Better Mechanic Shed placement.

This commit is contained in:
mountaindrew10 committed 2025-04-23 08:14:30 -05:00
1 parent 74e2043d04
commit 4f61c7f68f
4 files changed
+82 -23

No files matched your search

+1 -4
View File
@@ -145,10 +145,7 @@ namespace CalamityMod.NPCs.DevourerofGods
NPC.frame = frame;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
return false;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false;
public override void AI()
{
+2 -10
View File
@@ -146,10 +146,7 @@ namespace CalamityMod.NPCs.DevourerofGods
NPC.frame = frame;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
return false;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false;
public override void AI()
{
@@ -450,15 +447,10 @@ namespace CalamityMod.NPCs.DevourerofGods
{
// viable???, done here since it's conditional
if (Main.zenithWorld && projectile.type == ModContent.ProjectileType<LaceratorYoyo>())
{
modifiers.SourceDamage *= 40f;
}
}
public override bool CheckActive()
{
return false;
}
public override bool CheckActive() => false;
public override bool CheckDead()
{
+1 -1
View File
@@ -500,7 +500,7 @@ namespace CalamityMod.World
int distanceToCheckForCriticalTilesY = 50;
int attempts = 0;
int maxAttempts = 10000;
int maxAttempts = 100000;
while (!altarPlaced)
{
WorldGen.gen = true;
+78 -8
View File
@@ -17,25 +17,95 @@ namespace CalamityMod.World
string mapKey = MechanicShedKey;
var schematic = TileMaps[mapKey];
int placementPositionX = WorldGen.genRand.Next(GenVars.snowOriginLeft + 100, GenVars.snowOriginRight - 100);
int placementPositionY = (int)Main.worldSurface - (Main.maxTilesY / 12);
int leftLimit = GenVars.snowOriginLeft + 100;
int rightLimit = GenVars.snowOriginRight - 100;
int placementPositionX = WorldGen.genRand.Next(leftLimit, rightLimit);
int placementPositionY = (int)Main.worldSurface - 50;
int distanceToCheckForSnowTilesX = 30;
int distanceToCheckForSnowTilesY = 5;
int snowTilesRequired = 100;
int emptyTilesRequired = 100;
bool foundValidGround = false;
int attempts = 0;
while (!foundValidGround && attempts++ < 100000)
int maxAttempts = 100000;
while (!foundValidGround && attempts <= maxAttempts)
{
while (!WorldGen.SolidTile(placementPositionX, placementPositionY) && placementPositionY <= Main.worldSurface)
attempts++;
// Check if there are enough snow tiles on the bottom of the shed's gen location
// 150 tiles checked in total
int snowTileCount = 0;
bool enoughSnowTilesOnBottom = false;
for (int shedTileCheckIndexX = placementPositionX - 15; shedTileCheckIndexX < placementPositionX - 15 + distanceToCheckForSnowTilesX; shedTileCheckIndexX++)
{
placementPositionY++;
if (enoughSnowTilesOnBottom)
break;
for (int shedTileCheckIndexY = placementPositionY - 5; shedTileCheckIndexY < placementPositionY - 5 + distanceToCheckForSnowTilesY; shedTileCheckIndexY++)
{
if (Main.tile[shedTileCheckIndexX, shedTileCheckIndexY] != null)
{
if (Main.tile[shedTileCheckIndexX, shedTileCheckIndexY].HasTile)
{
if (Main.tile[shedTileCheckIndexX, shedTileCheckIndexY].TileType == TileID.SnowBlock)
{
snowTileCount++;
if (snowTileCount >= snowTilesRequired)
{
enoughSnowTilesOnBottom = true;
break;
}
}
}
}
}
}
if (Main.tile[placementPositionX, placementPositionY].HasTile || Main.tile[placementPositionX, placementPositionY].WallType > 0)
// Check if there are enough empty tiles on the top of the shed's gen location
// 150 tiles checked in total
int emptyTileCount = 0;
bool enoughEmptyTilesOnTop = false;
for (int shedTileCheckIndexX = placementPositionX - 15; shedTileCheckIndexX < placementPositionX - 15 + distanceToCheckForSnowTilesX; shedTileCheckIndexX++)
{
foundValidGround = true;
if (enoughEmptyTilesOnTop)
break;
for (int shedTileCheckIndexY = placementPositionY - 20; shedTileCheckIndexY < placementPositionY - 20 + distanceToCheckForSnowTilesY; shedTileCheckIndexY++)
{
if ((Main.tile[shedTileCheckIndexX, shedTileCheckIndexY] == null ||
!Main.tile[shedTileCheckIndexX, shedTileCheckIndexY].HasTile) &&
Main.tile[shedTileCheckIndexX, shedTileCheckIndexY].WallType == WallID.None)
{
emptyTileCount++;
if (emptyTileCount >= emptyTilesRequired)
{
enoughEmptyTilesOnTop = true;
break;
}
}
}
}
if (enoughSnowTilesOnBottom && enoughEmptyTilesOnTop)
{
break;
}
else
{
placementPositionX += 5;
if (placementPositionX > rightLimit)
placementPositionX = leftLimit;
if (!enoughEmptyTilesOnTop)
placementPositionY -= 5;
else if (!enoughSnowTilesOnBottom)
placementPositionY += 5;
}
}
Point placementPoint = new Point(placementPositionX, placementPositionY + 5);
Point placementPoint = new Point(placementPositionX, placementPositionY);
Vector2 schematicSize = new Vector2(schematic.GetLength(0), schematic.GetLength(1));
SchematicAnchor anchorType = SchematicAnchor.BottomCenter;