diff --git a/Backgrounds/SunkenSeaBG0.png b/Backgrounds/SunkenSeaBG0.png index 24766776c4..da6865c742 100644 Binary files a/Backgrounds/SunkenSeaBG0.png and b/Backgrounds/SunkenSeaBG0.png differ diff --git a/Backgrounds/SunkenSeaBG1.png b/Backgrounds/SunkenSeaBG1.png index f04de62d09..a25e598113 100644 Binary files a/Backgrounds/SunkenSeaBG1.png and b/Backgrounds/SunkenSeaBG1.png differ diff --git a/Backgrounds/SunkenSeaBG2.png b/Backgrounds/SunkenSeaBG2.png index dedfad6c44..a3cd31f4ab 100644 Binary files a/Backgrounds/SunkenSeaBG2.png and b/Backgrounds/SunkenSeaBG2.png differ diff --git a/Tiles/Abyss/AbyssGravel.cs b/Tiles/Abyss/AbyssGravel.cs index 23ed514fdf..b47504e4d1 100644 --- a/Tiles/Abyss/AbyssGravel.cs +++ b/Tiles/Abyss/AbyssGravel.cs @@ -9,7 +9,11 @@ namespace CalamityMod.Tiles.Abyss { public class AbyssGravel : ModTile { + int subsheetHeight = 270; + int subsheetWidth = 288; + public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3); + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -37,6 +41,12 @@ namespace CalamityMod.Tiles.Abyss num = fail ? 1 : 3; } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = i % 1 * subsheetWidth; //the 1 should be 2, but it looks weird right now, should be looked into later + frameYOffset = j % 1 * subsheetHeight; + } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { TileFraming.CustomMergeFrame(i, j, Type, TileID.Dirt); diff --git a/Tiles/Abyss/AbyssGravel.png b/Tiles/Abyss/AbyssGravel.png index c51a8c09ea..d92e9b7831 100644 Binary files a/Tiles/Abyss/AbyssGravel.png and b/Tiles/Abyss/AbyssGravel.png differ diff --git a/Utilities/WorldgenUtils.cs b/Utilities/WorldgenUtils.cs index e5ea6c2ca1..aa88bc0cba 100644 --- a/Utilities/WorldgenUtils.cs +++ b/Utilities/WorldgenUtils.cs @@ -1,6 +1,10 @@ -using System.Linq; -using Terraria; +using Terraria; using Terraria.ID; +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Linq; namespace CalamityMod { @@ -69,4 +73,111 @@ namespace CalamityMod Liquid.worldGenTilesIgnoreWater(false); } } + + //tile runner, probably useful for caves and probably other useful stuff? + public class TileRunner + { + public Vector2 pos; + public Vector2 speed; + public Point16 hRange; + public Point16 vRange; + public double strength; + public double str; + public int steps; + public int stepsLeft; + public ushort type; + public bool addTile; + public bool overRide; + + public TileRunner(Vector2 pos, Vector2 speed, Point16 hRange, Point16 vRange, double strength, int steps, ushort type, bool addTile, bool overRide) + { + this.pos = pos; + if (speed.X == 0 && speed.Y == 0) + { + this.speed = new Vector2(WorldGen.genRand.Next(hRange.X, hRange.Y + 1) * 0.1f, WorldGen.genRand.Next(vRange.X, vRange.Y + 1) * 0.1f); + } + else + { + this.speed = speed; + } + this.hRange = hRange; + this.vRange = vRange; + this.strength = strength; + str = strength; + this.steps = steps; + stepsLeft = steps; + this.type = type; + this.addTile = addTile; + this.overRide = overRide; + } + + public void Start() + { + while (str > 0 && stepsLeft > 0) + { + str = strength * (double)stepsLeft / steps; + + int a = (int)Math.Max(pos.X - str * 0.5, 1); + int b = (int)Math.Min(pos.X + str * 0.5, Main.maxTilesX - 1); + int c = (int)Math.Max(pos.Y - str * 0.5, 1); + int d = (int)Math.Min(pos.Y + str * 0.5, Main.maxTilesY - 1); + + for (int i = a; i < b; i++) + { + for (int j = c; j < d; j++) + { + if (Math.Abs(i - pos.X) + Math.Abs(j - pos.Y) >= strength * StrengthRange()) + { + continue; + } + + ChangeTile(Main.tile[i, j]); + } + } + + str += 50; + while (str > 50) + { + pos += speed; + stepsLeft--; + str -= 50; + speed.X += WorldGen.genRand.Next(hRange.X, hRange.Y + 1) * 0.05f; + speed.Y += WorldGen.genRand.Next(vRange.X, vRange.Y + 1) * 0.05f; + } + + speed = Vector2.Clamp(speed, new Vector2(-1, -1), new Vector2(1, 1)); + } + } + + public virtual void ChangeTile(Tile tile) + { + if (!addTile) + { + tile.HasTile = false; + } + else + { + tile.TileType = type; + } + } + + public virtual double StrengthRange() + { + return 0.5 + WorldGen.genRand.Next(-10, 11) * 0.0075; + } + } + + //probably might be useful to have for later, just places clumps of water + class WaterTileRunner : TileRunner + { + public WaterTileRunner(Vector2 pos, Vector2 speed, Point16 hRange, Point16 vRange, double strength, int steps, ushort type, bool addTile, bool overRide) : base(pos, speed, hRange, vRange, strength, steps, type, addTile, overRide) + { + } + public override void ChangeTile(Tile tile) + { + tile.HasTile = false; + tile.LiquidType = LiquidID.Water; + tile.LiquidAmount = 255; + } + } } diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index b24be19fd1..5535a192ef 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -1,4 +1,5 @@ using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Walls; using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Melee; @@ -29,20 +30,27 @@ namespace CalamityMod.World if (tile.LiquidType == LiquidID.Lava && careAboutLava) return true; if (tile.TileType == TileID.BlueDungeonBrick || - tile.TileType == TileID.GreenDungeonBrick || - tile.TileType == TileID.PinkDungeonBrick) + tile.TileType == TileID.GreenDungeonBrick || + tile.TileType == TileID.PinkDungeonBrick) { return true; } if (tile.TileType == TileID.LihzahrdBrick || - tile.WallType == WallID.LihzahrdBrickUnsafe) + tile.WallType == WallID.LihzahrdBrickUnsafe) { return true; } if (tile.TileType == TileID.Crimstone || - tile.WallType == WallID.CrimstoneUnsafe || - tile.TileType == TileID.Ebonstone || - tile.WallType == WallID.EbonstoneUnsafe) + tile.WallType == WallID.CrimstoneUnsafe || + tile.TileType == TileID.Ebonstone || + tile.WallType == WallID.EbonstoneUnsafe) + { + return true; + } + if (tile.TileType == ModContent.TileType() || + tile.TileType == ModContent.TileType() || + tile.WallType == ModContent.WallType() || + tile.WallType == ModContent.WallType()) { return true; } @@ -381,6 +389,9 @@ namespace CalamityMod.World placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(schematic.GetLength(0), schematic.GetLength(1)); int xCheckArea = 25; + /* + //Disabled this specifically for the sunken sea lab, not sure if it's even needed since the lab now always places based on where the sunken sea is + //this seems to work fine, but i dont want to delete it just in case bool shouldAvoidArea = false; float totalTiles = (schematicSize.X + xCheckArea * 2) * schematicSize.Y; @@ -394,7 +405,8 @@ namespace CalamityMod.World } } tries++; - if (!shouldAvoidArea && structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) + */ + if (/*!shouldAvoidArea &&*/ structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) break; } while (tries < 50000); diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index 31d40e942a..1e7b4c7882 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -7,6 +7,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.WorldBuilding; +using Terraria.DataStructures; namespace CalamityMod.World { @@ -246,7 +247,6 @@ namespace CalamityMod.World if (num10 > 4.5f) //Adjust num10 for all cases if you want different tile frequencies; higher is less frequent, lower is more frequent { tile.ClearEverything(); - //tile.WallType = (ushort)ModContent.WallType(); tile.LiquidAmount = 192; if (num4 % 5 == 2) { @@ -303,41 +303,6 @@ namespace CalamityMod.World } } - //seperate loop for biome polish and stuff - for (int i = -20; i < totalWidth + 20; i++) - { - for (int j = start.X + 50; j < Main.maxTilesY - 200; j++) - { - int x = i + start.X; - int y = j + start.Y; - - /* - //randomly place navystone chunks on top of exposed sand - if (WorldGen.genRand.Next(50) == 0 && tile.HasTile && tile.TileType == ModContent.TileType() && !tileAbove.HasTile) - { - //todo: change this to be more natural and not a circle, maybe use WorldGen.TileRunner? - BasicCircle(x, y, WorldGen.genRand.Next(3, 12), ModContent.TileType()); - } - */ - - //randomly kill walls so that the background can show through in some places - if (WorldGen.genRand.Next(50) == 0) - { - //TODO: continue this tomorrow - - int radius = (int)(((float)WorldGen.genRand.Next(8, 20))); - float outerRadius = WorldGen.genRand.Next(40, 56) * 0.01f; - ShapeData holeShape = new ShapeData(); - WorldUtils.Gen(new Point(x, y), new Shapes.Circle((int)((float)radius * (outerRadius * 0.3f))), Actions.Chain(new GenAction[] //Smallest is 1 - { - new Modifiers.Blotches(2, 0.3).Output(holeShape), - new Actions.ClearWall(true), //Clear center - new Actions.SetLiquid(0, 255) - })); - } - } - } - //final cleanup loop for (int i = -20; i < totalWidth + 20; i++) { @@ -347,6 +312,10 @@ namespace CalamityMod.World int y = j + start.Y; Tile tile = Main.tile[x, y]; + Tile tileUp = Main.tile[x, y - 1]; + Tile tileDown = Main.tile[x, y + 1]; + Tile tileLeft = Main.tile[x - 1, y]; + Tile tileRight = Main.tile[x + 1, y]; //lava BEGONE if (tile.WallType == ModContent.WallType() || tile.WallType == ModContent.WallType()) @@ -363,6 +332,30 @@ namespace CalamityMod.World WorldGen.KillTile(x, y); } } + + //place extra caves throughout the biome for variance + if (WorldGen.genRand.Next(1000) == 0 && tile != null && tile.HasTile && + (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType())) + { + TileRunner runner = new TileRunner(new Vector2(x, y), new Vector2(0, 5), new Point16(-35, 35), + new Point16(-35, 35), 15f, Main.rand.Next(25, 50), 0, false, true); + runner.Start(); + } + + //kill any random floating tiles + if ((tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) && + !tileUp.HasTile && !tileDown.HasTile && !tileLeft.HasTile && !tileRight.HasTile) + { + WorldGen.KillTile(x, y); + } + + //kill any random clumps of navystone without eutrophic sand around them + if (tile.TileType == ModContent.TileType() && tileUp.TileType != ModContent.TileType() && + tileDown.TileType != ModContent.TileType() && tileLeft.TileType != ModContent.TileType() && + tileRight.TileType != ModContent.TileType()) + { + WorldGen.KillTile(x, y); + } } } } @@ -626,11 +619,11 @@ namespace CalamityMod.World { PlaceTit(num5, num6 + 1, (ushort)ModContent.TileType()); } - if (WorldGen.genRand.Next(6) == 0) + if (WorldGen.genRand.Next(7) == 0) { WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); } - if (WorldGen.genRand.Next(5) == 0) + if (WorldGen.genRand.Next(10) == 0) { WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); }