diff --git a/Items/Weapons/Summon/SunSpiritStaff.cs b/Items/Weapons/Summon/SunSpiritStaff.cs index eed6b6f3b2..9d5ac24f1d 100644 --- a/Items/Weapons/Summon/SunSpiritStaff.cs +++ b/Items/Weapons/Summon/SunSpiritStaff.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 44; Item.height = 48; - Item.damage = 20; + Item.damage = 25; Item.mana = 10; Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Weapons/Summon/VengefulSunStaff.cs b/Items/Weapons/Summon/VengefulSunStaff.cs index 0738fd9998..7152f1617f 100644 --- a/Items/Weapons/Summon/VengefulSunStaff.cs +++ b/Items/Weapons/Summon/VengefulSunStaff.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 72; Item.height = 72; - Item.damage = 30; + Item.damage = 40; Item.mana = 10; Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Localization/en-US/Mods.CalamityMod.UI.WindowTitle.hjson b/Localization/en-US/Mods.CalamityMod.UI.WindowTitle.hjson new file mode 100644 index 0000000000..b09601ae5c --- /dev/null +++ b/Localization/en-US/Mods.CalamityMod.UI.WindowTitle.hjson @@ -0,0 +1 @@ +0: Terraria: Throw out the sunk with the seawater! diff --git a/Systems/TileMerging/DataStructures.cs b/Systems/TileMerging/DataStructures.cs index f164e549ef..671c32a0e0 100644 --- a/Systems/TileMerging/DataStructures.cs +++ b/Systems/TileMerging/DataStructures.cs @@ -103,19 +103,20 @@ namespace CalamityMod.Systems ShapeU_RightEmpty_DownEnd = ShapeI_Up | ShapeI_Down_End | ShapeI_Left, } - public struct SheetPositionKey(BlendSideFlags blendSides, byte randomFrameIndex) + public readonly struct SheetPositionKey(BlendSideFlags blendSides, byte randomFrameIndex) { - public BlendSideFlags BlendSides = blendSides; - public byte RandomFrameIndex = randomFrameIndex; + public ushort Key { get; init; } = (ushort)((int)blendSides + (randomFrameIndex * 256)); + public BlendSideFlags BlendSides => (BlendSideFlags)(byte)(Key % 256); + public byte RandomFrameIndex => (byte)(Key / 256); - public static implicit operator int(SheetPositionKey key) => (int)key.BlendSides + (key.RandomFrameIndex * byte.MaxValue); + public static implicit operator int(SheetPositionKey key) => key.Key; } - public struct SheetPosition + public readonly struct SheetPosition { - public byte X; - public byte Y; - public sbyte BakedSheetIndex; + public readonly byte X; + public readonly byte Y; + public readonly sbyte BakedSheetIndex; public SheetPosition(int x, int y, sbyte bakedSheetIndex = -1) { diff --git a/Systems/TileMerging/TileBlendMergeSystem_Draw.cs b/Systems/TileMerging/TileBlendMergeSystem_Draw.cs index 9306a298cf..07ab931ccc 100644 --- a/Systems/TileMerging/TileBlendMergeSystem_Draw.cs +++ b/Systems/TileMerging/TileBlendMergeSystem_Draw.cs @@ -81,7 +81,7 @@ namespace CalamityMod.Systems // Sliced Rendering int sliceLength = 0; Rectangle[] sliceRects = null; - Color[] colorSliceBuffer = ColorSliceBuffer.Value; + Color[] colorSliceBuffer = null; // Is HalfBlock condition is also in vanilla, so we follow that var silcedConfigEnabled = CalamityClientConfig.Instance.TileTextureBlendingQuality == TileBlendingQuality.High; @@ -92,12 +92,14 @@ namespace CalamityMod.Systems { sliceLength = 9; sliceRects = Rects9Slice; + colorSliceBuffer = ColorSliceBuffer.Value; Lighting.GetColor9Slice(tileX, tileY, ref colorSliceBuffer); } else if (tileLight.IsAnyChannelGreaterThan(tileRenderer._mediumQualityLightingRequirement)) { sliceLength = 4; sliceRects = Rects4Slice; + colorSliceBuffer = ColorSliceBuffer.Value; Lighting.GetColor4Slice(tileX, tileY, ref colorSliceBuffer); } } diff --git a/Systems/TileMerging/TileBlendTexture_Baking.cs b/Systems/TileMerging/TileBlendTexture_Baking.cs index 30d3a21f51..de51103d63 100644 --- a/Systems/TileMerging/TileBlendTexture_Baking.cs +++ b/Systems/TileMerging/TileBlendTexture_Baking.cs @@ -160,13 +160,7 @@ namespace CalamityMod.Systems var pos = _SheetPositionLookup[key]; sourceRect = pos.GetDrawRect(); - texture = pos.BakedSheetIndex switch - { - 0 => BakedBlendTexture, - 1 => BakedBlendTexture, - 2 => BakedBlendTexture, - _ => TextureAsset.Value - }; + texture = pos.IsUsingBaseTexture ? TextureAsset.Value : BakedBlendTexture; return texture != null; } diff --git a/UI/ResourceSets/CalamityResourceOverlay.cs b/UI/ResourceSets/CalamityResourceOverlay.cs index 43af0c9d76..07a194b84c 100644 --- a/UI/ResourceSets/CalamityResourceOverlay.cs +++ b/UI/ResourceSets/CalamityResourceOverlay.cs @@ -16,6 +16,18 @@ namespace CalamityMod.UI.ResourceSets // Most of this is taken from ExampleMod. See that for additional explanations. private Dictionary> vanillaAssetCache = new(); + // Vanilla texture paths + const string fancyFolder = "Images/UI/PlayerResourceSets/FancyClassic/"; + const string barsFolder = "Images/UI/PlayerResourceSets/HorizontalBars/"; + + private Asset FancyHeartFill => field ??= Main.Assets.Request(fancyFolder + "Heart_Fill"); + private Asset FancyHeartFillB => field ??= Main.Assets.Request(fancyFolder + "Heart_Fill_B"); + private Asset FancyStarFill => field ??= Main.Assets.Request(fancyFolder + "Star_Fill"); + + private Asset BarMPFill => field ??= Main.Assets.Request(barsFolder + "MP_Fill"); + private Asset BarHPFill => field ??= Main.Assets.Request(barsFolder + "HP_Fill"); + private Asset BarHPFillHoney => field ??= Main.Assets.Request(barsFolder + "HP_Fill_Honey"); + // Determines which health UI to draw based on player upgrades. public static CalamityUIResourceSet GetLifeTextureSet() { @@ -52,29 +64,17 @@ namespace CalamityMod.UI.ResourceSets { Asset asset = context.texture; - // Vanilla texture paths - const string fancyFolder = "Images/UI/PlayerResourceSets/FancyClassic/"; - const string barsFolder = "Images/UI/PlayerResourceSets/HorizontalBars/"; - - const string fancyHeartFill = fancyFolder + "Heart_Fill"; - const string fancyHeartFillB = fancyFolder + "Heart_Fill_B"; - const string fancyStarFill = fancyFolder + "Star_Fill"; - - const string barMPFill = barsFolder + "MP_Fill"; - const string barHPFill = barsFolder + "HP_Fill"; - const string barHPFillHoney = barsFolder + "HP_Fill_Honey"; - var manaTextureSet = GetManaTextureSet(); if (manaTextureSet != null) { // Draw stars for Classic and Fancy - if (asset == TextureAssets.Mana || CompareAssets(asset, fancyStarFill)) + if (asset == TextureAssets.Mana || asset == FancyStarFill) { context.texture = manaTextureSet.Star; context.Draw(); } // Draw mana bars - else if (CompareAssets(asset, barMPFill)) + else if (asset == BarMPFill) { context.texture = manaTextureSet.Bar; context.Draw(); @@ -85,13 +85,13 @@ namespace CalamityMod.UI.ResourceSets if (lifeTextureSet != null) { // Draw hearts for Classic and Fancy - if (asset == TextureAssets.Heart || asset == TextureAssets.Heart2 || CompareAssets(asset, fancyHeartFill) || CompareAssets(asset, fancyHeartFillB)) + if (asset == TextureAssets.Heart || asset == TextureAssets.Heart2 || asset == FancyHeartFill || asset == FancyHeartFillB) { context.texture = lifeTextureSet.Heart; context.Draw(); } // Draw health bars - else if (CompareAssets(asset, barHPFill) || CompareAssets(asset, barHPFillHoney)) + else if (asset == BarHPFill || asset == BarHPFillHoney) { context.texture = lifeTextureSet.Bar; context.Draw(); @@ -303,13 +303,5 @@ namespace CalamityMod.UI.ResourceSets } } - - private bool CompareAssets(Asset currentAsset, string compareAssetPath) - { - if (!vanillaAssetCache.TryGetValue(compareAssetPath, out var asset)) - asset = vanillaAssetCache[compareAssetPath] = Main.Assets.Request(compareAssetPath); - - return currentAsset == asset; - } } } diff --git a/UI/WindowTitles.cs b/UI/WindowTitles.cs new file mode 100644 index 0000000000..ada27a3d7a --- /dev/null +++ b/UI/WindowTitles.cs @@ -0,0 +1,45 @@ +using Terraria; +using Terraria.ModLoader; +using Terraria.Localization; +using System.Collections.Generic; +using System; +using System.Linq; +using System.Text.RegularExpressions; +using ReLogic.OS; + +namespace CalamityMod.UI +{ + public class WindowTitles : ModSystem + { + private static LocalizedText _calamityModifiedText; + private static bool loaded = false; + public override void PostSetupContent() + { + // the other method involving some terraria intrinsic function didn't work, so i'm just ignoring it + var vanillaTitles = Language.FindAll(new Regex("^GameTitle\\.")).ToList(); + var customTitles = Language.FindAll(new Regex("^Mods\\.CalamityMod\\.UI\\.WindowTitle\\.")).ToList(); + + var allTitles = new List(); + allTitles.AddRange(vanillaTitles); + allTitles.AddRange(customTitles); + + _calamityModifiedText ??= allTitles[Main.rand.Next(allTitles.Count)]; + + // this is what vanilla terraria does to set it's title, so i'm replicating that here + Platform.Get().SetUnicodeTitle(Main.instance.Window, _calamityModifiedText.Value); + Platform.Get().SetIcon(Main.instance.Window); + + loaded = true; + } + + public override void Unload() + { + Platform.Get().SetUnicodeTitle(Main.instance.Window, Lang.GetRandomGameTitle()); + Platform.Get().SetIcon(Main.instance.Window); + + _calamityModifiedText = null; + loaded = false; + base.Unload(); + } + } +} diff --git a/Walls/LargeBasaltWall.cs b/Walls/LargeBasaltWall.cs index f71e0f1ec0..a4afcb1f64 100644 --- a/Walls/LargeBasaltWall.cs +++ b/Walls/LargeBasaltWall.cs @@ -12,68 +12,40 @@ namespace CalamityMod.Walls AddMapEntry(new Color(65, 64, 68)); } + 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) + DrainWater(i - 1, j - 1); + DrainWater(i - 1, j); + DrainWater(i - 1, j + 1); + DrainWater(i, j - 1); + DrainWater(i, j); + DrainWater(i, j + 1); + DrainWater(i + 1, j - 1); + DrainWater(i + 1, j); + DrainWater(i + 1, j + 1); + + static void DrainWater(int x, int y) { - 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); + var tile = Main.tile[x, y]; + ref var liquidData = ref tile.Get(); + + if (liquidData.LiquidType != LiquidID.Water || liquidData.Amount == 0) + return; + + liquidData.Amount = 0; + WorldGen.SquareTileFrame(x, y); + + if (Main.dedServ) + NetMessage.sendWater(x, y); } - 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) { Tile t = Main.tile[i, j]; diff --git a/Walls/UnsafeWalls/UnsafeLargeBasaltWall.cs b/Walls/UnsafeWalls/UnsafeLargeBasaltWall.cs index fa88417a27..10fb46903d 100644 --- a/Walls/UnsafeWalls/UnsafeLargeBasaltWall.cs +++ b/Walls/UnsafeWalls/UnsafeLargeBasaltWall.cs @@ -13,68 +13,40 @@ namespace CalamityMod.Walls.UnsafeWalls AddMapEntry(new Color(65, 64, 68)); } + 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) + DrainWater(i - 1, j - 1); + DrainWater(i - 1, j); + DrainWater(i - 1, j + 1); + DrainWater(i, j - 1); + DrainWater(i, j); + DrainWater(i, j + 1); + DrainWater(i + 1, j - 1); + DrainWater(i + 1, j); + DrainWater(i + 1, j + 1); + + static void DrainWater(int x, int y) { - 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); + var tile = Main.tile[x, y]; + ref var liquidData = ref tile.Get(); + + if (liquidData.LiquidType != LiquidID.Water || liquidData.Amount == 0) + return; + + liquidData.Amount = 0; + WorldGen.SquareTileFrame(x, y); + + if (Main.dedServ) + NetMessage.sendWater(x, y); } - 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) { Tile t = Main.tile[i, j];