From 6d3d33fac522ea1abc97cc71d5eb790f30aa7f0c Mon Sep 17 00:00:00 2001 From: Flowaria Date: Wed, 10 Dec 2025 12:35:30 +0900 Subject: [PATCH] Simplified ModifyLight condition check in certain tiles --- Tiles/Ores/PerennialOre.cs | 80 +++++++++++++++++-------------- Tiles/SunkenSea/BlackPearlPile.cs | 9 ++-- Tiles/SunkenSea/PinkPearlPile.cs | 10 ++-- Tiles/SunkenSea/WhitePearlPile.cs | 9 ++-- 4 files changed, 64 insertions(+), 44 deletions(-) diff --git a/Tiles/Ores/PerennialOre.cs b/Tiles/Ores/PerennialOre.cs index 77cbd47565..a3fc7bb519 100644 --- a/Tiles/Ores/PerennialOre.cs +++ b/Tiles/Ores/PerennialOre.cs @@ -55,50 +55,60 @@ namespace CalamityMod.Tiles.Ores num = fail ? 1 : 3; } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + var tile = Main.tile[i, j]; + var frameX = tile.TileFrameX; + var frameY = tile.TileFrameY; + + bool hasFlowerInFrame = false; + switch (frameX) + { + case 0 when frameY == 0: + hasFlowerInFrame = true; + break; + + case 18 when frameY == 18: + hasFlowerInFrame = true; + break; + + case 36 when frameY == 0 || frameY == 36: + hasFlowerInFrame = true; + break; + + case 54 when frameY == 18: + hasFlowerInFrame = true; + break; + } + + tile.Get().Flag0 = hasFlowerInFrame; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { // The base green color glow r = 0.08f; g = 0.2f; b = 0.04f; - var tile = Main.tile[i, j]; - var pos = new Vector2(tile.TileFrameX, tile.TileFrameY); - Vector2[] positionsFlower = new Vector2[] + // Flower color glow + if (Main.tile[i, j].Get().Flag0) { - // Top row (always y = 0 on tile sheets) - new Vector2(0, 0), - new Vector2(36, 0), + float timeScalar = Main.GameUpdateCount * 0.017f; + float jDiv14 = j / 14f; + float iDiv14 = i / 14f; + float brightness = 0.7f; + brightness *= (float)MathF.Sin(jDiv14 + timeScalar); + brightness *= (float)MathF.Sin(iDiv14 + timeScalar); + brightness += 0.3f; + float flowerPosBrightnessR = 0.83f * brightness; + float flowerPosBrightnessG = 0.16f * brightness; + float flowerPosBrightnessB = 0.31f * brightness; - // Second row (always y = 18 on tile sheets) - new Vector2(18, 18), - new Vector2(54, 18), - - // Third row (always y = 36 on tile sheets) - new Vector2(36, 36), - - }; - - foreach (var positionFlower in positionsFlower) - { - if (pos == positionFlower) - { - float timeScalar = Main.GameUpdateCount * 0.017f; - float jDiv14 = j / 14f; - float iDiv14 = i / 14f; - float brightness = 0.7f; - brightness *= (float)MathF.Sin(jDiv14 + timeScalar); - brightness *= (float)MathF.Sin(iDiv14 + timeScalar); - brightness += 0.3f; - float flowerPosBrightnessR = 0.83f * brightness; - float flowerPosBrightnessG = 0.16f * brightness; - float flowerPosBrightnessB = 0.31f * brightness; - - // Adjust brightness for flowers - r = flowerPosBrightnessR; - g = flowerPosBrightnessG; - b = flowerPosBrightnessB; - } + // Adjust brightness for flowers + r = flowerPosBrightnessR; + g = flowerPosBrightnessG; + b = flowerPosBrightnessB; } } diff --git a/Tiles/SunkenSea/BlackPearlPile.cs b/Tiles/SunkenSea/BlackPearlPile.cs index ce0d1c73f4..662ec4069e 100644 --- a/Tiles/SunkenSea/BlackPearlPile.cs +++ b/Tiles/SunkenSea/BlackPearlPile.cs @@ -68,6 +68,11 @@ namespace CalamityMod.Tiles.SunkenSea return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's @@ -109,9 +114,7 @@ namespace CalamityMod.Tiles.SunkenSea public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - // figure out if the tile is exposed - taken from the coral tiles - if (Main.tile[i, j] == null || - (Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile)) + if (!Main.tile[i, j].Get().Flag0) return; // get in-game lighting color at this tile diff --git a/Tiles/SunkenSea/PinkPearlPile.cs b/Tiles/SunkenSea/PinkPearlPile.cs index 9b5cbc9e52..eef4ebe6ce 100644 --- a/Tiles/SunkenSea/PinkPearlPile.cs +++ b/Tiles/SunkenSea/PinkPearlPile.cs @@ -65,6 +65,11 @@ namespace CalamityMod.Tiles.SunkenSea return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's @@ -109,11 +114,10 @@ namespace CalamityMod.Tiles.SunkenSea } } } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - // figure out if the tile is exposed - taken from the coral tiles - if (Main.tile[i, j] == null || - (Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile)) + if (!Main.tile[i, j].Get().Flag0) return; // get in-game lighting color at this tile diff --git a/Tiles/SunkenSea/WhitePearlPile.cs b/Tiles/SunkenSea/WhitePearlPile.cs index f34a38a975..cec13da31b 100644 --- a/Tiles/SunkenSea/WhitePearlPile.cs +++ b/Tiles/SunkenSea/WhitePearlPile.cs @@ -66,6 +66,11 @@ namespace CalamityMod.Tiles.SunkenSea return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's @@ -107,9 +112,7 @@ namespace CalamityMod.Tiles.SunkenSea public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - // figure out if the tile is exposed - taken from the coral tiles - if (Main.tile[i, j] == null || - (Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile)) + if (!Main.tile[i, j].Get().Flag0) return; // get in-game lighting color at this tile