diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index b181b5b09d..23a8521e64 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -1083,6 +1083,18 @@ namespace CalamityMod.ILEditing #region Lava Blocking private void BlockLavaDrawing(ILContext il) + { + if (ModLoader.HasMod("LiquidSlopesPatch")) + { + BlockLavaDrawing_LiquidSlopesPatch(il); + } + else + { + BlockLavaDrawing_Vanilla(il); + } + } + + private void BlockLavaDrawing_Vanilla(ILContext il) { //This edit to DrawNormalLiquids makes lavas in normal and white lighting draw with an alpha and with new textures //If the parameter for the waterstyle is more than the max waterstyles then its subtracted by the max water style count and thats the lava style ID @@ -1134,6 +1146,61 @@ namespace CalamityMod.ILEditing ); } + private void BlockLavaDrawing_LiquidSlopesPatch(ILContext il) + { + Assembly lspAsm = ModLoader.GetMod("LiquidSlopesPatch").Code; + Type liquidDrawCache = lspAsm.GetType("LiquidSlopesPatch.Common.RewrittenLiquidRenderer").GetNestedType("LiquidDrawCache"); + + //This edit to DrawNormalLiquids makes lavas in normal and white lighting draw with an alpha and with new textures + //If the parameter for the waterstyle is more than the max waterstyles then its subtracted by the max water style count and thats the lava style ID + ILCursor cursor = new ILCursor(il); + + //Continue if statement, basically + //if the liquid being drawn is lava and the water style is greater than the max water styles or if the liquid is water and less than the max water styles then the draw code is ran + //otherwise the loop/s are continued for the next liquid + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld(liquidDrawCache, "IsVisible"))) + { + LogFailure("Liquid Renderer Drawing", "Could not locate the IsVisible boolean check"); + return; + } + cursor.EmitLdarg3(); + cursor.EmitLdloc2(); //Initiated Liquid Draw Cache (needed for the Type parameter) + cursor.EmitLdfld(liquidDrawCache.GetField("Type")); + cursor.EmitDelegate>((IsVisible, style, type) => IsVisible && ((type == 1 && style >= LavaRenderingSystem.Instance.WaterStyleMaxCount + 1) || (type != 1 && style <= LavaRenderingSystem.Instance.WaterStyleMaxCount))); + + //Lava alpha color, if the liquid drawn is lava, multiply num by the water alpha + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdloc(2), i => i.MatchLdfld(liquidDrawCache.GetField("Type")), i => i.MatchStloc(8))) + { + LogFailure("Liquid Renderer Drawing", "Could not locate creation of the local variable num2 (the liquid type holder variable)"); + return; + } + cursor.EmitLdloc(8); + cursor.EmitLdloca(7); + cursor.EmitLdarg(4); + cursor.EmitDelegate((int num2, ref float num, float globalAlpha) => + { + if (num2 == LiquidID.Lava) + { + num *= globalAlpha; + } + }); + + //Conditionally replace the liquid texture whether the liquid is lava or water + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCallvirt(typeof(Asset).GetMethod("get_Value", BindingFlags.Public | BindingFlags.Instance)))) + { + LogFailure("Liquid Renderer Drawing", "Could not locate the Texture2D array of liquids"); + return; + } + cursor.EmitLdarg3(); + cursor.EmitLdloc2(); //Initiated Liquid Draw Cache (needed for the Type parameter) + cursor.EmitLdfld(liquidDrawCache.GetField("Type")); + cursor.EmitDelegate>((initialTexture, style, type) => + (style >= LavaRenderingSystem.Instance.WaterStyleMaxCount + 1 && type == LiquidID.Lava) + ? LavaRenderingSystem.Textures.liquid[style - LavaRenderingSystem.Instance.WaterStyleMaxCount - 1].Value + : initialTexture + ); + } + private void BlockLavaDrawingForSlopes(On_TileDrawing.orig_DrawTile_LiquidBehindTile orig, TileDrawing self, bool solidLayer, bool inFrontOfPlayers, int waterStyleOverride, Vector2 screenPosition, Vector2 screenOffset, int tileX, int tileY, Tile tileCache) { if (tileCache.LiquidType == LiquidID.Lava) @@ -1387,6 +1454,18 @@ namespace CalamityMod.ILEditing } private static void LiquidDrawColors(ILContext il) + { + if (ModLoader.HasMod("LiquidSlopesPatch")) + { + LiquidDrawColors_LiquidSlopesPatch(il); + } + else + { + LiquidDrawColors_Vanilla(il); + } + } + + private static void LiquidDrawColors_Vanilla(ILContext il) { ILCursor cursor = new ILCursor(il); if (!cursor.TryGotoNext(MoveType.Before, c => c.MatchLdarg2(), c => c.MatchLdloc3(), c => c.MatchLdloc(4), c => c.MatchCall
("DrawTileInWater"))) @@ -1413,6 +1492,37 @@ namespace CalamityMod.ILEditing } }); } + + private static void LiquidDrawColors_LiquidSlopesPatch(ILContext il) + { + Assembly lspAsm = ModLoader.GetMod("LiquidSlopesPatch").Code; + Type liquidDrawCache = lspAsm.GetType("LiquidSlopesPatch.Common.RewrittenLiquidRenderer").GetNestedType("LiquidDrawCache"); + + ILCursor cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, c => c.MatchLdarg2(), c => c.MatchLdloc(out _), c => c.MatchLdloc(out _), c => c.MatchCall
("DrawTileInWater"))) + { + LogFailure("Liquid Draw Colors (LSP)", "Could not locate the liquid vertex colors for drawing"); + return; + } + + cursor.Emit(OpCodes.Ldloc, 9); + cursor.Emit(OpCodes.Ldloc, 10); + cursor.Emit(OpCodes.Ldloc_2); + cursor.Emit(OpCodes.Ldfld, liquidDrawCache.GetField("Type")); + cursor.Emit(OpCodes.Ldloca, 11); + + cursor.EmitDelegate((int x, int y, int liquidType, ref VertexColors initialColor) => + { + if (liquidType == LiquidID.Water) + { + CalamityWaterLoader.DrawColorSetup(x, y, Main.waterStyle, ref initialColor); + } + else if (liquidType == LiquidID.Lava && ExternalMods.biomeLava == null) + { + LavaStylesLoader.DrawColorSetup(x, y, LavaRenderingSystem.LavaStyle, ref initialColor); + } + }); + } private static void LiquidSlopeDrawColors(ILContext il) { diff --git a/Items/Accessories/BloodyWormTooth.cs b/Items/Accessories/BloodyWormTooth.cs index 9a31aa9dad..aeb23ca680 100644 --- a/Items/Accessories/BloodyWormTooth.cs +++ b/Items/Accessories/BloodyWormTooth.cs @@ -30,7 +30,8 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddTile(TileID.TinkerersWorkbench). AddCondition(Condition.InGraveyard). - Register(); + Register() + .DisableDecraft(); } } } diff --git a/Items/Accessories/RottenBrain.cs b/Items/Accessories/RottenBrain.cs index c5f4da845c..d48784a538 100644 --- a/Items/Accessories/RottenBrain.cs +++ b/Items/Accessories/RottenBrain.cs @@ -34,7 +34,8 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddTile(TileID.TinkerersWorkbench). AddCondition(Condition.InGraveyard). - Register(); + Register() + .DisableDecraft(); } } } diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index f9987ef183..f85e30be92 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -1361,7 +1361,8 @@ namespace CalamityMod.Items // Queen Bee shimmerTransmute[ItemID.BeeKeeper] = ItemID.BeesKnees; shimmerTransmute[ItemID.BeesKnees] = ItemID.BeeGun; - shimmerTransmute[ItemID.BeeGun] = ItemID.BeeKeeper; + shimmerTransmute[ItemID.BeeGun] = ModContent.ItemType(); + shimmerTransmute[ModContent.ItemType()] = ItemID.BeeKeeper; // Deerclops shimmerTransmute[ItemID.LucyTheAxe] = ItemID.PewMaticHorn; diff --git a/Systems/Mechanic/RecipeSystem.cs b/Systems/Mechanic/RecipeSystem.cs index ba26817d84..619d469e95 100644 --- a/Systems/Mechanic/RecipeSystem.cs +++ b/Systems/Mechanic/RecipeSystem.cs @@ -490,6 +490,7 @@ namespace CalamityMod.Systems AddIngredient(ItemID.ExplosivePowder, 4). AddTile(TileID.Anvils). Register(); + // and Rocket IIs (requires slightly more explosive powder) Recipe.Create(ItemID.RocketII, 100). AddRecipeGroup("IronBar"). @@ -1298,7 +1299,6 @@ namespace CalamityMod.Systems r.AddRecipeGroup("AnyCopperBar", 2); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); // Lower half Desert items (these are partially destroyed by Sunken Sea) // Bast Statue @@ -1308,14 +1308,12 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Ruby); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Encumbering Stone r = Recipe.Create(ItemID.EncumberingStone); r.AddIngredient(ItemID.StoneBlock, 100); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); } #endregion @@ -1328,7 +1326,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Wood, 7); r.AddTile(TileID.WorkBenches); r.Register(); - r.DisableDecraft(); // Wand of Sparking r = Recipe.Create(ItemID.WandofSparking); @@ -1338,7 +1335,6 @@ namespace CalamityMod.Systems r.AddCondition(Condition.NotRemixWorld); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Early game minions // Finch Staff @@ -1347,7 +1343,6 @@ namespace CalamityMod.Systems r.AddRecipeGroup("Wood", 8); r.AddTile(TileID.WorkBenches); r.Register(); - r.DisableDecraft(); // Slime Staff r = Recipe.Create(ItemID.SlimeStaff); @@ -1355,7 +1350,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Gel, 40); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Key sword components // Enchanted Sword @@ -1403,7 +1397,6 @@ namespace CalamityMod.Systems r.AddRecipeGroup("Wood", 10); r.AddTile(TileID.Sawmill); r.Register(); - r.DisableDecraft(); #region Terraspark Boots Line // Hermes Boots @@ -1412,14 +1405,12 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.SwiftnessPotion, 5); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); // Aglet r = Recipe.Create(ItemID.Aglet); r.AddRecipeGroup(AnyCopperBar, 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Anklet of the Wind r = Recipe.Create(ItemID.AnkletoftheWind); @@ -1428,7 +1419,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.PinkGel, 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Ice Skates r = Recipe.Create(ItemID.IceSkates); @@ -1436,7 +1426,6 @@ namespace CalamityMod.Systems r.AddRecipeGroup("IronBar", 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Water Walking Boots r = Recipe.Create(ItemID.WaterWalkingBoots); @@ -1444,7 +1433,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.WaterWalkingPotion, 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Lava Charm r = Recipe.Create(ItemID.LavaCharm); @@ -1462,7 +1450,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Hellstone, 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); #endregion #region Core Movement Accessories @@ -1474,7 +1461,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Feather, 3); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Cloud in a Bottle r = Recipe.Create(ItemID.CloudinaBottle); @@ -1483,7 +1469,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Feather, 2); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Sandstorm in a Bottle r = Recipe.Create(ItemID.SandstorminaBottle); @@ -1503,7 +1488,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Feather, 10); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Flying Carpet r = Recipe.Create(ItemID.FlyingCarpet); @@ -1526,7 +1510,6 @@ namespace CalamityMod.Systems r.AddRecipeGroup(AnyGoldBar, 8); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Shiny Red Balloon r = Recipe.Create(ItemID.ShinyRedBalloon); @@ -1534,7 +1517,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Cloud, 10); r.AddTile(TileID.Solidifier); r.Register(); - r.DisableDecraft(); #endregion // Cobalt Shield @@ -1551,7 +1533,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Obsidian, 4); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Flower Boots r = Recipe.Create(ItemID.FlowerBoots); @@ -1560,21 +1541,18 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.JungleGrassSeeds, 5); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); // Hand Warmer r = Recipe.Create(ItemID.HandWarmer); r.AddIngredient(ItemID.Silk, 10); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); // Radar r = Recipe.Create(ItemID.Radar); r.AddRecipeGroup("IronBar", 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); } #endregion @@ -1587,21 +1565,18 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.FlinxFur, 1); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); r = Recipe.Create(ItemID.EskimoCoat); r.AddIngredient(ItemID.Silk, 8); r.AddIngredient(ItemID.FlinxFur, 2); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); r = Recipe.Create(ItemID.EskimoPants); r.AddIngredient(ItemID.Silk, 6); r.AddIngredient(ItemID.FlinxFur, 1); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); } #endregion @@ -1622,7 +1597,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.ChaosFish, 5); r.AddTile(TileID.MythrilAnvil); r.Register(); - r.DisableDecraft(); // Sergeant United Shield r = Recipe.Create(ItemID.BouncingShield); @@ -1638,7 +1612,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.LunarBar); r.AddTile(TileID.LunarCraftingStation); r.Register(); - r.DisableDecraft(); // Tiershift Mini Nuke 2s to post Moon Lord. r = Recipe.Create(ItemID.MiniNukeII, 333); @@ -1646,7 +1619,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.LunarBar); r.AddTile(TileID.LunarCraftingStation); r.Register(); - r.DisableDecraft(); } #endregion diff --git a/Systems/World/WorldgenManagementSystem.cs b/Systems/World/WorldgenManagementSystem.cs index 0311e15215..edfe124d57 100644 --- a/Systems/World/WorldgenManagementSystem.cs +++ b/Systems/World/WorldgenManagementSystem.cs @@ -231,7 +231,7 @@ namespace CalamityMod.Systems // it breaks up the 3 minute gen time and makes it more interesting for those who dont tab out while worldgen runs, // rather than keeping the player in the dark about what's happening. // it doesn't have to make sense, just be cool for the players :) -ena - SunkenSea.PlaceBasaltGullyBorderBlend(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); + //SunkenSea.PlaceBasaltGullyBorderBlend(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.SunkenSea").Value; SunkenSea.PlaceBasaltGully(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.TimelessShores").Value; diff --git a/Tiles/SunkenSea/Basalt.cs b/Tiles/SunkenSea/Basalt.cs index e9537446f1..54afa0857e 100644 --- a/Tiles/SunkenSea/Basalt.cs +++ b/Tiles/SunkenSea/Basalt.cs @@ -1,4 +1,6 @@ -using CalamityMod.Systems; +using System; +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -54,6 +56,61 @@ namespace CalamityMod.Tiles.SunkenSea { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void RandomUpdate(int i, int j) + { + Tile tUP = Main.tile[i, j - 1]; + Tile tDOWN = Main.tile[i, j + 1]; + Tile tLEFT = Main.tile[i - 1, j]; + Tile tRIGHT = Main.tile[i + 1, j]; + Tile tUPLEFT = Main.tile[i - 1, j - 1]; + Tile tDOWNLEFT = Main.tile[i - 1, j + 1]; + Tile tUPRIGHT = Main.tile[i + 1, j - 1]; + Tile tDOWNRIGHT = Main.tile[i + 1, j + 1]; + if (tUP.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUP.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWN.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWN.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tUPLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUPLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWNLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWNLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tUPRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUPRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWNRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWNRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + Dust dust; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 16, 16, DustID.Smoke, 0f, -1.9069767f, 195, new Color(255, 255, 255), 1f)]; + dust.noGravity = false; + dust.fadeIn = 1.4209302f; + } } } diff --git a/Tiles/SunkenSea/VolcanicSand.cs b/Tiles/SunkenSea/VolcanicSand.cs index 0d9d1ee157..b2beb345d4 100644 --- a/Tiles/SunkenSea/VolcanicSand.cs +++ b/Tiles/SunkenSea/VolcanicSand.cs @@ -39,5 +39,61 @@ namespace CalamityMod.Tiles.SunkenSea { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void RandomUpdate(int i, int j) + { + Tile tUP = Main.tile[i, j - 1]; + Tile tDOWN = Main.tile[i, j + 1]; + Tile tLEFT = Main.tile[i - 1, j]; + Tile tRIGHT = Main.tile[i + 1, j]; + Tile tUPLEFT = Main.tile[i - 1, j - 1]; + Tile tDOWNLEFT = Main.tile[i - 1, j + 1]; + Tile tUPRIGHT = Main.tile[i + 1, j - 1]; + Tile tDOWNRIGHT = Main.tile[i + 1, j + 1]; + if (tUP.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUP.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWN.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWN.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + + if (tUPLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUPLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWNLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWNLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tUPRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUPRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWNRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWNRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + Dust dust; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 16, 16, DustID.Smoke, 0f, -1.9069767f, 195, new Color(255, 255, 255), 1f)]; + dust.noGravity = false; + dust.fadeIn = 1.4209302f; + } } } diff --git a/Walls/LargeBasaltWall.cs b/Walls/LargeBasaltWall.cs index 3d108a79c5..f71e0f1ec0 100644 --- a/Walls/LargeBasaltWall.cs +++ b/Walls/LargeBasaltWall.cs @@ -15,11 +15,64 @@ namespace CalamityMod.Walls public override void RandomUpdate(int i, int j) { Tile t = Main.tile[i, j]; + Tile tUP = Main.tile[i, j - 1]; + Tile tDOWN = Main.tile[i, j + 1]; + Tile tLEFT = Main.tile[i - 1, j]; + Tile tRIGHT = Main.tile[i + 1, j]; + Tile tUPLEFT = Main.tile[i -1, j - 1]; + Tile tDOWNLEFT = Main.tile[i - 1, j + 1]; + Tile tUPRIGHT = Main.tile[i + 1, j -1]; + Tile tDOWNRIGHT = Main.tile[i + 1, j + 1]; if (t.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) { t.LiquidAmount = 0; WorldGen.SquareTileFrame(i, j); } + if (tUP.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUP.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWN.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWN.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + + if (tUPLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUPLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWNLEFT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWNLEFT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tUPRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tUPRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + if (tDOWNRIGHT.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + tDOWNRIGHT.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + Dust dust; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 16, 16, DustID.Smoke, 0f, -1.9069767f, 195, new Color(255, 255, 255), 1f)]; + dust.noGravity = false; + dust.fadeIn = 1.4209302f; } public override void PlaceInWorld(int i, int j, Item item) { diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index c32660eda1..a33f23598e 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -24,7 +24,7 @@ namespace CalamityMod.World { public static int TimelessShoresX = 0, TimelessShoresY = 0; public static int RadiantReefsX = 0, RadiantReefsY = 55; - public static int PolypForestX = 0, PolypForestY = 0; + public static int PolypForestX = 0, PolypForestY = 30; public static int GleamingBurrowsX = 0, GleamingBurrowsY = 75; public static int ClamDenX = 0, ClamDenY = 75; public static int BasaltGullyX = 0, BasaltGullyY = 15; @@ -646,14 +646,14 @@ namespace CalamityMod.World if (Main.tile[X, Y].HasTile && Main.tile[X, Y].TileType != ModContent.TileType()) { - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(4, 0.7); - WorldUtils.Gen(new Point(X, Y), new Shapes.Slime(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); + //ShapeData circle = new ShapeData(); + //GenAction blotchMod = new Modifiers.Blotches(4, 0.7); + //WorldUtils.Gen(new Point(X, Y), new Shapes.Slime(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] + //{ + // blotchMod.Output(circle) + //})); - WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(X, Y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] { new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()) })); @@ -869,41 +869,32 @@ namespace CalamityMod.World ushort Navystone = (ushort)ModContent.TileType(); ushort NavystoneWall = (ushort)ModContent.WallType(); + int XStart = origin.X - biomeSize - 3; + int XEnd = origin.X + biomeSize + 3; + + int YStart = (int)(origin.Y - verticalRadius * 0.4f) - 3; + int YEnd = origin.Y + verticalRadius + 3; + //place another barrier so the gleaming burrows doesnt just burst into the gully - for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 10) + + var basaltcircle = new Shapes.Circle(30); + GenAction paintBasalt = Actions.Chain( + new Actions.Clear(), + new Actions.SetTile((ushort)ModContent.TileType()), + new Actions.SetFrames(true) + ); + + for (int X = XStart; X < XEnd; X += 14) { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y += 2) + for (int Y = YStart; Y <= YEnd; Y += 12) { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float _, true) + && Y > origin.Y - 10) { - Tile t = Main.tile[X, Y]; - float percent = dist / constant; - float blurPercent = 0.98f; - - if (percent > blurPercent) - { - if (Y > origin.Y - 10) - { - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(10, 0.4); - - WorldUtils.Gen(new Point(X, Y + 5), new Shapes.Rectangle(10, 10), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); - WorldUtils.Gen(new Point(X, Y + 5), new ModShapes.All(circle), Actions.Chain(new GenAction[] - { - new Actions.Clear(), - new Actions.PlaceTile((ushort)ModContent.TileType()) - })); - } - } + WorldUtils.Gen(new Point(X - 5, Y + 5), basaltcircle, paintBasalt); } } } - - - //place the gleaming burrows caverns for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) { @@ -1267,107 +1258,80 @@ namespace CalamityMod.World } //basalt biome underneath the sunken sea - public static void PlaceBasaltGullyBorderBlend(int startPosX, int startPosY) - { - int startX = startPosX + SSOffsets.GlobalX + SSOffsets.BasaltGullyX; + //public static void PlaceBasaltGullyBorderBlend(int startPosX, int startPosY) + //{ + // int startX = (startPosX + SSOffsets.GlobalX + SSOffsets.BasaltGullyX); - int startY = startPosY + SSOffsets.GlobalY + SSOffsets.BasaltGullyY; + // int startY = (startPosY + SSOffsets.GlobalY + SSOffsets.BasaltGullyY) - 90; - int biomeSize = 270 + (Main.maxTilesX / 180); + // int biomeSize = 250 + (Main.maxTilesX / 180); - int XLeft = GenVars.UndergroundDesertLocation.Left + 40; - int XRight = GenVars.UndergroundDesertLocation.Right - 70; + // ushort Basalt = (ushort)ModContent.TileType(); + // ushort BasaltWall = (ushort)ModContent.WallType(); - ushort Basalt = (ushort)ModContent.TileType(); - ushort BasaltWall = (ushort)ModContent.WallType(); + // //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 = startX - biomeSize - 80; X < startX + biomeSize + 80; X += 1) + // { + // const int totalCurveDepth = -320; + // const int totalCurveDepthTop = 70; - int cavePerlinSeed = WorldGen.genRand.Next(); - int cavePerlinSeedWalls = WorldGen.genRand.Next(); - - //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 = startX - biomeSize - 80; X < startX + biomeSize + 80; X += 1) - { - const int totalCurveDepth = -320; - const int totalCurveDepthTop = 45; - - var squrt = MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 60, startX + biomeSize - 200, X, true)); - var squrt2 = MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 60, startX - biomeSize + 200, X, true)); + // var squrt = MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 60, startX + biomeSize - 200, X, true)); + // var squrt2 = MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 60, startX - biomeSize + 200, X, true)); - int curveDepth = (int)MathHelper.Lerp( - totalCurveDepth, - 0f, squrt); - int curveDepth2 = (int)MathHelper.Lerp( - totalCurveDepth, 0f, squrt2); - int curveDepthtop = (int)MathHelper.Lerp( - totalCurveDepthTop, - 0f, squrt); - int curveDepth2top = (int)MathHelper.Lerp( - totalCurveDepthTop, - 0f, squrt2); + // int curveDepth = (int)MathHelper.Lerp( + // totalCurveDepth, + // 0f, squrt); + // int curveDepth2 = (int)MathHelper.Lerp( + // totalCurveDepth, 0f, squrt2); + // int curveDepthtop = (int)MathHelper.Lerp( + // totalCurveDepthTop, + // 0f, squrt); + // int curveDepth2top = (int)MathHelper.Lerp( + // totalCurveDepthTop, + // 0f, squrt2); - int Height = Main.maxTilesY - 270 + curveDepth + curveDepth2; - int StartHeight = startY - (625) + curveDepthtop + curveDepth2top; + // int Height = Main.maxTilesY - 270 + curveDepth + curveDepth2; + // int StartHeight = startY - (625) + curveDepthtop + curveDepth2top; - for (int Y = StartHeight; Y <= Height; Y++) - { - Tile t = Main.tile[X, Y]; - if (Main.tile[X, Y].HasTile) - { - t.TileType = Basalt; - t.HasTile = true; - } + // for (int Y = StartHeight; Y <= Height; Y++) + // { + // Tile t = Main.tile[X, Y]; + // if (Main.tile[X, Y].HasTile) + // { + // t.TileType = Basalt; + // t.HasTile = true; + // } - t.WallType = BasaltWall; + // t.WallType = BasaltWall; + // } + // } - //place sand clumps on top of exposed basalt - bool canPlaceSand = false; + // //cleanup + // for (int X = startX - biomeSize - (Main.maxTilesX / 25); X < startX + biomeSize + (Main.maxTilesX / 25); X += 1) + // { + // 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; + // 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 (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile) - { - canPlaceSand = true; - } + // if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + // { + // WorldGen.KillTile(X, Y); + // } - if (canPlaceSand) - { - PlaceSand(X, Y, 3, ModContent.TileType()); - } - } - - } - - //cleanup - for (int X = startX - biomeSize - (Main.maxTilesX / 25); X < startX + biomeSize + (Main.maxTilesX / 25); X += 1) - { - 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; - 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); - } - - //kill random single floating tiles - if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) - { - WorldGen.KillTile(X, Y); - } - - //if any sand is floating, put tiles below it - if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile) - { - WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); - Main.tile[X, Y].TileType = (ushort)ModContent.TileType(); - } - Tile.SmoothSlope(X, Y); - } - } - } + // //kill random single floating tiles + // if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + // { + // WorldGen.KillTile(X, Y); + // } + // Tile.SmoothSlope(X, Y); + // } + // } + //} public static void PlaceBasaltGully(int startPosX, int startPosY) { int startX = startPosX + SSOffsets.GlobalX + SSOffsets.BasaltGullyX; @@ -1438,18 +1402,32 @@ namespace CalamityMod.World { Tile t = Main.tile[X, Y]; //place caves - float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80, Y / 130, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; - float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; - float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; - float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; - float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 5.5f + 0.235f; + float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80, Y / 130, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 975f, Y / 375f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 975f, Y / 375f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; + float caveCreationThreshold = horizontalOffsetNoise * 5.5f + 0.235f; - if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) + if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) { t.HasTile = false; t.LiquidType = 1; } + float horizontalOffsetNoiseWallsinner = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWallsinner = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWallsinner; + float cavePerlinValue2Wallsinner = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float caveNoiseMapWallsinner = (cavePerlinValueWallsinner + cavePerlinValue2Wallsinner) * 0.5f; + float caveCreationThresholdWallsinner = horizontalOffsetNoiseWallsinner * 5.5f + 0.435f; + + if (caveNoiseMapWallsinner * caveNoiseMapWallsinner > caveCreationThresholdWallsinner) + { + if (t.WallType == BasaltWall) + { + WorldGen.KillWall(X, Y); + } + } + //place lava if (WorldGen.genRand.NextBool(2000)) { @@ -1551,10 +1529,12 @@ namespace CalamityMod.World //first clean up unnecessary chunks of tiles CleanOutSmallClumps(); - //just loop through the whole world and check for the specific tiles in the sunken sea because im lazy - for (int X = 20; X <= Main.maxTilesX - 20; X++) + // Loop through the area around the Sunken Sea and check for the specific tiles + int minX = Math.Max(20, GenVars.UndergroundDesertLocation.Left - 20); + int maxX = Math.Min(GenVars.UndergroundDesertLocation.Right + 20, Main.maxTilesX - 20); + for (int X = minX; X <= maxX; X++) { - for (int Y = 20; Y <= Main.maxTilesY - 20; Y++) + for (int Y = (int)Main.worldSurface; Y <= Main.UnderworldLayer; Y++) { if (WorldGen.genRand.NextBool(200)) WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[]