Sunken Kelp is real now, wall coral hell (still wip) Gil Herb Vines. More sunken sea worldgen + you can now move stuff.

This commit is contained in:
Heart-Plus-Up committed 2025-08-30 14:39:52 -07:00
1 parent eb973d7b0a
commit 889d5d5fce
31 files changed
+594 -255

No files matched your search

@@ -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<Tiles.SunkenSea.Ambient.TableCoralLeft>());
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

+2 -1
View File
@@ -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<DepthVines>();
int tileType = ModContent.TileType<SunkenKelp>();
// Assure the kelp still exists, if it's gone, clear the tile
if ((TileX != 0 || TileY != 0) && t.TileType != tileType)
+3 -1
View File
@@ -93,6 +93,8 @@ namespace CalamityMod.Systems
(ushort)ModContent.TileType<PhoviamareHalm>(),
(ushort)ModContent.TileType<SmallCorals>(),
(ushort)ModContent.TileType<LongScarletSeagrass>(),
(ushort)ModContent.TileType<SmallCorals>(),
(ushort)ModContent.TileType<SunkenKelp>(),
];
private static int[][] PlantValidGrounds;
@@ -121,7 +123,7 @@ namespace CalamityMod.Systems
PlantValidGrounds[ModContent.TileType<AbyssKelp>()] = new int[1] { ModContent.TileType<AbyssGravel>() };
PlantValidGrounds[ModContent.TileType<TenebrisRemnant>()] = new int[1] { ModContent.TileType<Voidstone>() };
PlantValidGrounds[ModContent.TileType<PhoviamareHalm>()] = new int[2] { ModContent.TileType<PyreMantle>(), ModContent.TileType<PyreMantleMolten>() };
PlantValidGrounds[ModContent.TileType<SmallCorals>()] = new int[1] { ModContent.TileType<EutrophicSand>() };
PlantValidGrounds[ModContent.TileType<SmallCorals>()] = new int[2] { ModContent.TileType<EutrophicSand>(), ModContent.TileType<HardenedEutrophicSand>() };
VineToGrass = new Dictionary<ushort, ushort>
{
+5
View File
@@ -32,6 +32,11 @@ namespace CalamityMod.Tiles
TileType<PyreMantle>(),
TileType<Navystone>(),
TileType<Shellstone>(),
TileType<EutrophicSand>(),
TileType<PolypSand>(),
TileType<VolcanicSand>(),
TileType<HardenedEutrophicSand>(),
TileType<Dunesand>(),
TileType<Limestone>(),
TileType<LimestoneCobble>(),
TileType<Voidstone>()
@@ -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";
}
}
+4 -26
View File
@@ -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<Shellstone>(), Type, 0);
//FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType<Shellstone>(), Type, 0);
}
}
public class WallCoral3Echo : WallCoral3
{
public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoral3";
public override void SetStaticDefaults()
{
base.SetStaticDefaults();
RegisterItemDrop(ModContent.ItemType<Shellstone>(), Type, 0);
//FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType<Shellstone>(), 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();
+79
View File
@@ -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<Limestone>() || 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<Limestone>())
{
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);
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

+41
View File
@@ -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;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

+7 -15
View File
@@ -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
{
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

+38
View File
@@ -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;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

+8 -43
View File
@@ -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;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

+38
View File
@@ -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;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

+10 -63
View File
@@ -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<SmallCorals>();
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<CoralPileGiant>(),
(ushort)ModContent.TileType<CoralPileLarge>(), (ushort)ModContent.TileType<MediumCoral2>() };
up.TileType = (ushort)ModContent.TileType<SunkenKelp>();
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<MediumCoral3>(), (ushort)ModContent.TileType<BlueCoralTree>() };
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<BrownCoral1>(), (ushort)ModContent.TileType<BrownCoral2>() };
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<FanCoral>());
}
//misc corals
if (WorldGen.genRand.NextBool())
{
ushort[] MiscCorals = new ushort[] { (ushort)ModContent.TileType<MediumCoral>(),
(ushort)ModContent.TileType<SmallWideCoral>(), (ushort)ModContent.TileType<SmallWideCoral2>() };
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);
}
}
}
+14
View File
@@ -85,6 +85,20 @@ namespace CalamityMod.Tiles.SunkenSea
NetMessage.SendObjectPlacement(-1, i, j - 1, (ushort)ModContent.TileType<SeaAnemone>(), 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<SunkenKelp>();
up.HasTile = true;
WorldGen.SquareTileFrame(i, j - 1, true);
if (Main.dedServ)
{
NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None);
}
}
}
}
}
+21
View File
@@ -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<GilHerb>();
Below.HasTile = true;
WorldGen.SquareTileFrame(i, j + 1, true);
if (Main.dedServ)
{
NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None);
}
}
}
}
}
}
+147
View File
@@ -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<EutrophicSand>(), (ushort)ModContent.TileType<HardenedEutrophicSand>() };
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<SunkenKelp>())
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<SunkenKelp>());
}
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<SunkenKelp>());
}
private static int GetChainLengthUpward(int i, int j)
{
int length = 1;
int y = j - 1;
int vineType = ModContent.TileType<SunkenKelp>();
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<SunkenKelp>();
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<SunkenKelp>())
SetFrame(i, bottomY, FrameBottom);
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 900 B

