Move Sulph Water Color util to LightingUtils
This commit is contained in:
1 parent
1749920b6c
commit
35515aa9d5
2 files changed
+62
-67
No files matched your search
@@ -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<Vector2> 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);
|
||||
}
|
||||
|
||||
@@ -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<Vector2> 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;
|
||||
|
||||
Reference in new issue
Block a user