101 lines
4.4 KiB
C#
101 lines
4.4 KiB
C#
|
|
using Ichni.RhythmGame.Beatmap;
|
|||
|
|
using SLSUtilities.Rendering.PostProcessing;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Ichni.RhythmGame
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 控制 SpeedLines 后处理效果的特效脚本。
|
|||
|
|
/// 通过 intensityCurve + peakRemap 在持续时间内驱动 speedLinesRemap(数值越低效果越强)。
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class SpeedLinesEffect : EffectBase
|
|||
|
|
{
|
|||
|
|
#region [运行时缓存数据] Property Caches
|
|||
|
|
// --- 时间控制 ---
|
|||
|
|
public AnimationCurve intensityCurve; // 0→1 映射到 remap:peakRemap→1f(1f=隐去,越小越强)
|
|||
|
|
|
|||
|
|
// --- Lines 设置 ---
|
|||
|
|
public Color color; // 包含 Alpha,Alpha 越大越不透明
|
|||
|
|
public float peakRemap; // 效果最强时 speedLinesRemap 的目标值(默认 0,越低越密集)
|
|||
|
|
public float speedLinesTiling; // 线条分块数量,默认 200
|
|||
|
|
public float speedLinesRadialScale; // 放射缩放,默认 0.1
|
|||
|
|
public float speedLinesPower; // 线条锐利度,默认 0
|
|||
|
|
public float speedLinesAnimation; // 移动速度,默认 3
|
|||
|
|
|
|||
|
|
// --- Radial Mask 设置 ---
|
|||
|
|
public float maskScale; // 遮罩比例,默认 1
|
|||
|
|
public float maskHardness; // 遮罩边缘硬度,默认 0
|
|||
|
|
public float maskPower; // 遮罩幂次,默认 5
|
|||
|
|
|
|||
|
|
private SpeedLines _speedLinesVolume;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region [生成与初始化] Generation & Initialization
|
|||
|
|
public SpeedLinesEffect(float effectTime, AnimationCurve intensityCurve,
|
|||
|
|
Color color, float peakRemap = 0f,
|
|||
|
|
float speedLinesTiling = 200f, float speedLinesRadialScale = 0.1f,
|
|||
|
|
float speedLinesPower = 0f, float speedLinesAnimation = 3f,
|
|||
|
|
float maskScale = 1f, float maskHardness = 0f, float maskPower = 5f)
|
|||
|
|
: base(effectTime)
|
|||
|
|
{
|
|||
|
|
this.intensityCurve = intensityCurve;
|
|||
|
|
this.color = color;
|
|||
|
|
this.peakRemap = peakRemap;
|
|||
|
|
this.speedLinesTiling = speedLinesTiling;
|
|||
|
|
this.speedLinesRadialScale = speedLinesRadialScale;
|
|||
|
|
this.speedLinesPower = speedLinesPower;
|
|||
|
|
this.speedLinesAnimation = speedLinesAnimation;
|
|||
|
|
this.maskScale = maskScale;
|
|||
|
|
this.maskHardness = maskHardness;
|
|||
|
|
this.maskPower = maskPower;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PrepareHandle()
|
|||
|
|
{
|
|||
|
|
if (_speedLinesVolume == null && PostProcessingManager.GlobalVolume != null)
|
|||
|
|
{
|
|||
|
|
PostProcessingManager.GlobalVolume.profile.TryGet(out _speedLinesVolume);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region [处理与更新] Update & Processing
|
|||
|
|
public override void PreExecute()
|
|||
|
|
{
|
|||
|
|
PrepareHandle();
|
|||
|
|
if (_speedLinesVolume == null) return;
|
|||
|
|
|
|||
|
|
// 静态参数在预执行时写入一次
|
|||
|
|
_speedLinesVolume.color.value = color;
|
|||
|
|
_speedLinesVolume.speedLinesTiling.value = speedLinesTiling;
|
|||
|
|
_speedLinesVolume.speedLinesRadialScale.value = speedLinesRadialScale;
|
|||
|
|
_speedLinesVolume.speedLinesPower.value = speedLinesPower;
|
|||
|
|
_speedLinesVolume.speedLinesAnimation.value = speedLinesAnimation;
|
|||
|
|
_speedLinesVolume.maskScale.value = maskScale;
|
|||
|
|
_speedLinesVolume.maskHardness.value = maskHardness;
|
|||
|
|
_speedLinesVolume.maskPower.value = maskPower;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void Execute()
|
|||
|
|
{
|
|||
|
|
if (_speedLinesVolume == null) return;
|
|||
|
|
|
|||
|
|
// intensityCurve 0→1,将 remap 从 1f(无效果)插值到 peakRemap(最强效果)
|
|||
|
|
float t = intensityCurve != null ? intensityCurve.Evaluate(effectProgressPercent) : effectProgressPercent;
|
|||
|
|
_speedLinesVolume.speedLinesRemap.value = Mathf.Lerp(1f, peakRemap, t);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void Adjust() { ResetEffect(); }
|
|||
|
|
public override void Recover() { ResetEffect(); }
|
|||
|
|
public override void Disrupt() { ResetEffect(); }
|
|||
|
|
|
|||
|
|
private void ResetEffect()
|
|||
|
|
{
|
|||
|
|
if (_speedLinesVolume != null)
|
|||
|
|
_speedLinesVolume.speedLinesRemap.value = 1f; // Remap=1 时 IsActive() 返回 false
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|