From 9d414f35b10d5d50aef9491c948dbf314c2f2f2f Mon Sep 17 00:00:00 2001 From: Mortis3 <53282720+DylanDoe21@users.noreply.github.com> Date: Fri, 10 Nov 2023 22:57:48 -0500 Subject: [PATCH] More sunken sea progress --- ILEditing/MechanicILChanges.cs | 5 +- Projectiles/Typeless/CoralBubble.cs | 5 + Projectiles/Typeless/CoralBubbleSmall.cs | 5 + Systems/WorldgenManagementSystem.cs | 18 ++-- World/SunkenSea.cs | 115 ++++++++++++++++------- 5 files changed, 103 insertions(+), 45 deletions(-) diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index b8652d9518..fe6d3f3f8b 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -916,13 +916,12 @@ namespace CalamityMod.ILEditing return; Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (tile.LiquidAmount <= 0 || tile.HasTile || (Main.waterStyle != SulphuricWater.Type && + if (tile.LiquidAmount <= 0 || tile.HasTile || tile.Get().LiquidType != LiquidID.Water || (Main.waterStyle != SulphuricWater.Type && Main.waterStyle != SulphuricDepthsWater.Type && Main.waterStyle != SunkenSeaWater.Type)) return; Tile above = CalamityUtils.ParanoidTileRetrieval(x, y - 1); - if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && - Main.waterStyle == SulphuricWater.Type) + if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && Main.waterStyle == SulphuricWater.Type) { MediumMistParticle acidFoam = new(new(x * 16f + Main.rand.NextFloat(16f), y * 16f + 8f), -Vector2.UnitY.RotatedByRandom(0.67f) * Main.rand.NextFloat(1f, 2.4f), Color.LightSeaGreen, Color.White, 0.16f, 128f, 0.02f); GeneralParticleHandler.SpawnParticle(acidFoam); diff --git a/Projectiles/Typeless/CoralBubble.cs b/Projectiles/Typeless/CoralBubble.cs index acbb4f7280..de146fa377 100644 --- a/Projectiles/Typeless/CoralBubble.cs +++ b/Projectiles/Typeless/CoralBubble.cs @@ -20,6 +20,11 @@ namespace CalamityMod.Projectiles.Typeless Projectile.penetrate = 1; } + public override bool? CanCutTiles() + { + return false; + } + public override void AI() { if (Projectile.localAI[0] > 2f) diff --git a/Projectiles/Typeless/CoralBubbleSmall.cs b/Projectiles/Typeless/CoralBubbleSmall.cs index bf008315bc..ca7f53edaf 100644 --- a/Projectiles/Typeless/CoralBubbleSmall.cs +++ b/Projectiles/Typeless/CoralBubbleSmall.cs @@ -23,6 +23,11 @@ namespace CalamityMod.Projectiles.Typeless Projectile.penetrate = 1; } + public override bool? CanCutTiles() + { + return false; + } + public override void AI() { if (Projectile.localAI[0] > 2f) diff --git a/Systems/WorldgenManagementSystem.cs b/Systems/WorldgenManagementSystem.cs index 7dd2c4d281..13d10df823 100644 --- a/Systems/WorldgenManagementSystem.cs +++ b/Systems/WorldgenManagementSystem.cs @@ -116,14 +116,11 @@ namespace CalamityMod.Systems })); } - // All further tasks occur after vanilla worldgen is completed - int FinalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup")); - if (FinalIndex != -1) + // sunken sea + int SunkenSeaIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Cactus, Palm Trees, & Coral")); + if (SunkenSeaIndex != -1) { - int currentFinalIndex = FinalIndex; - - // sunken sea - tasks.Insert(++currentFinalIndex, new PassLegacy("Sunken Sea", (progress, config) => + tasks.Insert(SunkenSeaIndex + 1, new PassLegacy("Sunken Sea", (progress, config) => { progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.SunkenSea").Value; @@ -138,6 +135,13 @@ namespace CalamityMod.Systems SunkenSea.PlaceSunkenSeaAmbience(); SunkenSea.BasaltBiomeLavaCleanup(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); })); + } + + // 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; // Reallocate gems so rarity corresponds to depth tasks.Insert(++currentFinalIndex, new PassLegacy("Gem Depth Adjustment", (progress, config) => diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index d508818035..09b5cdde28 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -19,14 +19,11 @@ namespace CalamityMod.World /* Dylandoe checklist: - -Add navystone vines in game and to the generation (in ambient tile placement) + -Make ambient tiles naturally grow on sunken sea tiles/sands (only eutrophic sand is done) -Add basalt slab block - -Add navystone brick wall - -Make ambient tiles naturally grow on sunken sea tiles/sands + -Add navystone brick wall -Add the wall corals properly - -Make geodes not collide - -Add coral piles - -Make sunken sea walls + -Make sunken sea walls produce water */ //sides of the sunken sea (radiant reefs) @@ -108,6 +105,7 @@ namespace CalamityMod.World } } + //generate the actual caverns for (int X = origin.X - distanceInTiles - 3; X <= origin.X + distanceInTiles + 3; X++) { for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) @@ -136,7 +134,7 @@ namespace CalamityMod.World float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; - float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.235f; + float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.280f; //kill or place tiles depending on the noise map if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) @@ -154,7 +152,7 @@ namespace CalamityMod.World float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; - float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 3.5f + 0.235f; + float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 3.5f + 0.280f; if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) { @@ -195,6 +193,20 @@ namespace CalamityMod.World } } + for (int X = origin.X - distanceInTiles - 3; X <= origin.X + distanceInTiles + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) + { + if (!Main.tile[X, Y].HasTile && Main.tile[X, Y - 1].HasTile && Main.tile[X, Y + 1].HasTile && Main.tile[X - 1, Y].HasTile && Main.tile[X + 1, Y].HasTile) + { + WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); + } + } + } + } + //place extra tiles for (int X = origin.X - distanceInTiles - 3; X <= origin.X + distanceInTiles + 3; X++) { @@ -205,7 +217,8 @@ namespace CalamityMod.World bool canPlaceSand = false; //place sand clumps on top of exposed shellstone - if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile) + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && + !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && !Main.tile[X, Y - 5].HasTile) { canPlaceSand = true; } @@ -292,14 +305,21 @@ namespace CalamityMod.World //biome "blending" on the edges (disabled for now) if (percent > blurPercent) { - /* float outerEdgePercent = (percent - blurPercent) / (1f - blurPercent); - if (WorldGen.genRand.NextFloat(1f) > outerEdgePercent && Y < origin.Y && Main.tile[X, Y].HasTile) + if (Y > origin.Y && Main.tile[X, Y].HasTile && Main.tile[X, Y].TileType != ModContent.TileType()) { - Main.tile[X, Y].TileType = (ushort)ModContent.TileType(); - WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()) + })); } - */ } else { @@ -381,7 +401,8 @@ namespace CalamityMod.World bool canPlaceSand = false; //place sand clumps on top of exposed limestone - if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile) + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && + !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && !Main.tile[X, Y - 5].HasTile) { canPlaceSand = true; } @@ -552,7 +573,7 @@ namespace CalamityMod.World bool canPlaceSand = false; //place sand clumps on top of exposed navystone - if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile) + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && !Main.tile[X, Y - 3].HasTile) { canPlaceSand = true; } @@ -804,6 +825,26 @@ namespace CalamityMod.World { for (int Y = 20; Y <= Main.maxTilesY - 20; Y++) { + //place coral blobs + if (WorldGen.genRand.NextBool(120) && ((Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile) || + (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile))) + { + ushort[] Corals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(2, 4)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), new Actions.PlaceTile(WorldGen.genRand.Next(Corals)) + })); + } + //gleaming burrows ambient tiles if (Main.tile[X, Y].TileType == ModContent.TileType()) { @@ -830,7 +871,7 @@ namespace CalamityMod.World } //giant navystone piles - if (WorldGen.genRand.NextBool(15)) + if (WorldGen.genRand.NextBool(10)) { ushort[] GiantPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; @@ -838,7 +879,7 @@ namespace CalamityMod.World } //small navystone piles - if (WorldGen.genRand.NextBool(10)) + if (WorldGen.genRand.NextBool(5)) { ushort[] Piles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; @@ -993,27 +1034,28 @@ namespace CalamityMod.World return true; } - /* - public static bool CanPlaceGeode(int X, int Y, int halfCheck) + //placing sea prism geodes + public static bool PlaceGeode(int X, int Y, int radius) { - for (int i = X - halfCheck; i <= X + halfCheck; X++) + int crystalNearby = 0; + + //check a 20 by 20 square for other geodes before placing + for (int i = X - 20; i < X + 20; i++) { - for (int j = Y - halfCheck; j <= Y + halfCheck; j++) + for (int j = Y - 20; j < Y + 20; j++) { - if (Main.tile[i, j].TileType == ModContent.TileType()) + //dont allow geodes to place if another one is too close + if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType == ModContent.TileType()) { - return false; + crystalNearby++; + if (crystalNearby > 0) + { + return false; + } } } } - return true; - } - */ - - //placing sea prism geodes - public static void PlaceGeode(int X, int Y, int radius) - { ShapeData circle1 = new ShapeData(); ShapeData circle2 = new ShapeData(); ShapeData circle3 = new ShapeData(); @@ -1053,6 +1095,8 @@ namespace CalamityMod.World new Actions.SetLiquid(), new Actions.PlaceWall((ushort)ModContent.WallType()) })); + + return true; } //method to clean up small clumps of tiles (taken from the sulphur sea generation) @@ -1060,14 +1104,15 @@ namespace CalamityMod.World { List blockTileTypes = new() { - (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), }; void getAttachedPoints(int x, int y, List points)