Files
ichni_Official/Assets/Scripts/Game/GameElements/GeneralEffects/SpeedLinesEffect.cs
SoulliesOfficial 25b6da25ae 同步
2026-03-31 07:51:40 -04:00

101 lines
4.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 映射到 remappeakRemap→1f1f=隐去,越小越强)
// --- Lines 设置 ---
public Color color; // 包含 AlphaAlpha 越大越不透明
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
}
}