86 lines
3.2 KiB
C#
86 lines
3.2 KiB
C#
using Ichni.RhythmGame.Beatmap;
|
||
using SLSUtilities.Rendering.PostProcessing; // 直接调取你的新版 Volume
|
||
using UnityEngine;
|
||
|
||
namespace Ichni.RhythmGame
|
||
{
|
||
public class RadialBlurEffect : EffectBase
|
||
{
|
||
#region [效果参数] Effect Parameters
|
||
public int sampleLevel;
|
||
public float position; // 注:虽然新版可能未用此值或代表意义不同,为了兼容旧读写表保持传入
|
||
public float fadeRange; // 注:同上,保留以使 ConvertToBM 存取数据兼容
|
||
public float peakIntensity;
|
||
public AnimationCurve intensityCurve;
|
||
|
||
private RadialBlur _radialBlurVolume;
|
||
#endregion
|
||
|
||
#region [初始化] Initialization
|
||
public RadialBlurEffect(float effectTime, int sampleLevel, float position, float fadeRange, float peakIntensity, AnimationCurve intensityCurve)
|
||
: base(effectTime) // 【修改】对接 EffectBase 含时控制
|
||
{
|
||
this.effectTime = effectTime;
|
||
this.sampleLevel = sampleLevel;
|
||
this.position = position;
|
||
this.fadeRange = fadeRange;
|
||
this.peakIntensity = peakIntensity;
|
||
this.intensityCurve = intensityCurve;
|
||
}
|
||
|
||
private void PrepareHandle()
|
||
{
|
||
if (_radialBlurVolume == null && PostProcessingManager.GlobalVolume != null)
|
||
{
|
||
// 用管家提取我们在全局体积域中注册的 RadialBlur 面板副本
|
||
PostProcessingManager.GlobalVolume.profile.TryGet(out _radialBlurVolume);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region [效果逻辑覆盖] Effect Pattern Overrides
|
||
public override void PreExecute()
|
||
{
|
||
PrepareHandle();
|
||
if (_radialBlurVolume != null)
|
||
{
|
||
// 直接把数值映射为你的 Quality Level 枚举 (限制在 0-3 之间防越界)
|
||
_radialBlurVolume.qualityLevel.value = RadialBlurQuality.RadialBlur_8Tap_Balance;
|
||
//(RadialBlurQuality)Mathf.Clamp(sampleLevel, 0, 3);
|
||
|
||
// 将径向中心点归位于正中(未来你可以在这里利用传入的 position 或改造一个 Vector2 支持屏幕任意位置暴气)
|
||
_radialBlurVolume.radialCenterX.value = 0.5f;
|
||
_radialBlurVolume.radialCenterY.value = 0.5f;
|
||
}
|
||
}
|
||
|
||
public override void Execute()
|
||
{
|
||
if (_radialBlurVolume != null)
|
||
{
|
||
// 完美跟随时间推移变换强度
|
||
float intensity = Mathf.Lerp(0, peakIntensity, intensityCurve.Evaluate(effectProgressPercent));
|
||
_radialBlurVolume.blurRadius.value = intensity;
|
||
}
|
||
}
|
||
|
||
public override void Adjust() { ResetEffect(); }
|
||
public override void Recover() { ResetEffect(); }
|
||
public override void Disrupt() { ResetEffect(); }
|
||
|
||
private void ResetEffect()
|
||
{
|
||
if (_radialBlurVolume != null)
|
||
{
|
||
// 新版里只要 radius = 0,IsActive就为 false,自动关闭!极其优雅。
|
||
_radialBlurVolume.blurRadius.value = 0f;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|