+162 -96
View File
@@ -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<Runestone>()));
}
});
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<Runestone>()));
WorldUtils.Gen(new Point(moundX, moundY), new ModShapes.All(mound), new Actions.PlaceWall((ushort)ModContent.WallType<RunestoneWall>()));
});
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<Runestone>()));
@@ -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<LiquidData>().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<Runestone>()),
}));
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<LiquidData>().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<Runestone>() &&
@@ -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<Navystone>(), 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<Basalt>());
WorldGen.PlaceWall(X, Y, ModContent.WallType<LargeBasaltWall>());
@@ -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<Basalt>())
{
@@ -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<EutrophicSand>() && !Main.tile[X, Y - 1].HasTile) ||
if (WorldGen.genRand.NextBool(400) && ((Main.tile[X, Y].TileType == ModContent.TileType<EutrophicSand>() && !Main.tile[X, Y - 1].HasTile) ||
(Main.tile[X, Y].TileType == ModContent.TileType<Shellstone>() && !Main.tile[X, Y + 1].HasTile)))
{
ushort[] Corals = new ushort[] { (ushort)ModContent.TileType<CyanCoral>(), (ushort)ModContent.TileType<LimeCoral>(),
@@ -1354,7 +1397,7 @@ namespace CalamityMod.World
if (Main.tile[X, Y].TileType == ModContent.TileType<Dunesand>())
{
//Driftwood Ambiance
if (WorldGen.genRand.NextBool(70))
if (WorldGen.genRand.NextBool(50))
{
ushort[] DriftwoodPiles = new ushort[] { (ushort)ModContent.TileType<DriftwoodAmbient1>(), (ushort)ModContent.TileType<DriftwoodAmbient2>(), (ushort)ModContent.TileType<DriftwoodAmbient3>(), (ushort)ModContent.TileType<DriftwoodAmbient4>(), (ushort)ModContent.TileType<DriftwoodAmbient5>(), (ushort)ModContent.TileType<DriftwoodAmbient6>() };
@@ -1364,7 +1407,7 @@ namespace CalamityMod.World
if (Main.tile[X, Y].TileType == ModContent.TileType<Runestone>())
{
//Driftwood Ambiance
if (WorldGen.genRand.NextBool(100))
if (WorldGen.genRand.NextBool(75))
{
ushort[] DriftwoodPiles = new ushort[] { (ushort)ModContent.TileType<DriftwoodAmbient1>(), (ushort)ModContent.TileType<DriftwoodAmbient2>(), (ushort)ModContent.TileType<DriftwoodAmbient3>(), (ushort)ModContent.TileType<DriftwoodAmbient4>(), (ushort)ModContent.TileType<DriftwoodAmbient5>(), (ushort)ModContent.TileType<DriftwoodAmbient6>() };
@@ -1447,6 +1490,19 @@ namespace CalamityMod.World
}
if (Main.tile[X, Y].TileType == ModContent.TileType<Navystone>())
{
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<TableCoralLeft>(), true, false, -1, styletable);
}
if (WorldGen.genRand.NextBool(5) && !Main.tile[X - 1, Y].HasTile)
{
WorldGen.PlaceTile(X - 2, Y, ModContent.TileType<TableCoral>(), true, false, -1, styletable);
}
//stalactites
if (WorldGen.genRand.NextBool(10))
{
@@ -1510,6 +1566,7 @@ namespace CalamityMod.World
ushort[] BranchCorals = new ushort[] { (ushort)ModContent.TileType<BranchCoral>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BranchCorals), true, 0, 0, style);
}
}
if (Main.tile[X, Y].TileType == ModContent.TileType<ScarletSeaGrassTile>())
{
@@ -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<SunkenShip>(), 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<RefractiveHangingCoral>());
}
if (Main.tile[X, Y].TileType == ModContent.TileType<Limestone>() && 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<GilHerb>());
}
if (Main.tile[X, Y].TileType == ModContent.TileType<GilHerb>())
{
CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType<GilHerb>());
}
//grow depth vines on navystone
if (Main.tile[X, Y].TileType == ModContent.TileType<Navystone>() && 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<DepthVines>());
}
if (Main.tile[X, Y].TileType == ModContent.TileType<DepthVines>())
@@ -1668,22 +1738,18 @@ namespace CalamityMod.World
//wall corals
if (Main.tile[X, Y].TileType == ModContent.TileType<Shellstone>())
{
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<WallCoral1>(), (ushort)ModContent.TileType<WallCoral2>(),
(ushort)ModContent.TileType<WallCoral3>(), (ushort)ModContent.TileType<WallCoral4>(), (ushort)ModContent.TileType<TableCoral>(),
(ushort)ModContent.TileType<TableCoral2>(), (ushort)ModContent.TileType<TableCoral3>() };
WorldGen.PlaceTile(X + 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0);
WorldGen.PlaceTile(X + 2, Y, ModContent.TileType<WallCoralLeft>(), true, false, -1, stylewall);
}
if (WorldGen.genRand.NextBool(5) && !Main.tile[X - 1, Y].HasTile)
{
ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType<WallCoral1>(), (ushort)ModContent.TileType<WallCoral2>(),
(ushort)ModContent.TileType<WallCoral3>(), (ushort)ModContent.TileType<WallCoral4>(), (ushort)ModContent.TileType<TableCoral>(),
(ushort)ModContent.TileType<TableCoral2>(), (ushort)ModContent.TileType<TableCoral3>() };
WorldGen.PlaceTile(X - 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0);
WorldGen.PlaceTile(X - 2, Y, ModContent.TileType<WallCoral>(), true, false, -1, stylewall);
}
}
// Pearl Autism