ambient tiles (yay)

This commit is contained in:
Mortis3 committed 2023-11-09 17:28:09 -05:00
1 parent f879c9e09d
commit 2f0d0b3b28
10 files changed
+249 -30

No files matched your search

+8 -19
View File
@@ -116,11 +116,14 @@ namespace CalamityMod.Systems
}));
}
// Sunken sea
int SunkenSeaIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Larva"));
if (SunkenSeaIndex != -1)
// All further tasks occur after vanilla worldgen is completed
int FinalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup"));
if (FinalIndex != -1)
{
tasks.Insert(SunkenSeaIndex + 1, new PassLegacy("Sunken Sea", (progress, config) =>
int currentFinalIndex = FinalIndex;
// sunken sea
tasks.Insert(++currentFinalIndex, new PassLegacy("Sunken Sea", (progress, config) =>
{
progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.SunkenSea").Value;
@@ -133,21 +136,6 @@ namespace CalamityMod.Systems
SunkenSea.PlaceBasaltBiome(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4));
SunkenSea.PlaceGleamingBurrows(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4));
SunkenSea.PlaceSunkenSeaAmbience();
}));
}
// All further tasks occur after vanilla worldgen is completed
int FinalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup"));
if (FinalIndex != -1)
{
int currentFinalIndex = FinalIndex;
// sunken sea basalt lava cleanup (because vanilla for some reason places water in it)
tasks.Insert(++currentFinalIndex, new PassLegacy("Sunken Sea Cleanup", (progress, config) =>
{
int sunkenSeaX = (GenVars.UndergroundDesertLocation.Left + GenVars.UndergroundDesertLocation.Right) / 2;
int sunkenSeaY = Main.maxTilesY / 2;
SunkenSea.BasaltBiomeLavaCleanup(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4));
}));
@@ -287,6 +275,7 @@ namespace CalamityMod.Systems
{
progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.Abyss").Value;
Abyss.PlaceAbyss();
Abyss.AbyssCleanup();
}));
// Sulphurous Sea (Part 2, after Abyss)
+1 -1
View File
@@ -17,7 +17,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient
Main.tileSolid[Type] = false;
TileObjectData.newTile.Width = 3;
TileObjectData.newTile.Height = 4;
TileObjectData.newTile.Origin = new Point16(1, 3);
TileObjectData.newTile.Origin = new Point16(2, 3);
TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 };
TileObjectData.newTile.StyleWrapLimit = 36;
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
+1 -1
View File
@@ -17,7 +17,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient
Main.tileSolid[Type] = false;
TileObjectData.newTile.Width = 5;
TileObjectData.newTile.Height = 5;
TileObjectData.newTile.Origin = new Point16(3, 4);
TileObjectData.newTile.Origin = new Point16(3, 5);
TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16 };
TileObjectData.newTile.StyleWrapLimit = 36;
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
+2
View File
@@ -12,6 +12,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient
{
int subsheetHeight = 34;
int subsheetWidth = 108;
public override void SetStaticDefaults()
{
Main.tileFrameImportant[Type] = true;
@@ -34,6 +35,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient
{
num = fail ? 1 : 3;
}
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int xPos = i % 1;
+1 -1
View File
@@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient
{
public class WallCorals : ModTile
{
int subsheetHeight = 34;
int subsheetHeight = 54;
int subsheetWidth = 108;
public override void SetStaticDefaults()
+1 -1
View File
@@ -32,7 +32,7 @@ namespace CalamityMod.Tiles.SunkenSea
TileID.Sets.CanBeDugByShovel[Type] = true;
DustType = 108;
AddMapEntry(new Color(92, 145, 167));
AddMapEntry(new Color(192, 235, 243));
TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out tileAdjacency);
TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out secondTileAdjacency);
+1 -1
View File
@@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.SunkenSea
TileID.Sets.CanBeDugByShovel[Type] = true;
DustType = 108;
AddMapEntry(new Color(67, 107, 143));
AddMapEntry(new Color(92, 145, 167));
TileFraming.SetUpUniversalMerge(Type, ModContent.TileType<EutrophicSand>(), out tileAdjacency);
TileFraming.SetUpUniversalMerge(Type, ModContent.TileType<Navystone>(), out secondTileAdjacency);
+1 -1
View File
@@ -28,7 +28,7 @@ namespace CalamityMod.Tiles.SunkenSea
Main.tileShine2[Type] = true;
DustType = 147;
AddMapEntry(new Color(210, 124, 45));
AddMapEntry(new Color(244, 193, 181));
TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out tileAdjacency);
TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out secondTileAdjacency);
+68
View File
@@ -1181,5 +1181,73 @@ namespace CalamityMod.World
}
AbleToUnlockChests = false; //reseting the variable in case players generate multiple worlds to prevent already unlocked chests from spawning
}
//method to clean up small clumps of tiles
public static void AbyssCleanup()
{
List<ushort> blockTileTypes = new()
{
(ushort)ModContent.TileType<SulphurousShale>(),
(ushort)ModContent.TileType<AbyssGravel>(),
(ushort)ModContent.TileType<PyreMantle>(),
(ushort)ModContent.TileType<Voidstone>(),
};
void getAttachedPoints(int x, int y, List<Point> points)
{
Tile t = CalamityUtils.ParanoidTileRetrieval(x, y);
Point p = new(x, y);
if (!blockTileTypes.Contains(t.TileType) || !t.HasTile || points.Count > 75 || points.Contains(p))
{
return;
}
points.Add(p);
getAttachedPoints(x + 1, y, points);
getAttachedPoints(x - 1, y, points);
getAttachedPoints(x, y + 1, points);
getAttachedPoints(x, y - 1, points);
}
for (int x = 20; x < Main.maxTilesX - 20; x++)
{
for (int y = 20; y < Main.maxTilesY - 20; y++)
{
List<Point> chunkPoints = new();
getAttachedPoints(x, y, chunkPoints);
int cutoffLimit = 75;
if (chunkPoints.Count >= 1 && chunkPoints.Count < cutoffLimit)
{
foreach (Point p in chunkPoints)
{
WorldUtils.Gen(p, new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[]
{
new Actions.ClearTile(true),
new Actions.SetLiquid()
}));
}
}
Tile tile = Main.tile[x, y];
if (blockTileTypes.Contains(tile.TileType))
{
//clean tiles that are sticking out (aka tiles only attached to one tile on one side)
bool OnlyRight = !Main.tile[x, y - 1].HasTile && !Main.tile[x, y + 1].HasTile && !Main.tile[x - 1, y].HasTile;
bool OnlyLeft = !Main.tile[x, y - 1].HasTile && !Main.tile[x, y + 1].HasTile && !Main.tile[x + 1, y].HasTile;
bool OnlyDown = !Main.tile[x, y - 1].HasTile && !Main.tile[x - 1, y].HasTile && !Main.tile[x + 1, y].HasTile;
bool OnlyUp = !Main.tile[x, y + 1].HasTile && !Main.tile[x - 1, y].HasTile && !Main.tile[x + 1, y].HasTile;
if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp)
{
WorldGen.KillTile(x, y);
}
}
}
}
}
}
}
+165 -5
View File
@@ -578,12 +578,12 @@ namespace CalamityMod.World
if (CheckInEllipse(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true))
{
//place geodes
if (WorldGen.genRand.NextBool(400) && Main.tile[X, Y].TileType == ModContent.TileType<Navystone>() &&
if (WorldGen.genRand.NextBool(600) && Main.tile[X, Y].TileType == ModContent.TileType<Navystone>() &&
Main.tile[X, Y - 1].HasTile && Main.tile[X, Y + 1].HasTile && Main.tile[X - 1, Y].HasTile && Main.tile[X + 1, Y].HasTile)
{
if (EnoughTilesInArea(X, Y, 7, 7, 35, true))
{
PlaceGeode(X, Y, WorldGen.genRand.Next(5, 10));
PlaceGeode(X, Y, WorldGen.genRand.Next(10, 17));
}
}
@@ -809,11 +809,171 @@ namespace CalamityMod.World
}
}
//TODO: this will be for placing all the ambient tiles, does nothing right now
//place all the ambient tiles in the sunken sea
public static void PlaceSunkenSeaAmbience()
{
//first clean up unnecessary chunks of tiles
CleanOutSmallClumps();
for (int X = 20; X <= Main.maxTilesX - 20; X++)
{
for (int Y = 20; Y <= Main.maxTilesY - 20; Y++)
{
//gleaming burrows ambient tiles
if (Main.tile[X, Y].TileType == ModContent.TileType<HardenedEutrophicSand>())
{
//brain coral
if (WorldGen.genRand.NextBool(10))
{
WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType<BrainCoral>());
}
//small brain coral
if (WorldGen.genRand.NextBool(5))
{
WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType<SmallBrainCoral>());
}
//tube coral
if (WorldGen.genRand.NextBool(12))
{
WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType<TubeCoral>());
}
//small tube coral
if (WorldGen.genRand.NextBool(8))
{
WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType<SmallTubeCoral>());
}
//giant navystone piles
if (WorldGen.genRand.NextBool(15))
{
ushort[] GiantPiles = new ushort[] { (ushort)ModContent.TileType<GiantNavystone1>(), (ushort)ModContent.TileType<GiantNavystone2>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(GiantPiles));
}
//small navystone piles
if (WorldGen.genRand.NextBool(10))
{
ushort[] Piles = new ushort[] { (ushort)ModContent.TileType<NavystonePile1>(),
(ushort)ModContent.TileType<NavystonePile2>(), (ushort)ModContent.TileType<NavystonePile3>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(Piles));
}
}
if (Main.tile[X, Y].TileType == ModContent.TileType<Navystone>())
{
//stalactites
if (WorldGen.genRand.NextBool(10))
{
ushort[] Stalactites = new ushort[] { (ushort)ModContent.TileType<SunkenStalactite1>(),
(ushort)ModContent.TileType<SunkenStalactite2>(), (ushort)ModContent.TileType<SunkenStalactite3>() };
WorldGen.PlaceObject(X, Y + 2, WorldGen.genRand.Next(Stalactites));
}
//small stalactites
if (WorldGen.genRand.NextBool(8))
{
WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType<SunkenStalactitesSmall>(), true, false, -1, 0);
}
//stalagmites
if (WorldGen.genRand.NextBool(12))
{
ushort[] Stalagmites = new ushort[] { (ushort)ModContent.TileType<SunkenStalagmite1>(),
(ushort)ModContent.TileType<SunkenStalagmite2>(), (ushort)ModContent.TileType<SunkenStalagmite3>() };
WorldGen.PlaceObject(X, Y - 2, WorldGen.genRand.Next(Stalagmites));
}
//small stalagmites
if (WorldGen.genRand.NextBool(10))
{
WorldGen.PlaceTile(X, Y - 1, (ushort)ModContent.TileType<SunkenStalagmitesSmall>(), true, false, -1, 0);
}
//giant navystone piles
if (WorldGen.genRand.NextBool())
{
ushort[] GiantPiles = new ushort[] { (ushort)ModContent.TileType<GiantNavystone1>(), (ushort)ModContent.TileType<GiantNavystone2>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(GiantPiles));
}
//small navystone piles
if (WorldGen.genRand.NextBool())
{
ushort[] Piles = new ushort[] { (ushort)ModContent.TileType<NavystonePile1>(),
(ushort)ModContent.TileType<NavystonePile2>(), (ushort)ModContent.TileType<NavystonePile3>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(Piles));
}
}
//radiant reefs ambient tiles
if (Main.tile[X, Y].TileType == ModContent.TileType<EutrophicSand>())
{
//multi-colored corals
if (WorldGen.genRand.NextBool(3))
{
ushort[] ColoredCorals = new ushort[] { (ushort)ModContent.TileType<CoralPileGiant>(),
(ushort)ModContent.TileType<CoralPileLarge>(), (ushort)ModContent.TileType<MediumCoral2>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(ColoredCorals));
}
//blue coral trees
if (WorldGen.genRand.NextBool(6))
{
ushort[] BlueCorals = new ushort[] { (ushort)ModContent.TileType<MediumCoral3>(), (ushort)ModContent.TileType<BlueCoralTree>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BlueCorals));
}
//brown coral trees
if (WorldGen.genRand.NextBool(6))
{
ushort[] BrownCorals = new ushort[] { (ushort)ModContent.TileType<BrownCoral1>(), (ushort)ModContent.TileType<BrownCoral2>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BrownCorals));
}
//fan coral
if (WorldGen.genRand.NextBool(10))
{
WorldGen.PlaceObject(X, Y - 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>() };
WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(MiscCorals));
}
}
/*
//wall corals
if (Main.tile[X, Y].TileType == ModContent.TileType<Shellstone>())
{
if (WorldGen.genRand.NextBool(8) && !Main.tile[X - 1, Y].HasTile)
{
ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType<TableCoral>(), (ushort)ModContent.TileType<WallCorals>() };
WorldGen.PlaceTile(X - 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0);
}
if (WorldGen.genRand.NextBool(8) && !Main.tile[X + 1, Y].HasTile)
{
ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType<TableCoral>(), (ushort)ModContent.TileType<WallCorals>() };
WorldGen.PlaceTile(X + 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0);
}
}
*/
}
}
}
public static void PlaceGeode(int X, int Y, int radius)
@@ -836,7 +996,7 @@ namespace CalamityMod.World
}));
//second circle of prisms
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 3), Actions.Chain(new GenAction[]
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 4), Actions.Chain(new GenAction[]
{
blotchMod.Output(circle2)
}));
@@ -847,7 +1007,7 @@ namespace CalamityMod.World
}));
//clear out the middle of the circle
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 6), Actions.Chain(new GenAction[]
WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 9), Actions.Chain(new GenAction[]
{
blotchMod.Output(circle3)
}));