整合SLSUtilities

This commit is contained in:
SoulliesOfficial
2026-01-17 11:35:49 -05:00
parent d94241f36c
commit 7ee2894a63
1338 changed files with 3051541 additions and 507034 deletions

View File

@@ -0,0 +1,53 @@
using System;
using UnityEngine;
namespace LunaWolfStudiosEditor.ScriptableSheets.Comparables
{
public class GradientComparable : AbstractComparable<GradientComparable, Gradient>, IComparable
{
public GradientComparable(Gradient value) : base(value)
{
}
public override int CompareTo(Gradient value, Gradient other)
{
var averageColor = GetAverageColor(value.colorKeys);
var otherAverageColor = GetAverageColor(other.colorKeys);
var redComparison = averageColor.r.CompareTo(otherAverageColor.r);
if (redComparison != 0)
{
return redComparison;
}
var greenComparison = averageColor.g.CompareTo(otherAverageColor.g);
if (greenComparison != 0)
{
return greenComparison;
}
var blueComparison = averageColor.b.CompareTo(otherAverageColor.b);
if (blueComparison != 0)
{
return blueComparison;
}
return averageColor.a.CompareTo(otherAverageColor.a);
}
public static Color GetAverageColor(GradientColorKey[] colorKeys)
{
var totalColor = Color.clear;
foreach (var key in colorKeys)
{
totalColor += key.color;
}
return totalColor / colorKeys.Length;
}
public static explicit operator GradientComparable(Gradient value)
{
return new GradientComparable(value);
}
}
}