diff --git a/Items/Placeables/SunkenSea/TableCoralLeft.cs b/Items/Placeables/SunkenSea/TableCoralLeft.cs new file mode 100644 index 0000000000..835a1e43df --- /dev/null +++ b/Items/Placeables/SunkenSea/TableCoralLeft.cs @@ -0,0 +1,15 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.SunkenSea +{ + public class TableCoralLeft : ModItem, ILocalizedModType + { + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + } +} diff --git a/Items/Placeables/SunkenSea/TableCoralLeft.png b/Items/Placeables/SunkenSea/TableCoralLeft.png new file mode 100644 index 0000000000..db7fa149c0 Binary files /dev/null and b/Items/Placeables/SunkenSea/TableCoralLeft.png differ diff --git a/NPCs/SunkenSea/PrismBack.cs b/NPCs/SunkenSea/PrismBack.cs index ad485a77d8..7dde9bb49e 100644 --- a/NPCs/SunkenSea/PrismBack.cs +++ b/NPCs/SunkenSea/PrismBack.cs @@ -3,6 +3,7 @@ using CalamityMod.Enums; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Placeables.SunkenSea; using CalamityMod.Projectiles.Enemy; +using CalamityMod.Tiles.SunkenSea; using CalamityMod.Tiles.SunkenSea.Ambient; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -118,7 +119,7 @@ namespace CalamityMod.NPCs.SunkenSea // TODO // Change this to kelp when it's added - int tileType = ModContent.TileType(); + int tileType = ModContent.TileType(); // Assure the kelp still exists, if it's gone, clear the tile if ((TileX != 0 || TileY != 0) && t.TileType != tileType) diff --git a/Systems/Tile/TileFramingSystem.cs b/Systems/Tile/TileFramingSystem.cs index 8294009f1b..169adcfb8c 100644 --- a/Systems/Tile/TileFramingSystem.cs +++ b/Systems/Tile/TileFramingSystem.cs @@ -93,6 +93,8 @@ namespace CalamityMod.Systems (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), ]; private static int[][] PlantValidGrounds; @@ -121,7 +123,7 @@ namespace CalamityMod.Systems PlantValidGrounds[ModContent.TileType()] = new int[1] { ModContent.TileType() }; PlantValidGrounds[ModContent.TileType()] = new int[1] { ModContent.TileType() }; PlantValidGrounds[ModContent.TileType()] = new int[2] { ModContent.TileType(), ModContent.TileType() }; - PlantValidGrounds[ModContent.TileType()] = new int[1] { ModContent.TileType() }; + PlantValidGrounds[ModContent.TileType()] = new int[2] { ModContent.TileType(), ModContent.TileType() }; VineToGrass = new Dictionary { diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 222d30dfc0..be54ad4ca5 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -32,6 +32,11 @@ namespace CalamityMod.Tiles TileType(), TileType(), TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), TileType(), TileType(), TileType() diff --git a/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs index 28345f79b5..ebe0e4e805 100644 --- a/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs @@ -50,14 +50,4 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea frameYOffset = yPos * subsheetHeight; } } - - public class TableCoralEcho2 : TableCoralEcho - { - public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TableCoral2"; - } - - public class TableCoralEcho3 : TableCoralEcho - { - public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TableCoral3"; - } } diff --git a/Tiles/Rubblemaker/SunkenSea/WallCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/WallCoralEcho.cs index da444b3432..f7ef145f92 100644 --- a/Tiles/Rubblemaker/SunkenSea/WallCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/WallCoralEcho.cs @@ -5,9 +5,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { - public class WallCoral1Echo : WallCoral1 + public class WallCoralEcho : WallCoral { - public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoral1"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoral"; public override void SetStaticDefaults() { base.SetStaticDefaults(); @@ -17,31 +17,9 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea } } - public class WallCoral2Echo : WallCoral2 + public class WallCoralLeftEcho : WallCoralLeft { - public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoral2"; - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); - RegisterItemDrop(ModContent.ItemType(), Type, 0); - //FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); - } - } - - public class WallCoral3Echo : WallCoral3 - { - public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoral3"; - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); - RegisterItemDrop(ModContent.ItemType(), Type, 0); - //FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); - } - } - - public class WallCoral4Echo : WallCoral4 - { - public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoral4"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoralLeft"; public override void SetStaticDefaults() { base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/Ambient/GilHerb.cs b/Tiles/SunkenSea/Ambient/GilHerb.cs new file mode 100644 index 0000000000..a3b6f3b65d --- /dev/null +++ b/Tiles/SunkenSea/Ambient/GilHerb.cs @@ -0,0 +1,79 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class GilHerb : ModTile + { + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoFail[Type] = true; + Main.tileNoAttach[Type] = true; + TileID.Sets.IsVine[Type] = true; + TileID.Sets.VineThreads[Type] = true; + AddMapEntry(new Color(41, 97, 126)); + DustType = DustID.Grass; + HitSound = SoundID.Grass; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + Tile tile = Framing.GetTileSafely(i, j + 1); + if (tile.HasTile && tile.TileType == Type) + WorldGen.KillTile(i, j + 1); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileAbove = Framing.GetTileSafely(i, j - 1); + int type = -1; + if (tileAbove.HasTile && !tileAbove.BottomSlope) + type = tileAbove.TileType; + + if (type == ModContent.TileType() || type == Type) + return true; + + WorldGen.KillTile(i, j); + return true; + } + + public override void RandomUpdate(int i, int j) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) + { + bool PlaceVine = false; + int Test = j; + while (Test > j - 10) + { + Tile testTile = Framing.GetTileSafely(i, Test); + if (testTile.BottomSlope) + { + break; + } + else if (!testTile.HasTile || testTile.TileType != ModContent.TileType()) + { + Test--; + continue; + } + PlaceVine = true; + break; + } + + if (PlaceVine) + { + tileBelow.TileType = Type; + tileBelow.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.dedServ) + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } +} diff --git a/Tiles/SunkenSea/Ambient/GilHerb.png b/Tiles/SunkenSea/Ambient/GilHerb.png new file mode 100644 index 0000000000..5f73fb2918 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/GilHerb.png differ diff --git a/Tiles/SunkenSea/Ambient/SunkenShip.cs b/Tiles/SunkenSea/Ambient/SunkenShip.cs new file mode 100644 index 0000000000..d32f8472c6 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SunkenShip.cs @@ -0,0 +1,41 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.Enums; +using Terraria.DataStructures; +using Terraria.Localization; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SunkenShip : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileBlockLight[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.Width = 14; + TileObjectData.newTile.Height = 8; + TileObjectData.newTile.Origin = new Point16(7, 7); + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16, 16, 16, 16, 16, 16 }; + TileObjectData.newTile.AnchorBottom = new AnchorData( + AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, 14, 0); + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(100, 80, 70), Language.GetText("Sunken Ship")); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SunkenShip.png b/Tiles/SunkenSea/Ambient/SunkenShip.png new file mode 100644 index 0000000000..496c1e2555 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SunkenShip.png differ diff --git a/Tiles/SunkenSea/Ambient/TableCoral.cs b/Tiles/SunkenSea/Ambient/TableCoral.cs index 8d2c9bd58d..fc71856e8d 100644 --- a/Tiles/SunkenSea/Ambient/TableCoral.cs +++ b/Tiles/SunkenSea/Ambient/TableCoral.cs @@ -10,21 +10,21 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { public class TableCoral : ModTile { + private const int Variants = 3; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; Main.tileSolidTop[Type] = true; + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = Variants; + TileObjectData.newTile.RandomStyleRange = Variants; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.StyleMultiplier = 2; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.None, 0, 0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; TileObjectData.addTile(Type); + DustType = 253; AddMapEntry(new Color(54, 69, 72)); } @@ -34,12 +34,4 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient num = fail ? 1 : 3; } } - - public class TableCoral2 : TableCoral - { - } - - public class TableCoral3 : TableCoral - { - } } diff --git a/Tiles/SunkenSea/Ambient/TableCoral.png b/Tiles/SunkenSea/Ambient/TableCoral.png index 9d89cd26ed..be8d875999 100644 Binary files a/Tiles/SunkenSea/Ambient/TableCoral.png and b/Tiles/SunkenSea/Ambient/TableCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/TableCoral2.png b/Tiles/SunkenSea/Ambient/TableCoral2.png deleted file mode 100644 index 150bdffd38..0000000000 Binary files a/Tiles/SunkenSea/Ambient/TableCoral2.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/TableCoral3.png b/Tiles/SunkenSea/Ambient/TableCoral3.png deleted file mode 100644 index 8dab87e6c8..0000000000 Binary files a/Tiles/SunkenSea/Ambient/TableCoral3.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/TableCoralLeft.cs b/Tiles/SunkenSea/Ambient/TableCoralLeft.cs new file mode 100644 index 0000000000..d483514583 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/TableCoralLeft.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class TableCoralLeft : ModTile + { + private const int Variants = 3; + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileSolidTop[Type] = true; + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = Variants; + TileObjectData.newTile.RandomStyleRange = Variants; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.addTile(Type); + + DustType = 253; + AddMapEntry(new Color(54, 69, 72)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/TableCoralLeft.png b/Tiles/SunkenSea/Ambient/TableCoralLeft.png new file mode 100644 index 0000000000..e107da9ede Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TableCoralLeft.png differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral.cs b/Tiles/SunkenSea/Ambient/WallCoral.cs index 39e2e2dd73..a01eefb85c 100644 --- a/Tiles/SunkenSea/Ambient/WallCoral.cs +++ b/Tiles/SunkenSea/Ambient/WallCoral.cs @@ -2,25 +2,27 @@ using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.SunkenSea.Ambient { - public class WallCoral1 : ModTile + public class WallCoral : ModTile { + private const int Variants = 4; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; Main.tileSolidTop[Type] = false; Main.tileLighted[Type] = true; + + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = Variants; + TileObjectData.newTile.RandomStyleRange = Variants; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.None, 0, 0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.addAlternate(1); + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); TileObjectData.addTile(Type); DustType = 253; @@ -31,42 +33,5 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { num = fail ? 1 : 3; } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 0.42f; - g = 0.16f; - b = 0.16f; - } - } - - public class WallCoral2 : WallCoral1 - { - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 0.213f; - g = 0.349f; - b = 0.416f; - } - } - - public class WallCoral3 : WallCoral1 - { - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 0.151f; - g = 0.342f; - b = 0.284f; - } - } - - public class WallCoral4 : WallCoral1 - { - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 0.38f; - g = 0.28f; - b = 0.32f; - } } } diff --git a/Tiles/SunkenSea/Ambient/WallCoral.png b/Tiles/SunkenSea/Ambient/WallCoral.png new file mode 100644 index 0000000000..6ef197c60b Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WallCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral1.png b/Tiles/SunkenSea/Ambient/WallCoral1.png deleted file mode 100644 index 5efc01eaec..0000000000 Binary files a/Tiles/SunkenSea/Ambient/WallCoral1.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral2.png b/Tiles/SunkenSea/Ambient/WallCoral2.png deleted file mode 100644 index ab007eeb0f..0000000000 Binary files a/Tiles/SunkenSea/Ambient/WallCoral2.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral3.png b/Tiles/SunkenSea/Ambient/WallCoral3.png deleted file mode 100644 index c5017e1401..0000000000 Binary files a/Tiles/SunkenSea/Ambient/WallCoral3.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral4.png b/Tiles/SunkenSea/Ambient/WallCoral4.png deleted file mode 100644 index 901f50fcdb..0000000000 Binary files a/Tiles/SunkenSea/Ambient/WallCoral4.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/WallCoralLeft.cs b/Tiles/SunkenSea/Ambient/WallCoralLeft.cs new file mode 100644 index 0000000000..377e2b0457 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/WallCoralLeft.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class WallCoralLeft : ModTile + { + public const int Variants = 4; + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileSolidTop[Type] = false; + Main.tileLighted[Type] = true; + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = Variants; + TileObjectData.newTile.RandomStyleRange = Variants; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.addTile(Type); + DustType = 253; + AddMapEntry(new Color(54, 69, 72)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/WallCoralLeft.png b/Tiles/SunkenSea/Ambient/WallCoralLeft.png new file mode 100644 index 0000000000..f8e349d9e8 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WallCoralLeft.png differ diff --git a/Tiles/SunkenSea/EutrophicSand.cs b/Tiles/SunkenSea/EutrophicSand.cs index a21b66491d..0d161b29fd 100644 --- a/Tiles/SunkenSea/EutrophicSand.cs +++ b/Tiles/SunkenSea/EutrophicSand.cs @@ -45,26 +45,12 @@ namespace CalamityMod.Tiles.SunkenSea public override void RandomUpdate(int i, int j) { - if (!WorldGen.genRand.NextBool(8)) - return; - Tile tile = Main.tile[i, j]; - if (tile.HasTile || tile.LiquidAmount <= 0) - return; - - if (tile.LeftSlope || tile.RightSlope || tile.IsHalfBlock) - return; - Tile up = Main.tile[i, j - 1]; - if (up.HasTile || up.LiquidAmount <= 0) - return; - Tile up2 = Main.tile[i, j - 2]; - if (up2.HasTile || up2.LiquidAmount <= 0) - return; // Place corals - if (WorldGen.genRand.NextBool(3)) + if (WorldGen.genRand.NextBool(8) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) { up.TileType = (ushort)ModContent.TileType(); up.HasTile = true; @@ -79,57 +65,18 @@ namespace CalamityMod.Tiles.SunkenSea NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); } } - - //multi-colored corals - if (WorldGen.genRand.NextBool(3)) + // Place sunken kelp + if (WorldGen.genRand.NextBool(2) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) { - ushort[] ColoredCorals = new ushort[] { (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + up.TileType = (ushort)ModContent.TileType(); + up.HasTile = true; - ushort newObject = Main.rand.Next(ColoredCorals); + WorldGen.SquareTileFrame(i, j - 1, true); - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); - } - - //blue coral trees - if (WorldGen.genRand.NextBool(6)) - { - ushort[] BlueCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - ushort newObject = Main.rand.Next(BlueCorals); - - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); - } - - //brown coral trees - if (WorldGen.genRand.NextBool(6)) - { - ushort[] BrownCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - ushort newObject = Main.rand.Next(BrownCorals); - - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); - } - - //fan coral - if (WorldGen.genRand.NextBool(10)) - { - WorldGen.PlaceObject(i, j - 1, (ushort)ModContent.TileType()); - } - - //misc corals - if (WorldGen.genRand.NextBool()) - { - ushort[] MiscCorals = new ushort[] { (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - ushort newObject = Main.rand.Next(MiscCorals); - - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); + if (Main.dedServ) + { + NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + } } } diff --git a/Tiles/SunkenSea/HardenedEutrophicSand.cs b/Tiles/SunkenSea/HardenedEutrophicSand.cs index 27c252ec75..957214a8c7 100644 --- a/Tiles/SunkenSea/HardenedEutrophicSand.cs +++ b/Tiles/SunkenSea/HardenedEutrophicSand.cs @@ -85,6 +85,20 @@ namespace CalamityMod.Tiles.SunkenSea NetMessage.SendObjectPlacement(-1, i, j - 1, (ushort)ModContent.TileType(), 0, 0, -1, -1); } } + + // Place sunken kelp + if (WorldGen.genRand.NextBool(2) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + { + up.TileType = (ushort)ModContent.TileType(); + up.HasTile = true; + + WorldGen.SquareTileFrame(i, j - 1, true); + + if (Main.dedServ) + { + NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + } + } } } } diff --git a/Tiles/SunkenSea/Limestone.cs b/Tiles/SunkenSea/Limestone.cs index 91779fe959..fb13b3429f 100644 --- a/Tiles/SunkenSea/Limestone.cs +++ b/Tiles/SunkenSea/Limestone.cs @@ -1,5 +1,6 @@ using CalamityMod.Systems; using CalamityMod.Tiles.Merges; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -49,5 +50,25 @@ namespace CalamityMod.Tiles.SunkenSea { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void RandomUpdate(int i, int j) + { + Tile Tile = Framing.GetTileSafely(i, j); + Tile Below = Framing.GetTileSafely(i, j + 1); + Tile Above = Framing.GetTileSafely(i, j - 1); + + if (!Below.HasTile && Below.LiquidType <= 0 && !Tile.BottomSlope) + { + if (Main.rand.NextBool(10)) + { + Below.TileType = (ushort)ModContent.TileType(); + Below.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.dedServ) + { + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } } } diff --git a/Tiles/SunkenSea/SunkenKelp.cs b/Tiles/SunkenSea/SunkenKelp.cs new file mode 100644 index 0000000000..d8c6aab42d --- /dev/null +++ b/Tiles/SunkenSea/SunkenKelp.cs @@ -0,0 +1,147 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class SunkenKelp : ModTile + { + private const int MaxChainLength = 18; + private static readonly ushort[] ValidAnchors = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + private const short FrameBottom = 0; + private const short FrameMid = 18; + private const short FrameTop = 36; + private const short FrameWidth = 18; + + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileID.Sets.IsVine[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; + + HitSound = SoundID.Grass; + DustType = DustID.Grass; + + AddMapEntry(new Color(27, 112, 68)); + } + + public override void RandomUpdate(int i, int j) + { + if (!IsTopmostSegment(i, j)) + return; + + if (j <= 0 || Main.tile[i, j - 1].HasTile) + return; + + if (!IsSupportedFromBelow(i, j)) + return; + + if (GetChainLengthUpward(i, j) >= MaxChainLength) + return; + + bool placed = WorldGen.PlaceTile(i, j - 1, Type, mute: true, forced: true); + if (placed) + { + SetFrame(i, j - 1, FrameTop); + SetFrame(i, j, FrameMid); + UpdateBaseSegment(i, j + GetChainLengthDownward(i, j)); + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + if (!IsSupportedFromBelow(i, j)) + { + WorldGen.KillTile(i, j, noItem: true, effectOnly: false); + return false; + } + + if (IsTopmostSegment(i, j)) + SetFrame(i, j, FrameTop); + else if (IsBottomSegment(i, j)) + SetFrame(i, j, FrameBottom); + else + SetFrame(i, j, FrameMid); + + return false; + } + + private static bool IsSupportedFromBelow(int i, int j) + { + if (j >= Main.maxTilesY - 1) return false; + Tile below = Main.tile[i, j + 1]; + if (!below.HasTile) return false; + + ushort t = below.TileType; + if (t == ModContent.TileType()) + return true; + + foreach (ushort anchor in ValidAnchors) + if (t == anchor) + return true; + + return false; + } + + private static bool IsTopmostSegment(int i, int j) + { + if (j <= 0) return true; + Tile above = Main.tile[i, j - 1]; + return !(above.HasTile && above.TileType == ModContent.TileType()); + } + + private static bool IsBottomSegment(int i, int j) + { + if (j >= Main.maxTilesY - 1) return true; + Tile below = Main.tile[i, j + 1]; + return !(below.HasTile && below.TileType == ModContent.TileType()); + } + + private static int GetChainLengthUpward(int i, int j) + { + int length = 1; + int y = j - 1; + int vineType = ModContent.TileType(); + while (y >= 0 && Main.tile[i, y].HasTile && Main.tile[i, y].TileType == vineType) + { + length++; + y--; + if (length > MaxChainLength) break; + } + return length; + } + + private static int GetChainLengthDownward(int i, int j) + { + int length = 0; + int y = j + 1; + int vineType = ModContent.TileType(); + while (y < Main.maxTilesY && Main.tile[i, y].HasTile && Main.tile[i, y].TileType == vineType) + { + length++; + y++; + } + return length; + } + + private static void SetFrame(int i, int j, short frameYRow) + { + Tile tile = Main.tile[i, j]; + tile.TileFrameX = (short)(WorldGen.genRand.Next(3) * FrameWidth); + tile.TileFrameY = frameYRow; + } + + private static void UpdateBaseSegment(int i, int bottomY) + { + Tile t = Main.tile[i, bottomY]; + if (t.HasTile && t.TileType == ModContent.TileType()) + SetFrame(i, bottomY, FrameBottom); + } + } +} diff --git a/Tiles/SunkenSea/SunkenKelp.png b/Tiles/SunkenSea/SunkenKelp.png index d6ef19a3c6..46c82c6488 100644 Binary files a/Tiles/SunkenSea/SunkenKelp.png and b/Tiles/SunkenSea/SunkenKelp.png differ diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index 8830825e46..769ca64ca5 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -19,7 +19,18 @@ namespace CalamityMod.World { public class SunkenSea { - /* + + internal static class SSOffsets + { + public static int TimelessShoresX = 0, TimelessShoresY = 0; + public static int RadiantReefsX = 0, RadiantReefsY = 55; + public static int PolypForestX = 0, PolypForestY = 0; + public static int GleamingBurrowsX = 0, GleamingBurrowsY = 75; + public static int ClamDenX = 0, ClamDenY = 75; + public static int BasaltGullyX = 0, BasaltGullyY = 15; + public static int GlobalX = 0, GlobalY = -20; + } +/* checklist: -Add the wall corals properly @@ -38,6 +49,10 @@ namespace CalamityMod.World public static void PlaceTimelessShores(int startPosX, int startPosY) { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.TimelessShoresX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.TimelessShoresY; + int biomeSize = 250 + (Main.maxTilesX / 180); // @@ -53,10 +68,10 @@ namespace CalamityMod.World else return -steepness * x + steepness; } - ParallelFor(startPosX - biomeSize - 5, startPosX + biomeSize + 20, 15, (X) => + ParallelFor(startX - biomeSize - 5, startX + biomeSize + 20, 15, (X) => { - float height = MathHelper.Lerp(startPosY + 35, startPosY - 15, trapezoidLateralSteep(Utils.GetLerpValue(startPosX - biomeSize - 20, startPosX + biomeSize + 20, X))); - for (int Y = startPosY + 25; Y >= height; Y -= 10) + float height = MathHelper.Lerp(startY + 35, startY - 15, trapezoidLateralSteep(Utils.GetLerpValue(startX - biomeSize - 20, startX + biomeSize + 20, X))); + for (int Y = startY + 25; Y >= height; Y -= 10) { ShapeData circle = new ShapeData(); WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(30), Actions.Chain(new GenAction[] @@ -72,10 +87,10 @@ namespace CalamityMod.World // Makes the bottom borders of the Timeless Shores curved downwards. // const int totalCuveDepth = 90; - ParallelFor(startPosX - biomeSize - 10, startPosX - biomeSize + 200, 10, (x) => + ParallelFor(startX - biomeSize - 10, startX - biomeSize + 200, 10, (x) => { - int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startPosX - biomeSize - 17, startPosX - biomeSize + 200, x, true))); - for (int y = startPosY + 50; y <= startPosY + 70 + curveDepth; y += 5) + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 17, startX - biomeSize + 200, x, true))); + for (int y = startY + 50; y <= startY + 70 + curveDepth; y += 5) { ShapeData circle = new(); WorldUtils.Gen(new Point(x, y), new Shapes.Slime(30), Actions.Chain(new GenAction[] @@ -86,10 +101,10 @@ namespace CalamityMod.World WorldUtils.Gen(new Point(x, y), new ModShapes.All(circle), new Actions.SetTile((ushort)ModContent.TileType())); } }); - ParallelFor(startPosX + biomeSize - 200, startPosX + biomeSize + 10, 5, (x) => + ParallelFor(startX + biomeSize - 200, startX + biomeSize + 10, 5, (x) => { - int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startPosX + biomeSize + 20, startPosX + biomeSize - 200, x, true))); - for (int y = startPosY + 50; y <= startPosY + 70 + curveDepth; y += 5) + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 20, startX + biomeSize - 200, x, true))); + for (int y = startY + 50; y <= startY + 70 + curveDepth; y += 5) { ShapeData circle = new(); WorldUtils.Gen(new Point(x, y), new Shapes.Slime(30), Actions.Chain(new GenAction[] @@ -103,13 +118,13 @@ namespace CalamityMod.World // Clear a smaller square out of the center where the biomes stuff will be // Added curves to the top of the biome via curve depth -hpu 02/19/25 - ParallelFor(startPosX - biomeSize + 10, startPosX + biomeSize - 10, 1, (X) => + ParallelFor(startX - biomeSize + 10, startX + biomeSize - 10, 1, (X) => { - int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startPosX + biomeSize + 20, startPosX + biomeSize - 200, X, true))); - int curveDepth2 = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startPosX - biomeSize - 17, startPosX - biomeSize + 200, X, true))); + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 20, startX + biomeSize - 200, X, true))); + int curveDepth2 = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 17, startX - biomeSize + 200, X, true))); int random = WorldGen.genRand.Next(-40, 10); - for (int Y = startPosY - 25 + curveDepth + curveDepth2; Y <= startPosY + 50; Y++) + for (int Y = startY - 25 + curveDepth + curveDepth2; Y <= startY + 50; Y++) { ShapeData circle = new ShapeData(); GenAction blotchMod = new Modifiers.Blotches(2, 0.4); @@ -128,24 +143,24 @@ namespace CalamityMod.World // // Places slopes at the sides of the shores to actually make shores. // - ParallelFor(startPosX - biomeSize - 15, startPosX - biomeSize + 200, 20, (moundX) => + ParallelFor(startX - biomeSize - 15, startX - biomeSize + 200, 20, (moundX) => { int RandomX = Main.rand.Next(15, 20); ShapeData mound = new(); GenAction blotchMod = new Modifiers.Blotches().Output(mound); - int moundY = startPosY + 75; - int moundHeight = (int)MathHelper.Lerp(60f, 5f, MathF.Sqrt(Utils.GetLerpValue(startPosX - biomeSize + 27, startPosX - biomeSize + 200, moundX))); + int moundY = startY + 75; + int moundHeight = (int)MathHelper.Lerp(60f, 5f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize + 27, startX - biomeSize + 200, moundX))); WorldUtils.Gen(new Point(moundX, moundY), new Shapes.Mound(30, moundHeight), blotchMod); WorldUtils.Gen(new Point(moundX, moundY), new ModShapes.All(mound), new Actions.SetTile((ushort)ModContent.TileType())); WorldUtils.Gen(new Point(moundX, moundY), new ModShapes.All(mound), new Actions.PlaceWall((ushort)ModContent.WallType())); }); - ParallelFor(startPosX + biomeSize - 200, startPosX + biomeSize - 15, 20, (moundX) => + ParallelFor(startX + biomeSize - 200, startX + biomeSize - 15, 20, (moundX) => { ShapeData mound = new(); GenAction blotchMod = new Modifiers.Blotches().Output(mound); - int moundY = startPosY + 75; - int moundHeight = (int)MathHelper.Lerp(60f, 5f, MathF.Sqrt(Utils.GetLerpValue(startPosX + biomeSize - 27, startPosX + biomeSize - 200, moundX))); + int moundY = startY + 75; + int moundHeight = (int)MathHelper.Lerp(60f, 5f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize - 27, startX + biomeSize - 200, moundX))); WorldUtils.Gen(new Point(moundX, moundY), new Shapes.Mound(30, moundHeight), blotchMod); WorldUtils.Gen(new Point(moundX, moundY), new ModShapes.All(mound), new Actions.SetTile((ushort)ModContent.TileType())); @@ -158,11 +173,11 @@ namespace CalamityMod.World const int platformSize = 130; const int platformHeight = 35; // Remember that because of Terraria's coordinate system, making it lower actually makes it higher. const int platformDepth = 35; // How deep it goes. Like above, the higher it is, the lower it goes. - ParallelFor(startPosX - platformSize / 2, startPosX + platformSize / 2, 5, (platformX) => + ParallelFor(startX - platformSize / 2, startX + platformSize / 2, 5, (platformX) => { // This makes the "stem" of the platform be thinner towards the base and then expand on the top. - int thickness = (int)(MathF.Pow(CalamityUtils.Convert01To010(Utils.GetLerpValue(startPosX - platformSize / 2, startPosX + platformSize / 2, platformX)), 3f) * platformDepth) + platformHeight; - for (int platformY = startPosY + platformHeight; platformY <= startPosY + thickness; platformY++) + int thickness = (int)(MathF.Pow(CalamityUtils.Convert01To010(Utils.GetLerpValue(startX - platformSize / 2, startX + platformSize / 2, platformX)), 3f) * platformDepth) + platformHeight; + for (int platformY = startY + platformHeight; platformY <= startY + thickness; platformY++) { WorldUtils.Gen(new Point(platformX, platformY), new Shapes.Circle(5), Actions.Chain(new GenAction[] { @@ -172,28 +187,28 @@ namespace CalamityMod.World })); } }); - ParallelFor(startPosX - platformSize / 2, startPosX + platformSize / 2, 1, (x) => + ParallelFor(startX - platformSize / 2, startX + platformSize / 2, 1, (x) => { - float interpolator = CalamityUtils.Convert01To010(Utils.GetLerpValue(startPosX - platformSize / 2, startPosX + platformSize / 2, x, true)); + float interpolator = CalamityUtils.Convert01To010(Utils.GetLerpValue(startX - platformSize / 2, startX + platformSize / 2, x, true)); int elevation = (int)MathHelper.Lerp(4f, 1f, interpolator); - WorldUtils.Gen(new Point(x, startPosY + platformHeight - 7), new Shapes.Circle(elevation), Actions.Chain(new GenAction[] { new Actions.Clear(), })); + WorldUtils.Gen(new Point(x, startY + platformHeight - 7), new Shapes.Circle(elevation), Actions.Chain(new GenAction[] { new Actions.Clear(), })); }); // Plateau - ParallelFor(startPosX - biomeSize, startPosX + biomeSize, 100, (wallPillarX) => + ParallelFor(startX - biomeSize, startX + biomeSize, 100, (wallPillarX) => { int randomDisplacement = WorldGen.genRand.Next(-27, 46); int RandomX = Main.rand.Next(15, 20); int RandomH = Main.rand.Next(20, 35); - for (int wallPillarY = startPosY + RandomH; wallPillarY <= startPosY + 60; wallPillarY += 10) + for (int wallPillarY = startY + RandomH; wallPillarY <= startY + 60; wallPillarY += 10) { // Along the height of the pillar, it becomes shorter the more closer to the center we get. - int pillarWidth = (int)(CalamityUtils.Convert01To010(Utils.GetLerpValue(startPosY - RandomH, startPosY + 45, wallPillarY)) * 25); + int pillarWidth = (int)(CalamityUtils.Convert01To010(Utils.GetLerpValue(startY - RandomH, startY + 45, wallPillarY)) * 25); ShapeData rectangle = new ShapeData(); GenAction blotchFilter = new Modifiers.Blotches(1, 0.4); - GenAction ditherFilter = new Modifiers.Dither(Math.Min(Utils.GetLerpValue(startPosY + 30, startPosY + 70, wallPillarY) + 0.25, 1)); + GenAction ditherFilter = new Modifiers.Dither(Math.Min(Utils.GetLerpValue(startY + 30, startY + 70, wallPillarY) + 0.25, 1)); WorldUtils.Gen(new Point(randomDisplacement + wallPillarX + pillarWidth / 2, wallPillarY), new Shapes.Circle(RandomX - pillarWidth + 3, RandomX), Actions.Chain(new GenAction[] { @@ -211,9 +226,9 @@ namespace CalamityMod.World }); //place water below the clear barrier for the islands so that theres water inbetween them - ParallelFor(startPosX - biomeSize + 35, startPosX + biomeSize - 35, 1, (WaterX) => + ParallelFor(startX - biomeSize + 35, startX + biomeSize - 35, 1, (WaterX) => { - for (int WaterY = startPosY + 37; WaterY <= startPosY + 60; WaterY++) + for (int WaterY = startY + 37; WaterY <= startY + 60; WaterY++) { Main.tile[WaterX, WaterY].Get().LiquidType = LiquidID.Water; Main.tile[WaterX, WaterY].LiquidAmount = byte.MaxValue; @@ -224,19 +239,19 @@ namespace CalamityMod.World // Generates pillars made out of walls at random points in the Timeless Shores. // const int furthestDistanceFromCenter = 100; - ParallelFor(startPosX - (biomeSize / 2) - furthestDistanceFromCenter, startPosX + (biomeSize / 2) + furthestDistanceFromCenter, 100, (wallPillarX) => + ParallelFor(startX - (biomeSize / 2) - furthestDistanceFromCenter, startX + (biomeSize / 2) + furthestDistanceFromCenter, 100, (wallPillarX) => { int randomDisplacementX = WorldGen.genRand.Next(-10, 10); int RandomX = Main.rand.Next(3, 6); - for (int wallPillarY = startPosY - 75; wallPillarY <= startPosY + 80; wallPillarY += 10) + for (int wallPillarY = startY - 75; wallPillarY <= startY + 80; wallPillarY += 10) { // Along the height of the pillar, it becomes shorter the more closer to the center we get. - int pillarWidth = (int)(CalamityUtils.Convert01To010(Utils.GetLerpValue(startPosY - 75, startPosY + 50, wallPillarY)) * 25); + int pillarWidth = (int)(CalamityUtils.Convert01To010(Utils.GetLerpValue(startY - 75, startY + 50, wallPillarY)) * 25); ShapeData rectangle = new ShapeData(); GenAction blotchFilter = new Modifiers.Blotches(2, 0.4); - GenAction ditherFilter = new Modifiers.Dither(Math.Min(Utils.GetLerpValue(startPosY + 40, startPosY + 70, wallPillarY) + 0.25, 1)); + GenAction ditherFilter = new Modifiers.Dither(Math.Min(Utils.GetLerpValue(startY + 40, startY + 70, wallPillarY) + 0.25, 1)); WorldUtils.Gen(new Point(randomDisplacementX + wallPillarX + pillarWidth / 2, wallPillarY), new Shapes.Rectangle(25 - pillarWidth + 3, 15), Actions.Chain(new GenAction[] { @@ -256,14 +271,14 @@ namespace CalamityMod.World // Makes the transition area to the Timeless Shores. // Replaces tiles, walls, and places some water spots. // - ParallelFor(startPosX - biomeSize - 30, startPosX + biomeSize + 30, 20, (x) => + ParallelFor(startX - biomeSize - 30, startX + biomeSize + 30, 20, (x) => { - int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startPosX + biomeSize + 30, startPosX + biomeSize - 200, x, true))); - int curveDepth2 = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startPosX - biomeSize - 30, startPosX - biomeSize + 200, x, true))); + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 30, startX + biomeSize - 200, x, true))); + int curveDepth2 = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 30, startX - biomeSize + 200, x, true))); - for (int y = startPosY - 5; y >= startPosY - 149; y -= 15) + for (int y = startY - 5; y >= startY - 149; y -= 15) { - float interpolator = Utils.GetLerpValue(startPosY - 90, startPosY - 150, y, true); + float interpolator = Utils.GetLerpValue(startY - 90, startY - 150, y, true); // This lerp does absolutely nothing. float ditherStrength = MathHelper.Lerp(0f, 0f, interpolator); @@ -277,7 +292,7 @@ namespace CalamityMod.World })); // Changing these makes the walls dither higher up than tiles, to prevent the biome from changing earlier than expected. Still looks nice imo :) - interpolator = Utils.GetLerpValue(startPosY - 90, startPosY - 200, y, true); + interpolator = Utils.GetLerpValue(startY - 90, startY - 200, y, true); ditherStrength = MathHelper.Lerp(0f, 0f, interpolator); WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] @@ -289,7 +304,7 @@ namespace CalamityMod.World })); // I forgot to change this one. :peepotired: - interpolator = Utils.GetLerpValue(startPosY - 90, startPosY - 150, y, true); + interpolator = Utils.GetLerpValue(startY - 90, startY - 150, y, true); ditherStrength = MathHelper.Lerp(0f, 0f, interpolator); WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] { @@ -298,7 +313,7 @@ namespace CalamityMod.World new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()), })); - interpolator = Utils.GetLerpValue(startPosY - 90, startPosY - 150, y, true); + interpolator = Utils.GetLerpValue(startY - 90, startY - 150, y, true); ditherStrength = MathHelper.Lerp(0f, 0f, interpolator); WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] { @@ -311,7 +326,7 @@ namespace CalamityMod.World if (Main.tile[x, y].Get().LiquidType == LiquidID.Lava) WorldUtils.Gen(new Point(x, y), new Shapes.Rectangle(5, 5), new Actions.SetLiquid(LiquidID.Lava, 0)); - if (WorldGen.genRand.NextBool(5) && y < startPosY - 100) + if (WorldGen.genRand.NextBool(5) && y < startY - 100) { WorldUtils.Gen(new Point(x, y), new Shapes.Circle(WorldGen.genRand.Next(5, 7)), Actions.Chain(new GenAction[] { @@ -322,9 +337,9 @@ namespace CalamityMod.World } // Place layer of sand on valid runestone blocks. - for (int X = startPosX - biomeSize; X < startPosX + biomeSize; X += 1) + for (int X = startX - biomeSize; X < startX + biomeSize; X += 1) { - for (int Y = startPosY - 100; Y <= startPosY + 100; Y++) + for (int Y = startY - 100; Y <= startY + 100; Y++) { bool canPlaceSand = Main.tile[X, Y].TileType == ModContent.TileType() && @@ -352,9 +367,9 @@ namespace CalamityMod.World } // Slope tiles and Soil Spawn - for (int X = startPosX - biomeSize; X < startPosX + biomeSize; X += 1) + for (int X = startX - biomeSize; X < startX + biomeSize; X += 1) { - for (int Y = startPosY - 300; Y <= startPosY + 200; Y++) + for (int Y = startY - 300; Y <= startY + 200; Y++) { Tile.SmoothSlope(X, Y); @@ -387,13 +402,17 @@ namespace CalamityMod.World // Sides of the sunken sea (radiant reefs) public static void PlaceRadiantReefs(int startPosX, int startPosY) { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.RadiantReefsX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.RadiantReefsY; + int cavePerlinSeed = WorldGen.genRand.Next(); int cavePerlinSeedWalls = WorldGen.genRand.Next(); - Point origin = new Point(startPosX, startPosY); + Point origin = new Point(startX, startY); Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); - float angle = MathHelper.Pi * 0.20f; + float angle = MathHelper.Pi * 0.15f; float otherAngle = MathHelper.PiOver2 - angle; int biomeSize = 280 + (Main.maxTilesX / 180); @@ -401,7 +420,7 @@ namespace CalamityMod.World float constant = actualSize * 2f / (float)Math.Sin(angle); float fociSpacing = actualSize * (float)Math.Sin(otherAngle) / (float)Math.Sin(angle); - int verticalRadius = (int)(constant / 20f); + int verticalRadius = (int)(constant / 50f); Vector2 fociOffset = Vector2.UnitY * fociSpacing; Vector2 topFoci = center - fociOffset; @@ -547,10 +566,17 @@ namespace CalamityMod.World // Middle of the sunken sea (polyp forest) public static void PlacePolypForest(int startPosX, int startPosY) { + + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.PolypForestX; + + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.PolypForestY; + + int cavePerlinSeed = WorldGen.genRand.Next(); int cavePerlinSeedWalls = WorldGen.genRand.Next(); - Point origin = new Point(startPosX, startPosY - 200); + Point origin = new Point(startX, startY - 200); Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); float angle = MathHelper.Pi * 0.15f; @@ -649,7 +675,7 @@ namespace CalamityMod.World { 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, false, Y > origin.Y)) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y < origin.Y)) { //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; @@ -674,9 +700,9 @@ namespace CalamityMod.World //place extra tiles for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 20; Y <= origin.Y + verticalRadius + 20; Y++) + 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, false, Y > origin.Y)) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y < origin.Y)) { bool canPlaceSand = false; @@ -699,7 +725,7 @@ namespace CalamityMod.World { for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 20; Y <= origin.Y + verticalRadius + 20; Y++) { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y > origin.Y)) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y < origin.Y)) { bool canPlaceGrass = false; @@ -779,10 +805,14 @@ namespace CalamityMod.World //bottom of the biome (gleaming burrows) public static void PlaceGleamingBurrows(int startPosX, int startPosY) { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.GleamingBurrowsX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.GleamingBurrowsY; + int cavePerlinSeed = WorldGen.genRand.Next(); int cavePerlinSeedWalls = WorldGen.genRand.Next(); - Point origin = new Point(startPosX, startPosY); + Point origin = new Point(startX, startY); Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); float angle = MathHelper.Pi * 0.15f; @@ -845,7 +875,7 @@ namespace CalamityMod.World if (percent > blurPercent) { - if (Y > origin.Y - 50) + if (Y > origin.Y - 15) { //place smaller navystone clumps infront of the basalt so the basalt isnt actually inside of the biome itself WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), ModContent.TileType(), true, 0f, 0f, true, true); @@ -1007,10 +1037,14 @@ namespace CalamityMod.World //Very bottom of the biome (Clam Den) public static void PlaceClamDen(int startPosX, int startPosY) { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.ClamDenX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.ClamDenY; + int cavePerlinSeed = WorldGen.genRand.Next(); int cavePerlinSeedWalls = WorldGen.genRand.Next(); - Point origin = new Point(startPosX, startPosY); + Point origin = new Point(startX, startY); Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); float angle = MathHelper.Pi * 0.70f; @@ -1177,38 +1211,46 @@ namespace CalamityMod.World //basalt biome underneath the sunken sea public static void PlaceBasaltGully(int startPosX, int startPosY) { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.BasaltGullyX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.BasaltGullyY; + int biomeSize = 250 + (Main.maxTilesX / 180); int XLeft = GenVars.UndergroundDesertLocation.Left + 40; int XRight = GenVars.UndergroundDesertLocation.Right - 70; //place blocks of basalt all the way down to hell, here it just places one block and wall so it doesnt hurt preformance - for (int X = startPosX - biomeSize - 60; X < startPosX + biomeSize + 60; X += 1) + for (int X = startX - biomeSize - 80; X < startX + biomeSize + 80; X += 1) { - //const int totalCuveDepth = -120; - //const int totalCuveDepth2 = 120; - int basaltbordernoise = Main.rand.Next(180, 185); - int basaltbordernoisetop = Main.rand.Next(645, 650); - const int totalCuveDepth = -220; - const int totalCuveDepth2 = 90; + int leftEdge = startX - biomeSize - 60; + int rightEdge = startX + biomeSize + 60; + int basaltbordernoise = Main.rand.Next(0, 4); + int basaltbordernoisetop = Main.rand.Next(0, 4); + const int totalCurveDepth = -320; + const int totalCurveDepthTop = 45; int curveDepth = (int)MathHelper.Lerp( - totalCuveDepth, + totalCurveDepth, 0f, - MathF.Sqrt(Utils.GetLerpValue(startPosX + biomeSize + 60, startPosX + biomeSize - 200, X, true))); + MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 60, startX + biomeSize - 200, X, true))); int curveDepth2 = (int)MathHelper.Lerp( - totalCuveDepth, + totalCurveDepth, 0f, - MathF.Sqrt(Utils.GetLerpValue(startPosX - biomeSize - 60, startPosX - biomeSize + 200, X, true))); + MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 60, startX - biomeSize + 200, X, true))); int curveDepthtop = (int)MathHelper.Lerp( - totalCuveDepth2, + totalCurveDepthTop, 0f, - MathF.Sqrt(Utils.GetLerpValue(startPosX + biomeSize + 60, startPosX + biomeSize - 200, X, true))); + MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 60, startX + biomeSize - 200, X, true))); int curveDepth2top = (int)MathHelper.Lerp( - totalCuveDepth2, + totalCurveDepthTop, 0f, - MathF.Sqrt(Utils.GetLerpValue(startPosX - biomeSize - 60, startPosX - biomeSize + 200, X, true))); + MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 60, startX - biomeSize + 200, X, true))); - for (int Y = startPosY - 650 + curveDepthtop + curveDepth2top; Y <= Main.maxTilesY - 185 + curveDepth + curveDepth2; Y++) + for (int Y = startY - (625 + basaltbordernoisetop) + curveDepthtop + curveDepth2top; Y <= Main.maxTilesY - (270 + basaltbordernoise) + curveDepth + curveDepth2; Y++) { + int leftIndent = Main.rand.Next(0, 12); + int rightIndent = Main.rand.Next(0, 12); + if (X < leftEdge + leftIndent || X > rightEdge - rightIndent) + continue; Main.tile[X, Y].ClearEverything(); WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); WorldGen.PlaceWall(X, Y, ModContent.WallType()); @@ -1216,9 +1258,9 @@ namespace CalamityMod.World } //place caverns and lava - for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X <= startPosX + biomeSize + (Main.maxTilesX / 25); X++) + for (int X = startX - biomeSize - (Main.maxTilesX / 25); X <= startX + biomeSize + (Main.maxTilesX / 25); X++) { - for (int Y = startPosY; Y <= Main.maxTilesY - 190; Y++) + for (int Y = startY; Y <= Main.maxTilesY - 190; Y++) { if (Main.tile[X, Y].TileType == ModContent.TileType()) { @@ -1240,9 +1282,9 @@ namespace CalamityMod.World } //place sand blocks - for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X < startPosX + biomeSize + (Main.maxTilesX / 25); X += 1) + for (int X = startX - biomeSize - (Main.maxTilesX / 25); X < startX + biomeSize + (Main.maxTilesX / 25); X += 1) { - for (int Y = startPosY; Y <= Main.maxTilesY - 210; Y++) + for (int Y = startY; Y <= Main.maxTilesY - 210; Y++) { bool canPlaceSand = false; @@ -1260,9 +1302,9 @@ namespace CalamityMod.World } //cleanup - for(int X = startPosX - biomeSize - (Main.maxTilesX / 25); X < startPosX + biomeSize + (Main.maxTilesX / 25); X += 1) + for(int X = startX - biomeSize - (Main.maxTilesX / 25); X < startX + biomeSize + (Main.maxTilesX / 25); X += 1) { - for (int Y = startPosY; Y <= Main.maxTilesY - 210; Y++) + for (int Y = startY; Y <= Main.maxTilesY - 210; Y++) { //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; @@ -1323,6 +1365,7 @@ namespace CalamityMod.World //place all the ambient tiles in the sunken sea public static void PlaceSunkenSeaAmbience() { + bool shipPlaced = false; //first clean up unnecessary chunks of tiles CleanOutSmallClumps(); @@ -1332,7 +1375,7 @@ namespace CalamityMod.World for (int Y = 20; Y <= Main.maxTilesY - 20; Y++) { //place coral blobs in the radiant reefs - if (WorldGen.genRand.NextBool(800) && ((Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile) || + if (WorldGen.genRand.NextBool(400) && ((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(), @@ -1354,7 +1397,7 @@ namespace CalamityMod.World if (Main.tile[X, Y].TileType == ModContent.TileType()) { //Driftwood Ambiance - if (WorldGen.genRand.NextBool(70)) + if (WorldGen.genRand.NextBool(50)) { ushort[] DriftwoodPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; @@ -1364,7 +1407,7 @@ namespace CalamityMod.World if (Main.tile[X, Y].TileType == ModContent.TileType()) { //Driftwood Ambiance - if (WorldGen.genRand.NextBool(100)) + if (WorldGen.genRand.NextBool(75)) { ushort[] DriftwoodPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; @@ -1447,6 +1490,19 @@ namespace CalamityMod.World } if (Main.tile[X, Y].TileType == ModContent.TileType()) { + int RandStyleTable() => WorldGen.genRand.Next(3); + int styletable = RandStyleTable(); + + if (WorldGen.genRand.NextBool(5) && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.PlaceTile(X + 2, Y, ModContent.TileType(), true, false, -1, styletable); + } + + if (WorldGen.genRand.NextBool(5) && !Main.tile[X - 1, Y].HasTile) + { + WorldGen.PlaceTile(X - 2, Y, ModContent.TileType(), true, false, -1, styletable); + } + //stalactites if (WorldGen.genRand.NextBool(10)) { @@ -1510,6 +1566,7 @@ namespace CalamityMod.World ushort[] BranchCorals = new ushort[] { (ushort)ModContent.TileType() }; WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BranchCorals), true, 0, 0, style); } + } if (Main.tile[X, Y].TileType == ModContent.TileType()) { @@ -1583,6 +1640,11 @@ namespace CalamityMod.World WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(DriftwoodPiles)); } + if (!shipPlaced) + { + if (WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), mute: true)) + shipPlaced = true; + } } //radiant reefs ambient tiles @@ -1654,10 +1716,18 @@ namespace CalamityMod.World CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); } + if (Main.tile[X, Y].TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile && !Main.tile[X, Y + 2].HasTile) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); + } + //grow depth vines on navystone if (Main.tile[X, Y].TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile && !Main.tile[X, Y + 2].HasTile) { - // 18APR2025: Ozzatron: removed guaranteed RNG check here, since it was intended to be guaranteed WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); } if (Main.tile[X, Y].TileType == ModContent.TileType()) @@ -1668,22 +1738,18 @@ namespace CalamityMod.World //wall corals if (Main.tile[X, Y].TileType == ModContent.TileType()) { + + int RandStyleWall() => WorldGen.genRand.Next(4); + int stylewall = RandStyleWall(); + if (WorldGen.genRand.NextBool(5) && !Main.tile[X + 1, Y].HasTile) { - ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - WorldGen.PlaceTile(X + 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0); + WorldGen.PlaceTile(X + 2, Y, ModContent.TileType(), true, false, -1, stylewall); } if (WorldGen.genRand.NextBool(5) && !Main.tile[X - 1, Y].HasTile) { - ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - WorldGen.PlaceTile(X - 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0); + WorldGen.PlaceTile(X - 2, Y, ModContent.TileType(), true, false, -1, stylewall); } } // Pearl Autism