From 35515aa9d5811d52a03097f8c429f8e290ffae06 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sat, 29 Nov 2025 23:03:50 +0900 Subject: [PATCH] Move Sulph Water Color util to LightingUtils --- ILEditing/ILHelperMethods.cs | 65 +----------------------------------- Utilities/LightingUtils.cs | 64 +++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 67 deletions(-) diff --git a/ILEditing/ILHelperMethods.cs b/ILEditing/ILHelperMethods.cs index e0297af836..09d87c77f9 100644 --- a/ILEditing/ILHelperMethods.cs +++ b/ILEditing/ILHelperMethods.cs @@ -1,11 +1,7 @@ -using System.Collections.Generic; -using System.Linq; -using CalamityMod.Systems; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using MonoMod.Cil; using Terraria; using Terraria.Audio; -using Terraria.Graphics; using Terraria.ID; namespace CalamityMod.ILEditing @@ -62,65 +58,6 @@ namespace CalamityMod.ILEditing return true; } - public static void SelectSulphuricWaterColor(int x, int y, ref VertexColors initialColor, bool isSlope) - { - if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1) - { - Color cleanWaterColor = new(10, 62, 193); - Point closestSafeZone = SulphuricWaterSafeZoneSystem.NearbySafeTiles.Keys.OrderBy(t => t.ToVector2().DistanceSQ(new(x, y))).First(); - List points = new() - { - new Vector2(x - 0.5f, y - 0.5f), - new Vector2(x + 0.5f, y - 0.5f), - new Vector2(x - 0.5f, y + 0.5f), - new Vector2(x + 0.5f, y + 0.5f), - }; - - float lerpAmt = (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f; - for (int i = 0; i < 4; i++) - { - float distanceToClosest = points[i].Distance(closestSafeZone.ToVector2()); - float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + lerpAmt, true); - switch (i) - { - case 0: - initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - break; - - case 1: - initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); - break; - - case 2: - initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - break; - - case 3: - initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); - break; - - default: - break; - } - } - } - - if (isSlope) - { - initialColor.TopLeftColor *= 1f / 3; - initialColor.TopRightColor *= 1f / 3; - initialColor.BottomLeftColor *= 1f / 3; - initialColor.BottomRightColor *= 1f / 3; - } - else - { - initialColor.TopLeftColor *= 0.4f; - initialColor.TopRightColor *= 0.4f; - initialColor.BottomLeftColor *= 0.4f; - initialColor.BottomRightColor *= 0.4f; - } - } - public static void DumpToLog(ILContext il) => CalamityMod.Log.Debug(il.ToString()); public static void LogFailure(string name, string reason) => CalamityMod.Log.ILFailure(name, reason); } diff --git a/Utilities/LightingUtils.cs b/Utilities/LightingUtils.cs index fd7f9d330e..bf7771f566 100644 --- a/Utilities/LightingUtils.cs +++ b/Utilities/LightingUtils.cs @@ -1,16 +1,74 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Waters; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Graphics; namespace CalamityMod { public static partial class CalamityUtils { + public static void SulphuricWaterColor(int x, int y, ref VertexColors initialColor, bool isSlope) + { + if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1) + { + Color cleanWaterColor = new(10, 62, 193); + Point closestSafeZone = SulphuricWaterSafeZoneSystem.NearbySafeTiles.Keys.OrderBy(t => t.ToVector2().DistanceSQ(new(x, y))).First(); + List points = new() + { + new Vector2(x - 0.5f, y - 0.5f), + new Vector2(x + 0.5f, y - 0.5f), + new Vector2(x - 0.5f, y + 0.5f), + new Vector2(x + 0.5f, y + 0.5f), + }; + + float lerpAmt = (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f; + for (int i = 0; i < 4; i++) + { + float distanceToClosest = points[i].Distance(closestSafeZone.ToVector2()); + float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + lerpAmt, true); + switch (i) + { + case 0: + initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 1: + initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 2: + initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 3: + initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + default: + break; + } + } + } + + if (isSlope) + { + initialColor.TopLeftColor *= 1f / 3; + initialColor.TopRightColor *= 1f / 3; + initialColor.BottomLeftColor *= 1f / 3; + initialColor.BottomRightColor *= 1f / 3; + } + else + { + initialColor.TopLeftColor *= 0.4f; + initialColor.TopRightColor *= 0.4f; + initialColor.BottomLeftColor *= 0.4f; + initialColor.BottomRightColor *= 0.4f; + } + } + public static void SunkenSeaWaterLighting(int x, int y, Vector3 waterColor, ref float r, ref float g, ref float b) { float tick = (float)Main.timeForVisualEffects;