Big hive built by Queen Bee simps.

This commit is contained in:
mountaindrew10 committed 2023-01-06 09:41:38 -06:00
1 parent 807810d1ed
commit 4c76c41a1b
3 files changed
+365 -12

No files matched your search

+22 -8
View File
@@ -32,7 +32,7 @@ namespace CalamityMod.Systems
int islandIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Island Houses"));
if (islandIndex != -1)
{
tasks.Insert(islandIndex + 2, new PassLegacy("EvilIsland", (progress, config) =>
tasks.Insert(islandIndex + 2, new PassLegacy("Evil Island", (progress, config) =>
{
progress.Message = "Corrupting a floating island";
WorldEvilIsland.PlaceEvilIsland();
@@ -52,6 +52,20 @@ namespace CalamityMod.Systems
CustomTemple.NewJungleTemple();
});
int hiveIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Hives"));
tasks[JungleTempleIndex] = new PassLegacy("Giant Hive", (progress, config) =>
{
progress.Message = "Building a giant beehive";
int attempts = 0;
while (attempts < 1000)
{
attempts++;
Point origin = WorldGen.RandomWorldPoint((int)Main.worldSurface, 20, Main.maxTilesY - (int)Main.worldSurface - 100, 20);
if (MiscWorldgenRoutines.CanPlaceGiantHive(origin, WorldGen.structures))
break;
}
});
int JungleTempleIndex2 = tasks.FindIndex(genpass => genpass.Name.Equals("Temple"));
tasks[JungleTempleIndex2] = new PassLegacy("Temple", (progress, config) =>
{
@@ -66,7 +80,7 @@ namespace CalamityMod.Systems
int TrapsIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Traps"));
if (TrapsIndex != -1)
{
tasks.Insert(TrapsIndex + 1, new PassLegacy("SunkenSea", (progress, config) =>
tasks.Insert(TrapsIndex + 1, new PassLegacy("Sunken Sea", (progress, config) =>
{
progress.Message = "Partially flooding an overblown desert";
int sunkenSeaX = WorldGen.UndergroundDesertLocation.Left;
@@ -88,7 +102,7 @@ namespace CalamityMod.Systems
if (FinalIndex != -1)
{
int currentFinalIndex = FinalIndex;
tasks.Insert(++currentFinalIndex, new PassLegacy("GemDepthAdjustment", (progress, config) =>
tasks.Insert(++currentFinalIndex, new PassLegacy("Gem Depth Adjustment", (progress, config) =>
{
progress.Message = "Reallocating gem deposits to match cavern depth";
MiscWorldgenRoutines.SmartGemGen();
@@ -98,7 +112,7 @@ namespace CalamityMod.Systems
//Not touching this yet because the Crags will be reworked in the future
#region BrimstoneCrag
tasks.Insert(++currentFinalIndex, new PassLegacy("BrimstoneCrag", (progress, config) =>
tasks.Insert(++currentFinalIndex, new PassLegacy("Brimstone Crag", (progress, config) =>
{
progress.Message = "Uncovering the ruins of a fallen empire";
@@ -134,21 +148,21 @@ namespace CalamityMod.Systems
int SulphurIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes"));
if (SulphurIndex != -1)
{
tasks.Insert(SulphurIndex + 1, new PassLegacy("SulphurSea", (progress, config) =>
tasks.Insert(SulphurIndex + 1, new PassLegacy("Sulphur Sea", (progress, config) =>
{
progress.Message = "Polluting one of the oceans";
SulphurousSea.PlaceSulphurSea();
}));
}
tasks.Insert(++currentFinalIndex, new PassLegacy("SpecialShrines", (progress, config) =>
tasks.Insert(++currentFinalIndex, new PassLegacy("Special Shrines", (progress, config) =>
{
progress.Message = "Placing hidden shrines";
UndergroundShrines.PlaceShrines();
}));
tasks.Insert(++currentFinalIndex, new PassLegacy("DraedonStructures", (progress, config) =>
tasks.Insert(++currentFinalIndex, new PassLegacy("Draedon Structures", (progress, config) =>
{
progress.Message = "Rust and Dust";
List<Point> workshopPositions = new List<Point>();
@@ -191,7 +205,7 @@ namespace CalamityMod.Systems
Abyss.PlaceAbyss();
}));
tasks.Insert(++currentFinalIndex, new PassLegacy("SulphurSea2", (progress, config) =>
tasks.Insert(++currentFinalIndex, new PassLegacy("Sulphur Sea 2", (progress, config) =>
{
progress.Message = "Further polluting one of the oceans";
SulphurousSea.SulphurSeaGenerationAfterAbyss();
+2 -2
View File
@@ -48,7 +48,7 @@ namespace CalamityMod.Tiles
}
}
if (placeBulb)
/*if (placeBulb)
{
WorldGen.Place2x2(i, j2, TileID.PlanteraBulb, 0);
WorldGen.SquareTileFrame(i, j2);
@@ -56,7 +56,7 @@ namespace CalamityMod.Tiles
WorldGen.SquareTileFrame(i - 1, j2);
if (Main.tile[i, j2].TileType == TileID.PlanteraBulb && Main.netMode == NetmodeID.Server)
NetMessage.SendTileSquare(-1, i, j2, 5);
}
}*/
}
}
}
+341 -2
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Potions;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Tiles;
@@ -15,6 +16,7 @@ using Terraria;
using Terraria.ID;
using Terraria.IO;
using Terraria.ModLoader;
using Terraria.Utilities;
using Terraria.WorldBuilding;
namespace CalamityMod.World
@@ -175,6 +177,343 @@ namespace CalamityMod.World
}
#endregion
#region Giant Hive
public static bool CanPlaceGiantHive(Point origin, StructureMap structures)
{
if (!structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100)))
return false;
if (TooCloseToImportantLocations(origin))
return false;
Ref<int> ref1 = new Ref<int>(0);
Ref<int> ref2 = new Ref<int>(0);
Ref<int> ref3 = new Ref<int>(0);
WorldUtils.Gen(origin, new Shapes.Circle(15), Actions.Chain(new Modifiers.IsSolid(), new Actions.Scanner(ref1), new Modifiers.OnlyTiles(60, 59), new Actions.Scanner(ref2), new Modifiers.OnlyTiles(60), new Actions.Scanner(ref3)));
if (ref2.Value / (float)ref1.Value < 0.75f || ref3.Value < 2)
return false;
int num = 0;
int[] array = new int[1000];
int[] array2 = new int[1000];
Vector2 vector = origin.ToVector2();
int numHiveTunnels = WorldGen.genRand.Next(10, 13);
for (int i = 0; i < numHiveTunnels; i++)
{
Vector2 vector2 = vector;
int num3 = WorldGen.genRand.Next(2, 5);
for (int j = 0; j < num3; j++)
vector2 = CreateHiveTunnel((int)vector.X, (int)vector.Y, WorldGen.genRand);
vector = vector2;
array[num] = (int)vector.X;
array2[num] = (int)vector.Y;
num++;
}
FrameOutAllHiveContents(origin, 50);
for (int k = 0; k < num; k++)
{
int num4 = array[k];
int y = array2[k];
int num5 = 1;
if (WorldGen.genRand.NextBool())
num5 = -1;
bool flag = false;
while (WorldGen.InWorld(num4, y, 10) && BadSpotForHoneyFall(num4, y))
{
num4 += num5;
if (Math.Abs(num4 - array[k]) > 50)
{
flag = true;
break;
}
}
if (!flag)
{
num4 += num5;
if (!SpotActuallyNotInHive(num4, y))
{
CreateBlockedHoneyCube(num4, y);
CreateDentForHoneyFall(num4, y, num5);
}
}
}
CreateStandForLarva(vector);
for (int l = 0; l < 1000; l++)
{
Vector2 vector3 = vector;
vector3.X += WorldGen.genRand.Next(-50, 51);
vector3.Y += WorldGen.genRand.Next(-50, 51);
if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(vector, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe)
{
CreateStandForLarva(vector3);
break;
}
}
structures.AddProtectedStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5);
return true;
}
private static void FrameOutAllHiveContents(Point origin, int squareHalfWidth)
{
int num = Math.Max(10, origin.X - squareHalfWidth);
int num2 = Math.Min(Main.maxTilesX - 10, origin.X + squareHalfWidth);
int num3 = Math.Max(10, origin.Y - squareHalfWidth);
int num4 = Math.Min(Main.maxTilesY - 10, origin.Y + squareHalfWidth);
for (int i = num; i < num2; i++)
{
for (int j = num3; j < num4; j++)
{
Tile tile = Main.tile[i, j];
if (tile.HasTile && tile.TileType == TileID.Hive)
WorldGen.SquareTileFrame(i, j);
if (tile.WallType == WallID.HiveUnsafe)
WorldGen.SquareWallFrame(i, j);
}
}
}
private static Vector2 CreateHiveTunnel(int i, int j, UnifiedRandom random)
{
double num = random.Next(20, 26);
float num2 = random.Next(30, 41);
float num3 = Main.maxTilesX / 4200;
num3 = (num3 + 1f) / 2f;
num *= (double)num3;
num2 *= num3;
double num4 = num;
Vector2 result = default;
result.X = i;
result.Y = j;
Vector2 vector = default;
vector.X = random.Next(-10, 11) * 0.2f;
vector.Y = random.Next(-10, 11) * 0.2f;
while (num > 0.0 && num2 > 0f)
{
if (result.Y > (Main.maxTilesY - 250))
num2 = 0f;
num = num4 * (double)(1f + random.Next(-20, 20) * 0.01f);
num2 -= 1f;
int num5 = (int)(result.X - num);
int num6 = (int)(result.X + num);
int num7 = (int)(result.Y - num);
int num8 = (int)(result.Y + num);
if (num5 < 1)
num5 = 1;
if (num6 > Main.maxTilesX - 1)
num6 = Main.maxTilesX - 1;
if (num7 < 1)
num7 = 1;
if (num8 > Main.maxTilesY - 1)
num8 = Main.maxTilesY - 1;
for (int k = num5; k < num6; k++)
{
for (int l = num7; l < num8; l++)
{
if (!WorldGen.InWorld(k, l, 50))
{
num2 = 0f;
}
else
{
if (Main.tile[k - 10, l].WallType == WallID.LihzahrdBrickUnsafe)
num2 = 0f;
if (Main.tile[k + 10, l].WallType == WallID.LihzahrdBrickUnsafe)
num2 = 0f;
if (Main.tile[k, l - 10].WallType == WallID.LihzahrdBrickUnsafe)
num2 = 0f;
if (Main.tile[k, l + 10].WallType == WallID.LihzahrdBrickUnsafe)
num2 = 0f;
}
if (l < Main.worldSurface && Main.tile[k, l - 5].WallType == WallID.None)
num2 = 0f;
float num9 = Math.Abs(k - result.X);
float num10 = Math.Abs(l - result.Y);
double num11 = Math.Sqrt(num9 * num9 + num10 * num10);
if (num11 < num4 * 0.4 * (1.0 + random.Next(-10, 11) * 0.005))
{
Main.tile[k, l].LiquidAmount = byte.MaxValue;
Main.tile[k, l].Get<LiquidData>().LiquidType = LiquidID.Honey;
Main.tile[k, l].WallType = WallID.HiveUnsafe;
Main.tile[k, l].Get<TileWallWireStateData>().HasTile = false;
Main.tile[k, l].Get<TileWallWireStateData>().IsHalfBlock = false;
Main.tile[k, l].Get<TileWallWireStateData>().Slope = SlopeType.Solid;
}
else if (num11 < num4 * 0.75 * (1.0 + random.Next(-10, 11) * 0.005))
{
Main.tile[k, l].LiquidAmount = 0;
if (Main.tile[k, l].WallType != WallID.HiveUnsafe)
{
Main.tile[k, l].Get<TileWallWireStateData>().HasTile = true;
Main.tile[k, l].Get<TileWallWireStateData>().IsHalfBlock = false;
Main.tile[k, l].Get<TileWallWireStateData>().Slope = SlopeType.Solid;
Main.tile[k, l].TileType = TileID.Hive;
}
}
if (num11 < num4 * 0.6 * (1.0 + random.Next(-10, 11) * 0.005))
{
Main.tile[k, l].WallType = WallID.HiveUnsafe;
if (random.NextBool())
{
Main.tile[k, l].LiquidAmount = byte.MaxValue;
Main.tile[k, l].Get<LiquidData>().LiquidType = LiquidID.Honey;
}
}
}
}
result += vector;
num2 -= 1f;
vector.Y += random.Next(-10, 11) * 0.05f;
vector.X += random.Next(-10, 11) * 0.05f;
}
return result;
}
private static bool TooCloseToImportantLocations(Point origin)
{
int x = origin.X;
int y = origin.Y;
int num = 150;
for (int i = x - num; i < x + num; i += 10)
{
if (i <= 0 || i > Main.maxTilesX - 1)
continue;
for (int j = y - num; j < y + num; j += 10)
{
if (j > 0 && j <= Main.maxTilesY - 1)
{
if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType == TileID.LihzahrdBrick)
return true;
if (Main.tile[i, j].WallType == WallID.CrimstoneUnsafe || Main.tile[i, j].WallType == WallID.EbonstoneUnsafe || Main.tile[i, j].WallType == WallID.LihzahrdBrickUnsafe)
return true;
}
}
}
return false;
}
private static void CreateDentForHoneyFall(int x, int y, int dir)
{
dir *= -1;
y++;
int num = 0;
while ((num < 4 || WorldGen.SolidTile(x, y)) && x > 10 && x < Main.maxTilesX - 10)
{
num++;
x += dir;
if (WorldGen.SolidTile(x, y))
{
WorldGen.PoundTile(x, y);
if (!Main.tile[x, y + 1].HasTile)
{
Main.tile[x, y + 1].Get<TileWallWireStateData>().HasTile = true;
Main.tile[x, y + 1].TileType = TileID.Hive;
}
}
}
}
private static void CreateBlockedHoneyCube(int x, int y)
{
for (int i = x - 1; i <= x + 2; i++)
{
for (int j = y - 1; j <= y + 2; j++)
{
if (i >= x && i <= x + 1 && j >= y && j <= y + 1)
{
Main.tile[i, j].Get<TileWallWireStateData>().HasTile = false;
Main.tile[i, j].LiquidAmount = byte.MaxValue;
Main.tile[i, j].Get<LiquidData>().LiquidType = LiquidID.Honey;
}
else
{
Main.tile[i, j].Get<TileWallWireStateData>().HasTile = true;
Main.tile[i, j].TileType = TileID.Hive;
}
}
}
}
private static bool SpotActuallyNotInHive(int x, int y)
{
for (int i = x - 1; i <= x + 2; i++)
{
for (int j = y - 1; j <= y + 2; j++)
{
if (i < 10 || i > Main.maxTilesX - 10)
return true;
if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType != TileID.Hive)
return true;
}
}
return false;
}
private static bool BadSpotForHoneyFall(int x, int y)
{
if (Main.tile[x, y].HasTile && Main.tile[x, y + 1].HasTile && Main.tile[x + 1, y].HasTile)
return !Main.tile[x + 1, y + 1].HasTile;
return true;
}
public static void CreateStandForLarva(Vector2 position)
{
WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp((int)position.X, 5, Main.maxTilesX - 5);
WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp((int)position.Y, 5, Main.maxTilesY - 5);
WorldGen.numLarva++;
if (WorldGen.numLarva >= WorldGen.larvaX.Length)
WorldGen.numLarva = WorldGen.larvaX.Length - 1;
int num = (int)position.X;
int num2 = (int)position.Y;
for (int i = num - 1; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++)
{
for (int j = num2 - 2; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++)
{
if (j != num2 + 1)
{
Main.tile[i, j].Get<TileWallWireStateData>().HasTile = false;
continue;
}
Main.tile[i, j].Get<TileWallWireStateData>().HasTile = true;
Main.tile[i, j].TileType = TileID.Hive;
Main.tile[i, j].Get<TileWallWireStateData>().Slope = SlopeType.Solid;
Main.tile[i, j].Get<TileWallWireStateData>().IsHalfBlock = false;
}
}
}
#endregion
#region Place Rox Shrine
public static void PlaceRoxShrine()
{
@@ -189,7 +528,7 @@ namespace CalamityMod.World
{
if ((Main.tile[x, y].TileFrameX == 18 && Main.tile[x, y].TileFrameY == 0) || (Main.tile[x, y].TileFrameX == 45 && Main.tile[x, y].TileFrameY == 0))
{
if (WorldGen.genRand.Next(3) == 0)
if (WorldGen.genRand.NextBool(3))
{
for (int dx = -1; dx < 2; dx++)
{