diff --git a/Backgrounds/FloralParadiseBGStyle.cs b/Backgrounds/FloralParadiseBGStyle.cs new file mode 100644 index 0000000000..ad87604643 --- /dev/null +++ b/Backgrounds/FloralParadiseBGStyle.cs @@ -0,0 +1,17 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Backgrounds +{ + public class FloralParadiseBGStyle : ModUgBgStyle + { + public override bool ChooseBgStyle() => Main.LocalPlayer.InFloralParadise(); + + public override void FillTextureArray(int[] textureSlots) + { + // Corresponds to underground jungle backgrounds. Something custom could probably be made, but for what it is it works sufficiently for the minibiome. + for (int i = 0; i <= 3; i++) + textureSlots[i] = i + 153; + } + } +} diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index cbd3774a58..3002acbc10 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1021,6 +1021,7 @@ namespace CalamityMod.CalPlayer public bool ZoneAbyssLayer2 => Player.InModBiome(ModContent.GetInstance()); public bool ZoneAbyssLayer3 => Player.InModBiome(ModContent.GetInstance()); public bool ZoneAbyssLayer4 => Player.InModBiome(ModContent.GetInstance()); + public bool ZoneFloralParadise = false; public bool abyssDeath = false; public int abyssBreathCD; public float caveDarkness = 0f; diff --git a/Projectiles/Environment/WaterAlgae.cs b/Projectiles/Environment/WaterAlgae.cs new file mode 100644 index 0000000000..7991100246 --- /dev/null +++ b/Projectiles/Environment/WaterAlgae.cs @@ -0,0 +1,65 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Environment +{ + public class WaterAlgae : ModProjectile + { + public ref float Direction => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Algae"); + Main.projFrames[projectile.type] = 3; + ProjectileID.Sets.CanDistortWater[projectile.type] = false; + } + + public override void SetDefaults() + { + projectile.width = 12; + projectile.height = 12; + projectile.ignoreWater = true; + projectile.timeLeft = 720; + projectile.penetrate = 1; + projectile.scale = Main.rand?.NextFloat(0.4f, 0.75f) ?? 1f; + projectile.hide = true; + } + + public override void AI() + { + projectile.Opacity = Utils.InverseLerp(0f, 120f, projectile.timeLeft, true) * Utils.InverseLerp(720f, 660f, projectile.timeLeft, true); + projectile.hide = projectile.Opacity < 0.2f; + if (projectile.localAI[0] == 0f) + { + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + projectile.localAI[0] = 1f; + } + + if (Collision.WetCollision(projectile.position, projectile.width, projectile.height)) + { + if (Direction == 0f) + Direction = projectile.identity % 2; + if (Collision.SolidCollision(projectile.Center + Vector2.UnitX * Direction * 100f, 1, 1)) + Direction *= -1f; + + projectile.velocity.X = MathHelper.Lerp(projectile.velocity.X, Direction * MathHelper.Lerp(0.3f, 0.7f, projectile.identity % 9f / 9f), 0.025f); + projectile.velocity.Y = MathHelper.Clamp(projectile.velocity.Y - 0.008f, -0.4f, 0.4f); + } + else + { + projectile.velocity.X *= 0.985f; + projectile.velocity.Y = MathHelper.Clamp(projectile.velocity.Y + 0.1f, -1f, 5f); + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + projectile.velocity.X *= 0.5f; + if (projectile.timeLeft > 210) + projectile.timeLeft = 210; + + return false; + } + } +} diff --git a/Projectiles/Environment/WaterAlgae.png b/Projectiles/Environment/WaterAlgae.png new file mode 100644 index 0000000000..e6a4ac5636 Binary files /dev/null and b/Projectiles/Environment/WaterAlgae.png differ diff --git a/Tiles/FloralParadise/BloodOrangePlant.cs b/Tiles/FloralParadise/BloodOrangePlant.cs new file mode 100644 index 0000000000..e88b26817d --- /dev/null +++ b/Tiles/FloralParadise/BloodOrangePlant.cs @@ -0,0 +1,42 @@ +using CalamityMod.Items.PermanentBoosters; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class BloodOrangePlant : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.addTile(Type); + + dustType = 6; + + AddMapEntry(new Color(250, 142, 4)); + + base.SetDefaults(); + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, 16, 16, ModContent.ItemType()); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/BloodOrangePlant.png b/Tiles/FloralParadise/BloodOrangePlant.png new file mode 100644 index 0000000000..c954393284 Binary files /dev/null and b/Tiles/FloralParadise/BloodOrangePlant.png differ diff --git a/Tiles/FloralParadise/FloralGrass.cs b/Tiles/FloralParadise/FloralGrass.cs new file mode 100644 index 0000000000..2a2fe5b328 --- /dev/null +++ b/Tiles/FloralParadise/FloralGrass.cs @@ -0,0 +1,114 @@ +using CalamityMod.Projectiles.Environment; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class FloralGrass : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + + TileID.Sets.Grass[Type] = true; + TileID.Sets.NeedsGrassFraming[Type] = true; + TileID.Sets.NeedsGrassFramingDirt[Type] = ModContent.TileType(); + TileID.Sets.Conversion.Grass[Type] = true; + + CalamityUtils.SetMerge(Type, TileID.Dirt); + CalamityUtils.SetMerge(Type, TileID.Grass); + CalamityUtils.SetMerge(Type, TileID.CorruptGrass); + CalamityUtils.SetMerge(Type, TileID.HallowedGrass); + CalamityUtils.SetMerge(Type, TileID.FleshGrass); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + + dustType = 39; + drop = ItemID.DirtBlock; + + AddMapEntry(new Color(31, 99, 31)); + } + + public override void NumDust(int i, int j, bool fail, ref int Type) + { + Type = fail ? 1 : 3; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + if (fail && !effectOnly) + Main.tile[i, j].type = (ushort)ModContent.TileType(); + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (WorldGen.genRand.NextBool(60) && !Main.gamePaused && CalamityUtils.ParanoidTileRetrieval(i, j - 1).liquid >= 200) + { + Vector2 algaeVelocity = -Vector2.UnitY.RotatedByRandom(0.91f) * Main.rand.NextFloat(0.85f, 1.6f); + Projectile.NewProjectile(new Vector2(i + 0.5f, j - 0.5f) * 16f, algaeVelocity, ModContent.ProjectileType(), 0, 0f); + } + } + + public override void RandomUpdate(int i, int j) + { + int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int nearbyVineCount = 0; + for (int x = i - 15; x <= i + 15; x++) + { + for (int y = j - 15; y <= j + 15; y++) + { + if (WorldGen.InWorld(x, y)) + { + if (CalamityUtils.ParanoidTileRetrieval(x, y).active() && + CalamityUtils.ParanoidTileRetrieval(x, y).type == (ushort)ModContent.TileType()) + { + nearbyVineCount++; + } + } + } + } + if (Main.tile[i, j + 1] != null && nearbyVineCount < 5) + { + if (!Main.tile[i, j + 1].active() && Main.tile[i, j + 1].type != (ushort)ModContent.TileType()) + { + if (Main.tile[i, j + 1].liquid == 255 && + !Main.tile[i, j + 1].lava()) + { + bool flag13 = false; + for (int y = num8; y > num8 - 10; y--) + { + if (Main.tile[i, y].bottomSlope()) + { + flag13 = false; + break; + } + if (Main.tile[i, y].active() && !Main.tile[i, y].bottomSlope()) + { + flag13 = true; + break; + } + } + if (flag13) + { + int num53 = i; + int num54 = j + 1; + Main.tile[num53, num54].type = (ushort)ModContent.TileType(); + Main.tile[num53, num54].active(true); + WorldGen.SquareTileFrame(num53, num54, true); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + } + } + Main.tile[i, j].slope(0); + Main.tile[i, j].halfBrick(false); + } + } + } + } + } +} diff --git a/Tiles/FloralParadise/FloralGrass.png b/Tiles/FloralParadise/FloralGrass.png new file mode 100644 index 0000000000..72c891cca1 Binary files /dev/null and b/Tiles/FloralParadise/FloralGrass.png differ diff --git a/Tiles/FloralParadise/FloralPlants.cs b/Tiles/FloralParadise/FloralPlants.cs new file mode 100644 index 0000000000..0e0be5b303 --- /dev/null +++ b/Tiles/FloralParadise/FloralPlants.cs @@ -0,0 +1,41 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class FloralPlants : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.addTile(Type); + + dustType = 2; + AddMapEntry(new Color(28, 216, 94)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (CalamityUtils.ParanoidTileRetrieval(i, j).liquid > 64) + WorldGen.KillTile(i, j); + } + } +} diff --git a/Tiles/FloralParadise/FloralPlants.png b/Tiles/FloralParadise/FloralPlants.png new file mode 100644 index 0000000000..5df9a4fed8 Binary files /dev/null and b/Tiles/FloralParadise/FloralPlants.png differ diff --git a/Tiles/FloralParadise/FloralStone.cs b/Tiles/FloralParadise/FloralStone.cs new file mode 100644 index 0000000000..dd90cf7ee0 --- /dev/null +++ b/Tiles/FloralParadise/FloralStone.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class FloralStone : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + TileID.Sets.Stone[Type] = true; + TileID.Sets.Conversion.Stone[Type] = true; + TileID.Sets.CanBeClearedDuringOreRunner[Type] = false; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithOres(Type); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + + dustType = 78; + // drop = ModContent.ItemType(); + + soundType = SoundID.Tink; + + AddMapEntry(new Color(26, 73, 31)); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFraming.CustomMergeFrame(i, j, Type, TileID.Dirt); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/FloralStone.png b/Tiles/FloralParadise/FloralStone.png new file mode 100644 index 0000000000..13f93e7709 Binary files /dev/null and b/Tiles/FloralParadise/FloralStone.png differ diff --git a/Tiles/FloralParadise/RichDirt.cs b/Tiles/FloralParadise/RichDirt.cs new file mode 100644 index 0000000000..519e3d8dac --- /dev/null +++ b/Tiles/FloralParadise/RichDirt.cs @@ -0,0 +1,60 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class RichDirt : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeAstralTiles(Type); + CalamityUtils.MergeWithOres(Type); + CalamityUtils.SetMerge(Type, TileID.Grass); + CalamityUtils.SetMerge(Type, TileID.CorruptGrass); + CalamityUtils.SetMerge(Type, TileID.HallowedGrass); + CalamityUtils.SetMerge(Type, TileID.FleshGrass); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + + dustType = 38; + // drop = ModContent.ItemType(); + + AddMapEntry(new Color(140, 81, 56)); + + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFraming.CustomMergeFrame(i, j, Type, TileID.Dirt); + return false; + } + + public override void RandomUpdate(int i, int j) + { + Tile up = Main.tile[i, j - 1]; + Tile down = Main.tile[i, j + 1]; + Tile left = Main.tile[i - 1, j]; + Tile right = Main.tile[i + 1, j]; + if (WorldGen.genRand.NextBool(3) && (up.type == ModContent.TileType() || + down.type == ModContent.TileType() || + left.type == ModContent.TileType() || + right.type == ModContent.TileType())) + { + WorldGen.SpreadGrass(i, j, Type, ModContent.TileType(), false); + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/RichDirt.png b/Tiles/FloralParadise/RichDirt.png new file mode 100644 index 0000000000..f3c3e67b3a Binary files /dev/null and b/Tiles/FloralParadise/RichDirt.png differ diff --git a/Tiles/FloralParadise/SmallVines.cs b/Tiles/FloralParadise/SmallVines.cs new file mode 100644 index 0000000000..0ce54459ea --- /dev/null +++ b/Tiles/FloralParadise/SmallVines.cs @@ -0,0 +1,94 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class SmallVines : ModTile + { + public override void SetDefaults() + { + Main.tileCut[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileNoFail[Type] = true; + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Vines"); + AddMapEntry(new Color(100, 151, 31), name); + soundType = SoundID.Grass; + dustType = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + if (WorldGen.genRand.NextBool(2) && Main.player[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].cordage) + Item.NewItem(new Vector2(i * 16 + 8f, j * 16 + 8f), ItemID.VineRope); + + if (Main.tile[i, j + 1] != null) + { + if (Main.tile[i, j + 1].active()) + { + if (Main.tile[i, j + 1].type == ModContent.TileType()) + { + WorldGen.KillTile(i, j + 1, false, false, false); + if (!Main.tile[i, j + 1].active() && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); + } + } + } + } + } + + public override void RandomUpdate(int i, int j) + { + if (Main.tile[i, j + 1] != null) + { + if (!Main.tile[i, j + 1].active() && Main.tile[i, j + 1].type != (ushort)ModContent.TileType()) + { + if (Main.tile[i, j + 1].liquid >= 128 && !Main.tile[i, j + 1].lava()) + { + bool flag13 = false; + for (int num52 = j; num52 > j - 10; j--) + { + if (Main.tile[i, num52].bottomSlope()) + { + flag13 = false; + break; + } + if (Main.tile[i, num52].active() && !Main.tile[i, num52].bottomSlope()) + { + flag13 = true; + break; + } + } + if (flag13) + { + int num53 = i; + int num54 = j + 1; + Main.tile[num53, num54].type = (ushort)ModContent.TileType(); + Main.tile[num53, num54].frameX = (short)(WorldGen.genRand.Next(8) * 18); + Main.tile[num53, num54].frameY = (short)(4 * 18); + Main.tile[num53, num54 - 1].frameX = (short)(WorldGen.genRand.Next(12) * 18); + Main.tile[num53, num54 - 1].frameY = (short)(WorldGen.genRand.Next(4) * 18); + Main.tile[num53, num54].active(true); + WorldGen.SquareTileFrame(num53, num54, true); + WorldGen.SquareTileFrame(num53, num54 - 1, true); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, num53, num54 - 1, 3, TileChangeType.None); + } + } + } + } + } + } + } +} diff --git a/Tiles/FloralParadise/SmallVines.png b/Tiles/FloralParadise/SmallVines.png new file mode 100644 index 0000000000..38aa9df661 Binary files /dev/null and b/Tiles/FloralParadise/SmallVines.png differ diff --git a/Tiles/FloralParadise/VigorousVines.cs b/Tiles/FloralParadise/VigorousVines.cs new file mode 100644 index 0000000000..68a69ce177 --- /dev/null +++ b/Tiles/FloralParadise/VigorousVines.cs @@ -0,0 +1,87 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class VigorousVines : ModTile + { + public override void SetDefaults() + { + Main.tileCut[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Vigorous Vines"); + AddMapEntry(new Color(145, 203, 102), name); + + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = Point16.Zero; + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.AnchorValidTiles = new[] { ModContent.TileType() }; + TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.RandomStyleRange = 2; + TileObjectData.addTile(Type); + + soundType = SoundID.Grass; + dustType = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); + if (tile.frameX % 36 != 0 || tile.frameY % 36 != 0) + { + WorldGen.KillTile(i - tile.frameX % 36 / 18, j - tile.frameY % 36 / 18); + + if (CalamityUtils.ParanoidTileRetrieval(i - tile.frameX % 36 / 18, j - tile.frameY % 36 / 18 - 1).type == Type) + WorldGen.KillTile(i - tile.frameX % 36 / 18, j - tile.frameY % 36 / 18 - 1); + return; + } + + else if (WorldGen.genRand.NextBool(2) && Main.player[Player.FindClosest(new Vector2(i, j) * 16f, 16, 16)].cordage) + { + Item.NewItem(new Vector2(i * 16 + 24f, j * 16 + 24f), ItemID.VineRope); + } + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + Tile t = Main.tile[i, j]; + int frameX = t.frameX; + int frameY = t.frameY; + Texture2D tex = Main.tileTexture[Type]; + Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset; + Color drawColor = Lighting.GetColor(i, j); + if (!t.halfBrick() && t.slope() == 0) + spriteBatch.Draw(tex, drawPosition, new Rectangle(frameX, frameY, 18, 18), drawColor, 0f, Vector2.Zero, 1f, 0, 0f); + else if (t.halfBrick()) + spriteBatch.Draw(tex, drawPosition + new Vector2(0f, 8f), new Rectangle(frameX, frameY, 18, 8), drawColor, 0f, Vector2.Zero, 1f, 0, 0f); + + return false; + } + + public override void RandomUpdate(int i, int j) + { + + } + } +} diff --git a/Tiles/FloralParadise/VigorousVines.png b/Tiles/FloralParadise/VigorousVines.png new file mode 100644 index 0000000000..0056a23af2 Binary files /dev/null and b/Tiles/FloralParadise/VigorousVines.png differ diff --git a/Tiles/Ores/PerennialOre.cs b/Tiles/Ores/PerennialOre.cs index 6ff54e7563..5bb15467c6 100644 --- a/Tiles/Ores/PerennialOre.cs +++ b/Tiles/Ores/PerennialOre.cs @@ -1,10 +1,10 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Tiles.FloralParadise; using System; namespace CalamityMod.Tiles.Ores @@ -25,6 +25,9 @@ namespace CalamityMod.Tiles.Ores Main.tileShine2[Type] = true; CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + CalamityUtils.SetMerge(Type, ModContent.TileType()); TileID.Sets.Ore[Type] = true; TileID.Sets.OreMergesWithMud[Type] = true; diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 3e46bc041b..39eadced64 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -294,6 +294,7 @@ namespace CalamityMod public static bool InCalamity(this Player player) => player.Calamity().ZoneCalamity; public static bool InSunkenSea(this Player player) => player.Calamity().ZoneSunkenSea; public static bool InSulphur(this Player player) => player.Calamity().ZoneSulphur; + public static bool InFloralParadise(this Player player) => player.Calamity().ZoneFloralParadise; public static bool InAstral(this Player player, int biome = 0) //1 is above ground, 2 is underground, 3 is desert { switch (biome) diff --git a/Waters/FloralParadiseWater.cs b/Waters/FloralParadiseWater.cs new file mode 100644 index 0000000000..3d1484d7b6 --- /dev/null +++ b/Waters/FloralParadiseWater.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class FloralParadiseWater : ModWaterStyle + { + public override bool ChooseWaterStyle() + { + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + return modPlayer.ZoneFloralParadise; + } + + public override int ChooseWaterfallStyle() + { + return mod.GetWaterfallStyleSlot("FloralParadiseWaterflow"); + } + + public override int GetSplashDust() + { + return 33; + } + + public override int GetDropletGore() + { + return 713; + } + + public override Color BiomeHairColor() + { + return Color.PaleTurquoise; + } + } +} diff --git a/Waters/FloralParadiseWater.png b/Waters/FloralParadiseWater.png new file mode 100644 index 0000000000..d8a0958b63 Binary files /dev/null and b/Waters/FloralParadiseWater.png differ diff --git a/Waters/FloralParadiseWaterWaterflow.cs b/Waters/FloralParadiseWaterWaterflow.cs new file mode 100644 index 0000000000..64a6ce4344 --- /dev/null +++ b/Waters/FloralParadiseWaterWaterflow.cs @@ -0,0 +1,9 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class FloralParadiseWaterflow : ModWaterfallStyle + { + + } +} diff --git a/Waters/FloralParadiseWater_Block.png b/Waters/FloralParadiseWater_Block.png new file mode 100644 index 0000000000..5fe701ea91 Binary files /dev/null and b/Waters/FloralParadiseWater_Block.png differ diff --git a/Waters/FloralParadiseWaterflow.png b/Waters/FloralParadiseWaterflow.png new file mode 100644 index 0000000000..aa0d689eb7 Binary files /dev/null and b/Waters/FloralParadiseWaterflow.png differ diff --git a/World/Minibiomes/FloralParadiseMinibiome.cs b/World/Minibiomes/FloralParadiseMinibiome.cs new file mode 100644 index 0000000000..bfbc36d153 --- /dev/null +++ b/World/Minibiomes/FloralParadiseMinibiome.cs @@ -0,0 +1,416 @@ +using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.Tiles.FloralParadise; +using CalamityMod.Tiles.SunkenSea; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.GameContent.Generation; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.World.Generation; + +namespace CalamityMod.World.Minibiomes +{ + public class FloralParadiseMinibiome + { + public const int MaxHorizontalDistanceFromWorldCenter = 1250; + + public const int MinSurfaceDepth = 250; + + public const int MaxSurfaceDepth = 550; + + public static void GenerateInstances() + { + float worldSize = Main.maxTilesX / 4200f; + int totalCaves = (int)(worldSize * 5f); + int[] blacklistedTiles = new int[] + { + TileID.Sand, + TileID.Sandstone, + TileID.HardenedSand, + TileID.DesertFossil, + TileID.SnowBlock, + TileID.IceBlock, + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + }; + + List existingCaves = new List(); + for (int i = 0; i < totalCaves; i++) + { + int x = Main.maxTilesX / 2 + WorldGen.genRand.Next(-MaxHorizontalDistanceFromWorldCenter, MaxHorizontalDistanceFromWorldCenter); + int y = (int)WorldGen.worldSurface + WorldGen.genRand.Next(MinSurfaceDepth, MaxSurfaceDepth); + int width = (int)(WorldGen.genRand.Next(80, 100) * worldSize); + int height = (int)(WorldGen.genRand.Next(70, 95) * worldSize); + Rectangle caveArea = Utils.CenteredRectangle(new Vector2(x, y), new Vector2(width, height)); + + // Try again if this selected location is near blacklisted tiles. + // This is done to prevent logical consistencies/intrusion on unrelated biomes. + bool needsToTryAgain = false; + for (int dx = -40; dx < 40; dx++) + { + for (int dy = -40; dy < 40; dy++) + { + if (!needsToTryAgain) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy); + needsToTryAgain = tile.active() && blacklistedTiles.Contains(tile.type); + } + else + break; + } + } + + if (!needsToTryAgain) + needsToTryAgain = existingCaves.Any(c => caveArea.Intersects(c)); + + if (needsToTryAgain) + { + i--; + continue; + } + + Place(new Vector2(x, y), width, height); + existingCaves.Add(caveArea); + } + } + + public static void Place(Vector2 placementCenter, int width, int height) + { + int seed = WorldGen.genRand.Next(); + bool[,] caveState = new bool[width, height]; + for (int i = 0; i < width; i++) + { + for (int j = 0; j < height; j++) + { + float noise = CalamityUtils.PerlinNoise2D(i / 180f, j / 180f, 3, seed) * 0.5f + 0.5f; + caveState[i, j] = noise >= 0.48f && noise < 0.64f; + if (WorldGen.genRand.NextBool(3)) + caveState[i, j] = WorldGen.genRand.NextBool(); + } + } + + // Repeatedly smoothen out caves with celluar automata. + for (int i = 0; i < 12; i++) + caveState = SimulateCelluarAutomata(caveState); + + // Reset tile states based on the above results. + ushort grassID = (ushort)ModContent.TileType(); + ushort dirtID = (ushort)ModContent.TileType(); + ushort stoneID = (ushort)ModContent.TileType(); + bool[,] grassDirtMap = new bool[width, height]; + for (int x = (int)placementCenter.X; x < (int)placementCenter.X + width; x++) + { + for (int y = (int)placementCenter.Y; y < (int)placementCenter.Y + height; y++) + { + // Don't attempt to change tile data if a tile is outside of the world for some reason. + if (!WorldGen.InWorld(x, y, 1)) + continue; + + int arrayRelativeX = x - (int)placementCenter.X; + int arrayRelativeY = y - (int)placementCenter.Y; + float distanceFromCenter = Vector2.Distance(new Vector2(arrayRelativeX / (float)width, arrayRelativeY / (float)height), Vector2.One * 0.5f) * 1.75f; + if (distanceFromCenter > 1f) + distanceFromCenter = 1f; + + float ditherChance = Utils.InverseLerp(0.97f, 0.72f, distanceFromCenter, true); + + Main.tile[x, y].wall = WallID.None; + if (WorldGen.genRand.NextFloat() < ditherChance) + { + if (!caveState[arrayRelativeX, arrayRelativeY] && distanceFromCenter < 0.7f) + Main.tile[x, y] = new Tile(); + else + { + bool useGrass = CountCellsAtPosition(caveState, arrayRelativeX, arrayRelativeY, false) >= 1; + grassDirtMap[arrayRelativeX, arrayRelativeY] = useGrass; + Main.tile[x, y] = new Tile(); + Main.tile[x, y].ResetToType(useGrass ? grassID : stoneID); + WorldGen.SquareTileFrame(x, y); + } + } + } + } + + // Perform secondary passes that overlay dirt behind grass. + for (int i = 0; i < 2; i++) + { + for (int x = (int)placementCenter.X; x < (int)placementCenter.X + width; x++) + { + for (int y = (int)placementCenter.Y; y < (int)placementCenter.Y + height; y++) + { + int arrayRelativeX = x - (int)placementCenter.X; + int arrayRelativeY = y - (int)placementCenter.Y; + bool nearbyGrassOrDirt = false; + if (arrayRelativeX - 1 >= 0 && grassDirtMap[arrayRelativeX - 1, arrayRelativeY]) + nearbyGrassOrDirt = true; + else if (arrayRelativeX + 1 < width && grassDirtMap[arrayRelativeX + 1, arrayRelativeY]) + nearbyGrassOrDirt = true; + else if (arrayRelativeY - 1 >= 0 && grassDirtMap[arrayRelativeX, arrayRelativeY - 1]) + nearbyGrassOrDirt = true; + else if (arrayRelativeY + 1 < height && grassDirtMap[arrayRelativeX, arrayRelativeY + 1]) + nearbyGrassOrDirt = true; + + bool canPerformPlacement = i == 0 || WorldGen.genRand.NextBool(); + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (canPerformPlacement && tile.active() && tile.type == stoneID && nearbyGrassOrDirt) + Main.tile[x, y].type = dirtID; + } + } + + // Reset the dirt/grass map for successive passes. + for (int x = (int)placementCenter.X; x < (int)placementCenter.X + width; x++) + { + for (int y = (int)placementCenter.Y; y < (int)placementCenter.Y + height; y++) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + int arrayRelativeX = x - (int)placementCenter.X; + int arrayRelativeY = y - (int)placementCenter.Y; + grassDirtMap[arrayRelativeX, arrayRelativeY] = tile.type == grassID || tile.type == dirtID; + } + } + } + + // Create walls. + for (int x = (int)placementCenter.X; x < (int)placementCenter.X + width; x++) + { + for (int y = (int)placementCenter.Y; y < (int)placementCenter.Y + height; y++) + { + float noise = CalamityUtils.PerlinNoise2D(x / 160f, y / 160f, 3, unchecked(seed - 13)) * 0.5f + 0.5f; + if (noise >= 0.42f && noise < 0.69f) + Main.tile[x, y].wall = WorldGen.genRand.NextBool(4) ? WallID.GrassUnsafe : WallID.FlowerUnsafe; + } + } + + // Place big vines. + int bigVineCount = WorldGen.genRand.Next(20, 30); + for (int i = 0; i < bigVineCount; i++) + { + int x = (int)placementCenter.X + WorldGen.genRand.Next(24, width - 24); + int y = (int)placementCenter.Y + WorldGen.genRand.Next(18, height - 18); + if (!GenerateVigorousVines(x, y, WorldGen.genRand.Next(3, 12))) + { + i--; + continue; + } + } + + // Place small vines. + int smallVineCount = WorldGen.genRand.Next(35, 50); + for (int i = 0; i < smallVineCount; i++) + { + int x = (int)placementCenter.X + WorldGen.genRand.Next(24, width - 24); + int y = (int)placementCenter.Y + WorldGen.genRand.Next(18, height - 18); + if (CalamityUtils.ParanoidTileRetrieval(x, y).active() || !WorldGen.SolidTile(x, y - 1)) + { + i--; + continue; + } + + int vineLength = WorldGen.genRand.Next(5, 12); + bool neeedsToTryAgain = false; + for (int dy = 0; dy < vineLength + 4; dy++) + { + if (CalamityUtils.ParanoidTileRetrieval(x, y + dy).active()) + { + neeedsToTryAgain = true; + break; + } + } + + if (neeedsToTryAgain) + { + i--; + continue; + } + + for (int dy = 0; dy < vineLength; dy++) + { + Main.tile[x, y + dy].type = (ushort)ModContent.TileType(); + if (dy == vineLength - 1) + { + Main.tile[x, y + dy].frameX = (short)(WorldGen.genRand.Next(8) * 18); + Main.tile[x, y + dy].frameY = 72; + } + else + { + Main.tile[x, y + dy].frameX = (short)(WorldGen.genRand.Next(12) * 18); + Main.tile[x, y + dy].frameY = (short)(WorldGen.genRand.Next(4) * 18); + } + Main.tile[x, y + dy].active(true); + WorldGen.SquareTileFrame(x, y, true); + } + } + + // Place small flowers everywhere. + int smallFlowerCount = WorldGen.genRand.Next(150, 200); + for (int i = 0; i < smallFlowerCount; i++) + { + int x = (int)placementCenter.X + WorldGen.genRand.Next(16, width - 16); + int y = (int)placementCenter.Y + WorldGen.genRand.Next(12, height - 12); + if (CalamityUtils.ParanoidTileRetrieval(x, y).active() || !WorldGen.SolidTile(x, y + 1)) + { + i--; + continue; + } + + Main.tile[x, y].type = (ushort)ModContent.TileType(); + Main.tile[x, y].frameX = (short)(Utils.SelectRandom(WorldGen.genRand, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44) * 18); + Main.tile[x, y].frameY = 0; + Main.tile[x, y].active(true); + } + + // Place ponds. + int pondCount = WorldGen.genRand.Next(3); + for (int i = 0; i < pondCount; i++) + { + int x = (int)placementCenter.X + WorldGen.genRand.Next(24, width - 24); + int y = (int)placementCenter.Y + WorldGen.genRand.Next(24, height - 24); + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tile.active() || tile.liquid > 0) + { + i--; + continue; + } + + // Go upward once an open area is found. This is where water will be created and then settled. + Point waterSpawnPoint = new Point(x, y); + for (int dy = 0; dy < 100; dy++) + { + if (CalamityUtils.ParanoidTileRetrieval(x, y - dy).active()) + { + waterSpawnPoint.Y -= dy - 1; + break; + } + } + + int increment = 0; + int waterCount = WorldGen.genRand.Next(180, 200); + RecursivelyFillAreaWithWater(x, y, waterCount, ref increment); + } + + // Place a blood orange. THIS IS FOR TESTING PURPOSES. + for (int i = 0; i < 1; i++) + { + int x = (int)placementCenter.X + WorldGen.genRand.Next(24, width - 24); + int y = (int)placementCenter.Y + WorldGen.genRand.Next(18, height - 18); + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (!WorldGen.SolidTile(x, y + 1) || !WorldGen.SolidTile(x + 1, y + 1) || tile.active() || tile.liquid > 0) + { + i--; + continue; + } + + for (int dx = 0; dx < 3; dx++) + { + for (int dy = 0; dy < 3; dy++) + { + Main.tile[x + dx, y + dy].type = (ushort)ModContent.TileType(); + Main.tile[x + dx, y + dy].frameX = (short)(dx * 18); + Main.tile[x + dx, y + dy].frameY = (short)(dy * 18); + Main.tile[x + dx, y + dy].active(true); + } + } + } + } + + public static int CountCellsAtPosition(bool[,] originalMap, int x, int y, bool checkForActiveCells) + { + int count = 0; + for (int dx = -1; dx <= 1; dx++) + { + for (int dy = -1; dy <= 1; dy++) + { + // Ignore the center position. + if (dx == 0 && dy == 0) + continue; + + // Ignore cells outside of the range of the map. + if (x + dx < 0 || x + dx >= originalMap.GetLength(0) || y + dy < 0 || y + dy >= originalMap.GetLength(1)) + continue; + + if ((originalMap[x + dx, y + dy] && checkForActiveCells) || (!originalMap[x + dx, y + dy] && !checkForActiveCells)) + count++; + } + } + return count; + } + + public static bool[,] SimulateCelluarAutomata(bool[,] originalMap) + { + bool[,] newMap = (bool[,])originalMap.Clone(); + for (int x = 0; x < originalMap.GetLength(0); x++) + { + for (int y = 0; y < originalMap.GetLength(1); y++) + { + if (originalMap[x, y] && CountCellsAtPosition(originalMap, x, y, true) < 4) + newMap[x, y] = false; + else if (!originalMap[x, y] && CountCellsAtPosition(originalMap, x, y, true) >= 5) + newMap[x, y] = true; + } + } + return newMap; + } + + public static bool GenerateVigorousVines(int x, int y, int length) + { + // Don't bother placing vines if there's no solid ground above for them to hang from. + if (!WorldGen.SolidTile(x, y - 1) || !WorldGen.SolidTile(x + 1, y - 1)) + return false; + + // Don't bother placing vines if there's anything obstructing their placement. + for (int dx = 0; dx < 2; dx++) + { + for (int dy = 0; dy < length * 2; dy++) + { + if (CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy).active()) + return false; + } + } + + int xFrame = 0; + ushort vineID = (ushort)ModContent.TileType(); + for (int dx = 0; dx < 2; dx++) + { + for (int dy = 0; dy < length * 2; dy++) + { + int yFrame = dy >= length * 2 - 2 ? 36 : 0; + if (dx == 0 && dy % 2 == 0) + xFrame = WorldGen.genRand.NextBool(yFrame > 0 ? 2 : 5) ? 36 : 0; + + Main.tile[x + dx, y + dy].active(true); + Main.tile[x + dx, y + dy].frameX = (short)(xFrame + dx * 18); + Main.tile[x + dx, y + dy].frameY = (short)(yFrame + dy % 2 * 18); + Main.tile[x + dx, y + dy].type = vineID; + } + } + return true; + } + + public static void RecursivelyFillAreaWithWater(int x, int y, int limit, ref int increment) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tile.active() || tile.liquid > 127) + return; + + increment++; + if (increment >= limit) + return; + + Main.tile[x, y].liquid = 255; + RecursivelyFillAreaWithWater(x + 1, y, limit, ref increment); + RecursivelyFillAreaWithWater(x - 1, y, limit, ref increment); + RecursivelyFillAreaWithWater(x, y + 1, limit, ref increment); + RecursivelyFillAreaWithWater(x, y - 1, limit, ref increment); + } + } +}