From 9fa4732dd88abe2aadd724c09e95b5e282bf2d18 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 20 May 2022 18:22:31 -0500 Subject: [PATCH] Removed unnecessary tile position variables --- Systems/MiscWorldStateSystem.cs | 3 +-- Systems/WorldgenManagementSystem.cs | 25 ++++++++++------------- World/CalamityWorld.cs | 12 ----------- World/CustomTemple.cs | 31 +++++++++++++++-------------- World/WorldEvilIsland.cs | 4 +--- 5 files changed, 29 insertions(+), 46 deletions(-) diff --git a/Systems/MiscWorldStateSystem.cs b/Systems/MiscWorldStateSystem.cs index f05363c8ee..23eb9d9d6b 100644 --- a/Systems/MiscWorldStateSystem.cs +++ b/Systems/MiscWorldStateSystem.cs @@ -50,8 +50,7 @@ namespace CalamityMod BossRushEvent.BossRushActive = false; BossRushEvent.BossRushSpawnCountdown = 180; BossRushEvent.HostileProjectileKillCounter = 0; - newAltarX = 0; - newAltarY = 0; + CustomTemple.NewAlterPosition = Point.Zero; Abyss.AbyssChasmBottom = 0; Abyss.AtLeftSideOfWorld = false; diff --git a/Systems/WorldgenManagementSystem.cs b/Systems/WorldgenManagementSystem.cs index 549df841e4..2e9c0eaa06 100644 --- a/Systems/WorldgenManagementSystem.cs +++ b/Systems/WorldgenManagementSystem.cs @@ -105,30 +105,27 @@ namespace CalamityMod.Systems int xUnderworldGen = WorldGen.genRand.Next((int)((double)x * 0.1), (int)((double)x * 0.15)); int yUnderworldGen = Main.maxTilesY - 100; - fuhX = xUnderworldGen; - fuhY = yUnderworldGen; - MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen, yUnderworldGen, 180, 201, 120, 136); MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 50, yUnderworldGen - 30, 100, 111, 60, 71); MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 50, yUnderworldGen - 30, 100, 111, 60, 71); - MiscWorldgenRoutines.ChasmGenerator(fuhX - 110, fuhY - 10, WorldGen.genRand.Next(150) + 150); - MiscWorldgenRoutines.ChasmGenerator(fuhX + 110, fuhY - 10, WorldGen.genRand.Next(150) + 150); + MiscWorldgenRoutines.ChasmGenerator(xUnderworldGen - 110, yUnderworldGen - 10, WorldGen.genRand.Next(150) + 150); + MiscWorldgenRoutines.ChasmGenerator(xUnderworldGen + 110, yUnderworldGen - 10, WorldGen.genRand.Next(150) + 150); MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 150, yUnderworldGen - 30, 60, 66, 35, 41); MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 150, yUnderworldGen - 30, 60, 66, 35, 41); MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 180, yUnderworldGen - 20, 60, 66, 35, 41); MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 180, yUnderworldGen - 20, 60, 66, 35, 41); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX, fuhY + 30, 1323); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX - 22, fuhY + 15, 1322); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX + 22, fuhY + 15, 535); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX - 50, fuhY - 30, 112); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX + 50, fuhY - 30, 906); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX - 150, fuhY - 30, 218); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX + 150, fuhY - 30, 3019); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX - 180, fuhY - 20, 274); - MiscWorldgenRoutines.UnderworldIslandHouse(fuhX + 180, fuhY - 20, 220); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen, yUnderworldGen + 30, 1323); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen - 22, yUnderworldGen + 15, 1322); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen + 22, yUnderworldGen + 15, 535); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen - 50, yUnderworldGen - 30, 112); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen + 50, yUnderworldGen - 30, 906); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen - 150, yUnderworldGen - 30, 218); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen + 150, yUnderworldGen - 30, 3019); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen - 180, yUnderworldGen - 20, 274); + MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen + 180, yUnderworldGen - 20, 220); })); #endregion diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index a37e3f5c4c..9561d51ec8 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -30,18 +30,6 @@ namespace CalamityMod.World public static bool armageddon = false; // Armageddon Mode public static bool malice = false; // Malice Mode - // New Temple Altar - public static int newAltarX = 0; - public static int newAltarY = 0; - - // Evil Islands - public static int fehX = 0; - public static int fehY = 0; - - // Brimstone Crag - public static int fuhX = 0; - public static int fuhY = 0; - // Abyss & Sulphur public static bool rainingAcid; public static int acidRainPoints = 0; diff --git a/World/CustomTemple.cs b/World/CustomTemple.cs index b3b8b49c94..43fa9a646b 100644 --- a/World/CustomTemple.cs +++ b/World/CustomTemple.cs @@ -7,6 +7,10 @@ namespace CalamityMod.World { public class CustomTemple { + public static Point NewAlterPosition = Point.Zero; + + public static Vector2 FinalRoomSize = new(105f, 95f); + public static void NewJungleTemple() { bool success = false; @@ -66,8 +70,8 @@ namespace CalamityMod.World // Final temple room size. if (i == totalRooms - 1) { - width = WorldGen.genRand.Next(105, 116); - height = WorldGen.genRand.Next(90, 106); + width = (int)FinalRoomSize.X; + height = (int)FinalRoomSize.Y; roomPositionY += WorldGen.genRand.Next(6, 9); } @@ -90,7 +94,7 @@ namespace CalamityMod.World { if (rectangle.Intersects(roomBounds[j])) isValidRoom = false; - if (WorldGen.genRand.Next(100) == 0) + if (WorldGen.genRand.NextBool(100)) { xOffset++; } @@ -217,7 +221,7 @@ namespace CalamityMod.World if (i < totalRooms - 1) { reachedDestination = false; - if (WorldGen.genRand.Next(3) != 0) + if (!WorldGen.genRand.NextBool(3)) { Rectangle nextRoom = roomBounds[i + 1]; if (nextRoom.Y >= roomBounds[i].Y + roomBounds[i].Height) @@ -461,7 +465,7 @@ namespace CalamityMod.World if (Main.tile[randomPointInRoomX, randomPointInRoomY].WallType == 87 && !Main.tile[randomPointInRoomX, randomPointInRoomY].HasTile) { bool successPlacingSpikes = false; - if (WorldGen.genRand.Next(2) == 0) + if (WorldGen.genRand.NextBool(2)) { int xMoveDirection = WorldGen.genRand.NextBool(2).ToDirectionInt(); while (!Main.tile[randomPointInRoomX, randomPointInRoomY].HasTile) @@ -718,8 +722,7 @@ namespace CalamityMod.World } // And place the shrine. - CalamityWorld.newAltarX = roomCenterX - 1; - CalamityWorld.newAltarY = roomBottom - calculateHeightFromOutwardness(0) - 2; + NewAlterPosition = new(roomCenterX - 1, roomBottom - calculateHeightFromOutwardness(0) - 2); // Place some lanterns on the top of the room. for (int dx = 6; dx < roomBounds.Width - 6; dx += 10) @@ -896,14 +899,12 @@ namespace CalamityMod.World public static void NewJungleTempleLihzahrdAltar() { - int alterPositionX = CalamityWorld.newAltarX; - int alterPositionY = CalamityWorld.newAltarY; for (int i = 0; i <= 2; i++) { for (int j = 0; j < 2; j++) { - int framedAlterPositionX = alterPositionX + i; - int framedAlterPositionY = alterPositionY + j; + int framedAlterPositionX = NewAlterPosition.X + i; + int framedAlterPositionY = NewAlterPosition.Y + j; Main.tile[framedAlterPositionX, framedAlterPositionY].Get().HasTile = true; Main.tile[framedAlterPositionX, framedAlterPositionY].TileType = TileID.LihzahrdAltar; Main.tile[framedAlterPositionX, framedAlterPositionY].TileFrameX = (short)(i * 18); @@ -911,10 +912,10 @@ namespace CalamityMod.World } // Ensure that the tiles below the altar are active and valid. - Main.tile[i, alterPositionY + 2].Get().HasTile = true; - Main.tile[i, alterPositionY + 2].Get().Slope = SlopeType.Solid; - Main.tile[i, alterPositionY + 2].Get().IsHalfBlock = false; - Main.tile[i, alterPositionY + 2].TileType = TileID.LihzahrdBrick; + Main.tile[i, NewAlterPosition.Y + 2].Get().HasTile = true; + Main.tile[i, NewAlterPosition.Y + 2].Get().Slope = SlopeType.Solid; + Main.tile[i, NewAlterPosition.Y + 2].Get().IsHalfBlock = false; + Main.tile[i, NewAlterPosition.Y + 2].TileType = TileID.LihzahrdBrick; } } } diff --git a/World/WorldEvilIsland.cs b/World/WorldEvilIsland.cs index 7b7bbc993c..f3c1c422a7 100644 --- a/World/WorldEvilIsland.cs +++ b/World/WorldEvilIsland.cs @@ -45,10 +45,8 @@ namespace CalamityMod.World } xIslandGen = tileXLookup; - CalamityWorld.fehX = xIslandGen; - CalamityWorld.fehY = yIslandGen; EvilIsland(xIslandGen, yIslandGen); - EvilIslandHouse(CalamityWorld.fehX, CalamityWorld.fehY); + EvilIslandHouse(xIslandGen, yIslandGen); } public static void EvilIsland(int i, int j)