狗屎Minimax坏我代码
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.Feedback;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// 曲线通道模块,用于定义一个可复用的曲线震动参数。
|
||||
/// 包含激活状态、曲线定义、重映射范围。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct FloatCurveChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用此通道。
|
||||
/// </summary>
|
||||
public bool active;
|
||||
|
||||
/// <summary>
|
||||
/// 震动曲线,X轴为归一化时间[0,1],Y轴为强度[0,1]。
|
||||
/// </summary>
|
||||
[ShowIf("active")]
|
||||
[ShakeCurvePreset]
|
||||
public AnimationCurve curve;
|
||||
|
||||
/// <summary>
|
||||
/// 曲线值0对应的实际数值。
|
||||
/// </summary>
|
||||
[ShowIf("active")]
|
||||
[LabelText("Remap Min")]
|
||||
public float remapMin;
|
||||
|
||||
/// <summary>
|
||||
/// 曲线值1对应的实际数值。
|
||||
/// </summary>
|
||||
[ShowIf("active")]
|
||||
[LabelText("Remap Max")]
|
||||
public float remapMax;
|
||||
|
||||
/// <summary>
|
||||
/// 是否相对初始值叠加。
|
||||
/// </summary>
|
||||
[Tooltip("开启时,结果叠加在初始值上;关闭时,结果为绝对值")]
|
||||
public bool relativeToInitial;
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的曲线通道。
|
||||
/// </summary>
|
||||
public static FloatCurveChannel CreateDefault(bool active = true, float remapMin = 0f, float remapMax = 1f, bool relativeToInitial = true)
|
||||
{
|
||||
return new FloatCurveChannel
|
||||
{
|
||||
active = active,
|
||||
curve = new AnimationCurve(
|
||||
new Keyframe(0f, 0f),
|
||||
new Keyframe(0.5f, 1f),
|
||||
new Keyframe(1f, 0f)
|
||||
),
|
||||
remapMin = remapMin,
|
||||
remapMax = remapMax,
|
||||
relativeToInitial = relativeToInitial
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据归一化时间计算当前值。
|
||||
/// </summary>
|
||||
public readonly float Evaluate(float normalizedTime)
|
||||
{
|
||||
if (!active || curve == null) return 0f;
|
||||
float t = Mathf.Clamp01(normalizedTime);
|
||||
float curveValue = curve.Evaluate(t);
|
||||
return Mathf.LerpUnclamped(remapMin, remapMax, curveValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带颜色选项的曲线通道。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct ColorCurveChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用此通道。
|
||||
/// </summary>
|
||||
public bool active;
|
||||
|
||||
/// <summary>
|
||||
/// 颜色渐变。
|
||||
/// </summary>
|
||||
[ShowIf("active")]
|
||||
[LabelText("颜色渐变")]
|
||||
public Gradient gradient;
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的颜色曲线通道。
|
||||
/// </summary>
|
||||
public static ColorCurveChannel CreateDefault()
|
||||
{
|
||||
return new ColorCurveChannel
|
||||
{
|
||||
active = true,
|
||||
gradient = new Gradient()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据归一化时间获取颜色。
|
||||
/// </summary>
|
||||
public Color Evaluate(float normalizedTime)
|
||||
{
|
||||
if (!active || gradient == null) return Color.white;
|
||||
return gradient.Evaluate(Mathf.Clamp01(normalizedTime));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带Vector2选项的曲线通道(用于中心点等)。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct Vector2CurveChannel
|
||||
{
|
||||
public bool active;
|
||||
|
||||
[ShowIf("active")]
|
||||
[LabelText("曲线 X")]
|
||||
[ShakeCurvePreset]
|
||||
public AnimationCurve curveX;
|
||||
|
||||
[ShowIf("active")]
|
||||
[LabelText("曲线 Y")]
|
||||
[ShakeCurvePreset]
|
||||
public AnimationCurve curveY;
|
||||
|
||||
[ShowIf("active")]
|
||||
[LabelText("Remap Min")]
|
||||
public Vector2 remapMin;
|
||||
|
||||
[ShowIf("active")]
|
||||
[LabelText("Remap Max")]
|
||||
public Vector2 remapMax;
|
||||
|
||||
/// <summary>
|
||||
/// 是否相对初始值叠加。
|
||||
/// </summary>
|
||||
[TitleGroup("高级设置")]
|
||||
[LabelText("相对初始值")]
|
||||
[Tooltip("开启时,结果叠加在初始值上;关闭时,结果为绝对值")]
|
||||
public bool relativeToInitial;
|
||||
|
||||
public static Vector2CurveChannel CreateDefault()
|
||||
{
|
||||
return new Vector2CurveChannel
|
||||
{
|
||||
active = true,
|
||||
curveX = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f)),
|
||||
curveY = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f)),
|
||||
remapMin = Vector2.zero,
|
||||
remapMax = Vector2.one
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据归一化时间计算Vector2值。
|
||||
/// </summary>
|
||||
public Vector2 Evaluate(float normalizedTime, Vector2 initialValue)
|
||||
{
|
||||
if (!active) return Vector2.zero;
|
||||
float t = Mathf.Clamp01(normalizedTime);
|
||||
float x = curveX?.Evaluate(t) ?? 0f;
|
||||
float y = curveY?.Evaluate(t) ?? 0f;
|
||||
Vector2 remappedValue = new Vector2(
|
||||
Mathf.LerpUnclamped(remapMin.x, remapMax.x, x),
|
||||
Mathf.LerpUnclamped(remapMin.y, remapMax.y, y)
|
||||
);
|
||||
|
||||
return relativeToInitial ? initialValue + remappedValue : remappedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user