From 2f0d0b3b28f36a4acf2d97afa9be1b28f3f63cfd Mon Sep 17 00:00:00 2001 From: Mortis3 <53282720+DylanDoe21@users.noreply.github.com> Date: Thu, 9 Nov 2023 17:28:09 -0500 Subject: [PATCH] ambient tiles (yay) --- Systems/WorldgenManagementSystem.cs | 27 +--- Tiles/SunkenSea/Ambient/CoralPileGiant.cs | 2 +- Tiles/SunkenSea/Ambient/GiantNavystone.cs | 2 +- Tiles/SunkenSea/Ambient/TableCoral.cs | 2 + Tiles/SunkenSea/Ambient/WallCorals.cs | 2 +- Tiles/SunkenSea/EutrophicSand.cs | 2 +- Tiles/SunkenSea/HardenedEutrophicSand.cs | 2 +- Tiles/SunkenSea/PolypSand.cs | 2 +- World/Abyss.cs | 68 +++++++++ World/SunkenSea.cs | 170 +++++++++++++++++++++- 10 files changed, 249 insertions(+), 30 deletions(-) diff --git a/Systems/WorldgenManagementSystem.cs b/Systems/WorldgenManagementSystem.cs index 3bf9a3e6ac..7dd2c4d281 100644 --- a/Systems/WorldgenManagementSystem.cs +++ b/Systems/WorldgenManagementSystem.cs @@ -116,11 +116,14 @@ namespace CalamityMod.Systems })); } - // Sunken sea - int SunkenSeaIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Larva")); - if (SunkenSeaIndex != -1) + // All further tasks occur after vanilla worldgen is completed + int FinalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup")); + if (FinalIndex != -1) { - tasks.Insert(SunkenSeaIndex + 1, new PassLegacy("Sunken Sea", (progress, config) => + int currentFinalIndex = FinalIndex; + + // sunken sea + tasks.Insert(++currentFinalIndex, new PassLegacy("Sunken Sea", (progress, config) => { progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.SunkenSea").Value; @@ -133,21 +136,6 @@ namespace CalamityMod.Systems SunkenSea.PlaceBasaltBiome(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); SunkenSea.PlaceGleamingBurrows(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); SunkenSea.PlaceSunkenSeaAmbience(); - })); - } - - // All further tasks occur after vanilla worldgen is completed - int FinalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup")); - if (FinalIndex != -1) - { - int currentFinalIndex = FinalIndex; - - // sunken sea basalt lava cleanup (because vanilla for some reason places water in it) - tasks.Insert(++currentFinalIndex, new PassLegacy("Sunken Sea Cleanup", (progress, config) => - { - int sunkenSeaX = (GenVars.UndergroundDesertLocation.Left + GenVars.UndergroundDesertLocation.Right) / 2; - int sunkenSeaY = Main.maxTilesY / 2; - SunkenSea.BasaltBiomeLavaCleanup(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); })); @@ -287,6 +275,7 @@ namespace CalamityMod.Systems { progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.Abyss").Value; Abyss.PlaceAbyss(); + Abyss.AbyssCleanup(); })); // Sulphurous Sea (Part 2, after Abyss) diff --git a/Tiles/SunkenSea/Ambient/CoralPileGiant.cs b/Tiles/SunkenSea/Ambient/CoralPileGiant.cs index ae350dd085..3951a41547 100644 --- a/Tiles/SunkenSea/Ambient/CoralPileGiant.cs +++ b/Tiles/SunkenSea/Ambient/CoralPileGiant.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileSolid[Type] = false; TileObjectData.newTile.Width = 3; TileObjectData.newTile.Height = 4; - TileObjectData.newTile.Origin = new Point16(1, 3); + TileObjectData.newTile.Origin = new Point16(2, 3); TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; TileObjectData.newTile.StyleWrapLimit = 36; TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); diff --git a/Tiles/SunkenSea/Ambient/GiantNavystone.cs b/Tiles/SunkenSea/Ambient/GiantNavystone.cs index 164c26ab3c..e831caca37 100644 --- a/Tiles/SunkenSea/Ambient/GiantNavystone.cs +++ b/Tiles/SunkenSea/Ambient/GiantNavystone.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileSolid[Type] = false; TileObjectData.newTile.Width = 5; TileObjectData.newTile.Height = 5; - TileObjectData.newTile.Origin = new Point16(3, 4); + TileObjectData.newTile.Origin = new Point16(3, 5); TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16 }; TileObjectData.newTile.StyleWrapLimit = 36; TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); diff --git a/Tiles/SunkenSea/Ambient/TableCoral.cs b/Tiles/SunkenSea/Ambient/TableCoral.cs index a1e818ced2..0974ae1abd 100644 --- a/Tiles/SunkenSea/Ambient/TableCoral.cs +++ b/Tiles/SunkenSea/Ambient/TableCoral.cs @@ -12,6 +12,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { int subsheetHeight = 34; int subsheetWidth = 108; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -34,6 +35,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { num = fail ? 1 : 3; } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { int xPos = i % 1; diff --git a/Tiles/SunkenSea/Ambient/WallCorals.cs b/Tiles/SunkenSea/Ambient/WallCorals.cs index 5982f33828..ece98d4028 100644 --- a/Tiles/SunkenSea/Ambient/WallCorals.cs +++ b/Tiles/SunkenSea/Ambient/WallCorals.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { public class WallCorals : ModTile { - int subsheetHeight = 34; + int subsheetHeight = 54; int subsheetWidth = 108; public override void SetStaticDefaults() diff --git a/Tiles/SunkenSea/EutrophicSand.cs b/Tiles/SunkenSea/EutrophicSand.cs index 9c9b5d5430..9224b52f34 100644 --- a/Tiles/SunkenSea/EutrophicSand.cs +++ b/Tiles/SunkenSea/EutrophicSand.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.CanBeDugByShovel[Type] = true; DustType = 108; - AddMapEntry(new Color(92, 145, 167)); + AddMapEntry(new Color(192, 235, 243)); TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out tileAdjacency); TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out secondTileAdjacency); diff --git a/Tiles/SunkenSea/HardenedEutrophicSand.cs b/Tiles/SunkenSea/HardenedEutrophicSand.cs index 15eea56930..6a94f017e3 100644 --- a/Tiles/SunkenSea/HardenedEutrophicSand.cs +++ b/Tiles/SunkenSea/HardenedEutrophicSand.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.CanBeDugByShovel[Type] = true; DustType = 108; - AddMapEntry(new Color(67, 107, 143)); + AddMapEntry(new Color(92, 145, 167)); TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); diff --git a/Tiles/SunkenSea/PolypSand.cs b/Tiles/SunkenSea/PolypSand.cs index d7501c8ec8..9328b3d89b 100644 --- a/Tiles/SunkenSea/PolypSand.cs +++ b/Tiles/SunkenSea/PolypSand.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileShine2[Type] = true; DustType = 147; - AddMapEntry(new Color(210, 124, 45)); + AddMapEntry(new Color(244, 193, 181)); TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out tileAdjacency); TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out secondTileAdjacency); diff --git a/World/Abyss.cs b/World/Abyss.cs index 7cdca25089..93e7644eb6 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -1181,5 +1181,73 @@ namespace CalamityMod.World } AbleToUnlockChests = false; //reseting the variable in case players generate multiple worlds to prevent already unlocked chests from spawning } + + //method to clean up small clumps of tiles + public static void AbyssCleanup() + { + List blockTileTypes = new() + { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + }; + + void getAttachedPoints(int x, int y, List points) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); + Point p = new(x, y); + + if (!blockTileTypes.Contains(t.TileType) || !t.HasTile || points.Count > 75 || points.Contains(p)) + { + return; + } + + points.Add(p); + + getAttachedPoints(x + 1, y, points); + getAttachedPoints(x - 1, y, points); + getAttachedPoints(x, y + 1, points); + getAttachedPoints(x, y - 1, points); + } + + for (int x = 20; x < Main.maxTilesX - 20; x++) + { + for (int y = 20; y < Main.maxTilesY - 20; y++) + { + List chunkPoints = new(); + getAttachedPoints(x, y, chunkPoints); + + int cutoffLimit = 75; + if (chunkPoints.Count >= 1 && chunkPoints.Count < cutoffLimit) + { + foreach (Point p in chunkPoints) + { + WorldUtils.Gen(p, new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(true), + new Actions.SetLiquid() + })); + } + } + + Tile tile = Main.tile[x, y]; + + if (blockTileTypes.Contains(tile.TileType)) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[x, y - 1].HasTile && !Main.tile[x, y + 1].HasTile && !Main.tile[x - 1, y].HasTile; + bool OnlyLeft = !Main.tile[x, y - 1].HasTile && !Main.tile[x, y + 1].HasTile && !Main.tile[x + 1, y].HasTile; + bool OnlyDown = !Main.tile[x, y - 1].HasTile && !Main.tile[x - 1, y].HasTile && !Main.tile[x + 1, y].HasTile; + bool OnlyUp = !Main.tile[x, y + 1].HasTile && !Main.tile[x - 1, y].HasTile && !Main.tile[x + 1, y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(x, y); + } + } + } + } + } } } diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index a33e445229..8292ad0849 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -578,12 +578,12 @@ namespace CalamityMod.World if (CheckInEllipse(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) { //place geodes - if (WorldGen.genRand.NextBool(400) && Main.tile[X, Y].TileType == ModContent.TileType() && + if (WorldGen.genRand.NextBool(600) && Main.tile[X, Y].TileType == ModContent.TileType() && Main.tile[X, Y - 1].HasTile && Main.tile[X, Y + 1].HasTile && Main.tile[X - 1, Y].HasTile && Main.tile[X + 1, Y].HasTile) { if (EnoughTilesInArea(X, Y, 7, 7, 35, true)) { - PlaceGeode(X, Y, WorldGen.genRand.Next(5, 10)); + PlaceGeode(X, Y, WorldGen.genRand.Next(10, 17)); } } @@ -809,11 +809,171 @@ namespace CalamityMod.World } } - //TODO: this will be for placing all the ambient tiles, does nothing right now + //place all the ambient tiles in the sunken sea public static void PlaceSunkenSeaAmbience() { //first clean up unnecessary chunks of tiles CleanOutSmallClumps(); + + for (int X = 20; X <= Main.maxTilesX - 20; X++) + { + for (int Y = 20; Y <= Main.maxTilesY - 20; Y++) + { + //gleaming burrows ambient tiles + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + //brain coral + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); + } + //small brain coral + if (WorldGen.genRand.NextBool(5)) + { + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); + } + + //tube coral + if (WorldGen.genRand.NextBool(12)) + { + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); + } + //small tube coral + if (WorldGen.genRand.NextBool(8)) + { + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); + } + + //giant navystone piles + if (WorldGen.genRand.NextBool(15)) + { + ushort[] GiantPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(GiantPiles)); + } + + //small navystone piles + if (WorldGen.genRand.NextBool(10)) + { + ushort[] Piles = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(Piles)); + } + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + //stalactites + if (WorldGen.genRand.NextBool(10)) + { + ushort[] Stalactites = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y + 2, WorldGen.genRand.Next(Stalactites)); + } + //small stalactites + if (WorldGen.genRand.NextBool(8)) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType(), true, false, -1, 0); + } + + //stalagmites + if (WorldGen.genRand.NextBool(12)) + { + ushort[] Stalagmites = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 2, WorldGen.genRand.Next(Stalagmites)); + } + //small stalagmites + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceTile(X, Y - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + } + + //giant navystone piles + if (WorldGen.genRand.NextBool()) + { + ushort[] GiantPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(GiantPiles)); + } + + //small navystone piles + if (WorldGen.genRand.NextBool()) + { + ushort[] Piles = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(Piles)); + } + } + + //radiant reefs ambient tiles + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + //multi-colored corals + if (WorldGen.genRand.NextBool(3)) + { + ushort[] ColoredCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(ColoredCorals)); + } + + //blue coral trees + if (WorldGen.genRand.NextBool(6)) + { + ushort[] BlueCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BlueCorals)); + } + + //brown coral trees + if (WorldGen.genRand.NextBool(6)) + { + ushort[] BrownCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BrownCorals)); + } + + //fan coral + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); + } + + //misc corals + if (WorldGen.genRand.NextBool()) + { + ushort[] MiscCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(MiscCorals)); + } + } + + /* + //wall corals + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + if (WorldGen.genRand.NextBool(8) && !Main.tile[X - 1, Y].HasTile) + { + ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceTile(X - 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0); + } + + if (WorldGen.genRand.NextBool(8) && !Main.tile[X + 1, Y].HasTile) + { + ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceTile(X + 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0); + } + } + */ + } + } } public static void PlaceGeode(int X, int Y, int radius) @@ -836,7 +996,7 @@ namespace CalamityMod.World })); //second circle of prisms - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 3), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 4), Actions.Chain(new GenAction[] { blotchMod.Output(circle2) })); @@ -847,7 +1007,7 @@ namespace CalamityMod.World })); //clear out the middle of the circle - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 6), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 9), Actions.Chain(new GenAction[] { blotchMod.Output(circle3) }));