Feel滚
This commit is contained in:
@@ -46,25 +46,25 @@ namespace Cielonos.MainGame.Characters
|
||||
private void ClawStabBlast()
|
||||
{
|
||||
GenerateClawStabBlast("ClawStabBlast", "ClawStabBlast", 10);
|
||||
feedbackSc["ImpaleWave_Stab"].Play();
|
||||
//feedbackSc["ImpaleWave_Stab"].Play();
|
||||
}
|
||||
|
||||
private void ClawImpaleWave()
|
||||
{
|
||||
GenerateImpaleWave("ImpaleWave");
|
||||
feedbackSc["ImpaleWave_Wave"].Play();
|
||||
//feedbackSc["ImpaleWave_Wave"].Play();
|
||||
}
|
||||
|
||||
private void JumpAttackBlast()
|
||||
{
|
||||
GenerateJumpAttackBlast("JumpAttackBlast", "JumpAttackBlast", 10);
|
||||
feedbackSc["JumpAttack_Blast"].Play();
|
||||
//feedbackSc["JumpAttack_Blast"].Play();
|
||||
}
|
||||
|
||||
private void BumpImpaleWave()
|
||||
{
|
||||
GenerateImpaleWave("ImpaleWave");
|
||||
feedbackSc["ImpaleWave_Wave"].Play();
|
||||
//feedbackSc["ImpaleWave_Wave"].Play();
|
||||
}
|
||||
|
||||
private void GenerateNormalBulletSpawner()
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Cielonos.MainGame.Characters
|
||||
{
|
||||
AudioManager.Post(AK.EVENTS.NEXUS_CORE_FINISH, centerPosition);
|
||||
PlayerCanvas.Instance.bossInfoUIArea.RemoveInfoUnit(this);
|
||||
MainGameManager.Player.feedbackSc["NexusFinish"].Play();
|
||||
//MainGameManager.Player.feedbackSc["NexusFinish"].Play();
|
||||
}
|
||||
|
||||
base.Die();
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Cielonos.MainGame.Effects.Feedback;
|
||||
using Lean.Pool;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using SLSUtilities.Feedback;
|
||||
using SLSUtilities.FeelAssistance;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Characters
|
||||
{
|
||||
public partial class FeedbackSubcontroller : SubcontrollerBase<CharacterBase>
|
||||
{
|
||||
// === 旧系统(Feel)—— 保留向后兼容 ===
|
||||
public Dictionary<string, FeedbackUnit> feedbacks;
|
||||
public FeedbackUnit this[string feedbackName] => feedbacks?.GetValueOrDefault(feedbackName, null);
|
||||
|
||||
// === 新系统(Feedback System)===
|
||||
public FeedbackDataCollection feedbackDataCollection;
|
||||
public FeedbackData this[string feedbackName] => GetFeedbackData(feedbackName);
|
||||
|
||||
private CharacterFeedbackTimeProvider _timeProvider;
|
||||
private readonly List<FeedbackPlayer> _activePlayers = new List<FeedbackPlayer>(8);
|
||||
@@ -99,6 +91,19 @@ namespace Cielonos.MainGame.Characters
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按名称停止正在播放的 Feedback。
|
||||
/// </summary>
|
||||
public void StopFeedback(string feedbackName)
|
||||
{
|
||||
if (feedbackDataCollection == null) return;
|
||||
if (feedbackDataCollection.TryGet(feedbackName, out FeedbackData data))
|
||||
{
|
||||
StopFeedback(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 停止所有活跃的新系统播放器。
|
||||
@@ -114,18 +119,6 @@ namespace Cielonos.MainGame.Characters
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// 旧系统驱动
|
||||
if (feedbacks != null)
|
||||
{
|
||||
foreach (var feedbackUnit in feedbacks.Values)
|
||||
{
|
||||
float timeScaleMultiplier = owner.selfTimeSm.TimeScale;
|
||||
feedbackUnit.feedback.ExternalTimeScale = timeScaleMultiplier;
|
||||
feedbackUnit.Update();
|
||||
}
|
||||
}
|
||||
|
||||
// 新系统驱动
|
||||
float dt = Time.deltaTime;
|
||||
for (int i = _activePlayers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace Cielonos.MainGame.Characters
|
||||
if (sourceItem != null)
|
||||
{
|
||||
sourceItem.audioContainer.PlaySoundFX("PerfectBlock");
|
||||
sourceItem.feedbackSc["PerfectBlock"]?.Play();
|
||||
sourceItem.feedbackSc.PlayFeedback("PerfectBlock");
|
||||
pObj = sourceItem.blockData.InstantiateBlockEffect(perfectEffectName, sourceCharacter, blockEffectPosition, Quaternion.identity);
|
||||
}
|
||||
else
|
||||
@@ -178,7 +178,7 @@ namespace Cielonos.MainGame.Characters
|
||||
if (sourceItem != null)
|
||||
{
|
||||
sourceItem.audioContainer.PlaySoundFX("NormalBlock");
|
||||
sourceItem.feedbackSc["NormalBlock"]?.Play();
|
||||
sourceItem.feedbackSc.PlayFeedback("NormalBlock");
|
||||
sourceItem.blockData.InstantiateBlockEffect(normalEffectName, sourceCharacter, blockEffectPosition, Quaternion.identity);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cielonos.MainGame.Characters.Inventory;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.General;
|
||||
using UnityEngine;
|
||||
@@ -157,7 +156,7 @@ namespace Cielonos.MainGame.Characters
|
||||
|
||||
if (sourceItem == null)
|
||||
{
|
||||
sourceCharacter?.feedbackSc["PerfectDodge"]?.Play();
|
||||
sourceCharacter?.feedbackSc.PlayFeedback("PerfectDodge");
|
||||
Debug.Log("Perfect Dodge!");
|
||||
}
|
||||
}
|
||||
@@ -168,7 +167,7 @@ namespace Cielonos.MainGame.Characters
|
||||
|
||||
if (sourceItem == null)
|
||||
{
|
||||
sourceCharacter?.feedbackSc["NormalDodge"]?.Play();
|
||||
sourceCharacter?.feedbackSc.PlayFeedback("NormalDodge");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using MoreMountains.Feedbacks;
|
||||
using SLSUtilities.General;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Cielonos.MainGame.UI;
|
||||
using FIMSpace.FProceduralAnimation;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using RootMotion.FinalIK;
|
||||
using SLSUtilities.General;
|
||||
using SLSUtilities.FunctionalAnimation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Cielonos.MainGame.Characters
|
||||
{
|
||||
|
||||
@@ -2,17 +2,13 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Cielonos.MainGame.Characters;
|
||||
using Cielonos.MainGame.Effects.Feedback;
|
||||
using Cielonos.MainGame.FunctionalAnimation;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.Feedback;
|
||||
using SLSUtilities.WwiseAssistance;
|
||||
using SLSUtilities.FunctionalAnimation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Cielonos.MainGame.Characters.Inventory
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Cielonos.MainGame.Characters;
|
||||
using Cielonos.MainGame.UI;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ namespace Cielonos.MainGame.Characters.Inventory.Collections
|
||||
//Swing("Swing", "Swing", swingRotation);
|
||||
audioContainer.PlaySoundFX(vfxName + "Release", projectile.gameObject, true);
|
||||
|
||||
projectile.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_NORMALHIT)
|
||||
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());
|
||||
/*projectile.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_NORMALHIT)
|
||||
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());*/
|
||||
}
|
||||
|
||||
private void GenerateGroundArea(string vfxName)
|
||||
@@ -125,8 +125,8 @@ namespace Cielonos.MainGame.Characters.Inventory.Collections
|
||||
//Swing("Swing", "Swing", Vector3.right);
|
||||
audioContainer.PlaySoundFX("GroundArea", area.gameObject, true);
|
||||
|
||||
area.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_NORMALHIT)
|
||||
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());
|
||||
/*area.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_NORMALHIT)
|
||||
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());*/
|
||||
}
|
||||
|
||||
private void GenerateSquareExpandingAura(string vfxName)
|
||||
|
||||
@@ -3,9 +3,6 @@ using ChocDino.UIFX;
|
||||
using Cielonos.MainGame.Buffs.Character;
|
||||
using Cielonos.MainGame.Effects.Feedback;
|
||||
using Cielonos.MainGame.UI;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using MoreMountains.FeedbacksForThirdParty.Cielonos;
|
||||
using SLSUtilities.Feedback;
|
||||
using SLSUtilities.General;
|
||||
using SLSUtilities.FunctionalAnimation;
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Cielonos.MainGame.Characters;
|
||||
using DG.Tweening;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Characters.Inventory.Collections
|
||||
@@ -86,9 +85,9 @@ namespace Cielonos.MainGame.Characters.Inventory.Collections
|
||||
//.AddHitSound("LightAttackCriticalHit")
|
||||
.AddHitEvent((enemy, hitPosition) =>
|
||||
{
|
||||
slash.hitSm.PlayHitSound(hitPosition,
|
||||
/*slash.hitSm.PlayHitSound(hitPosition,
|
||||
slash.attackSm.attackValue.isCritical ? "LightAttackCriticalHit" : "LightAttackNormalHit");
|
||||
feedbackSc["Hit"].Play();
|
||||
feedbackSc["Hit"].Play();*/
|
||||
});
|
||||
|
||||
//Swing("LightAttackSwing", "Swing", swingForce);
|
||||
@@ -115,7 +114,7 @@ namespace Cielonos.MainGame.Characters.Inventory.Collections
|
||||
.SetTimeSubmodule<NormalArea>(1f)
|
||||
.SetHitSubmodule<NormalArea>();
|
||||
|
||||
slash.hitSm.AddHitEvent((_,_) => feedbackSc["Hit"].Play());
|
||||
//slash.hitSm.AddHitEvent((_,_) => feedbackSc["Hit"].Play());
|
||||
//Swing("GroundImpact", "GroundImpact", Vector3.down * 0.2f * (1 + Mathf.Log10(fallDamageMultiplier)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cielonos.MainGame.Effects.Feedback;
|
||||
using MoreMountains.Feedbacks;
|
||||
using SLSUtilities.Feedback;
|
||||
using SLSUtilities.FeelAssistance;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Characters.Inventory
|
||||
{
|
||||
public class FeedbackSubcontroller : SubcontrollerBase<ItemBase>
|
||||
{
|
||||
// === 旧系统(Feel)—— 保留向后兼容 ===
|
||||
public Dictionary<string, FeedbackUnit> feedbacks;
|
||||
public FeedbackUnit this[string feedbackName] => feedbacks.GetValueOrDefault(feedbackName, null);
|
||||
|
||||
// === 新系统(Feedback System)===
|
||||
public FeedbackDataCollection feedbackDataCollection;
|
||||
public FeedbackData this[string feedbackName] => GetFeedbackData(feedbackName);
|
||||
|
||||
private CharacterFeedbackTimeProvider _timeProvider;
|
||||
private readonly List<FeedbackPlayer> _activePlayers = new List<FeedbackPlayer>(8);
|
||||
@@ -97,6 +90,19 @@ namespace Cielonos.MainGame.Characters.Inventory
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按名称停止正在播放的 Feedback。
|
||||
/// </summary>
|
||||
public void StopFeedback(string feedbackName)
|
||||
{
|
||||
if (feedbackDataCollection == null) return;
|
||||
if (feedbackDataCollection.TryGet(feedbackName, out FeedbackData data))
|
||||
{
|
||||
StopFeedback(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 停止所有活跃的新系统播放器。
|
||||
/// </summary>
|
||||
@@ -111,18 +117,6 @@ namespace Cielonos.MainGame.Characters.Inventory
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// 旧系统驱动
|
||||
if (feedbacks != null)
|
||||
{
|
||||
foreach (var feedbackUnit in feedbacks.Values)
|
||||
{
|
||||
float timeScaleMultiplier = owner.player.selfTimeSm.TimeScale;
|
||||
feedbackUnit.feedback.ExternalTimeScale = timeScaleMultiplier;
|
||||
feedbackUnit.Update();
|
||||
}
|
||||
}
|
||||
|
||||
// 新系统驱动
|
||||
float dt = Time.deltaTime;
|
||||
for (int i = _activePlayers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
|
||||
@@ -73,8 +73,6 @@ namespace Cielonos.MainGame.Characters
|
||||
{
|
||||
base.Start();
|
||||
|
||||
feedbackSc["Prewarm"]?.Play();
|
||||
|
||||
inventorySc.equipmentSm.EquipMainWeapon(inventorySc.equipmentSm.preparedMainWeapons[0]);
|
||||
|
||||
for (int i = 0; i < inventorySc.backpack.supportEquipments.Count; i++)
|
||||
|
||||
@@ -1,18 +1,88 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.Feedback;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// AnimeBloom 反馈动作,通过 AnimeBloomShakeEvent 触发 AnimeBloomShaker。
|
||||
/// 默认驱动 intensity 曲线,可选启用 threshold/scatter/tint 的动画或固定值。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[FeedbackActionColor(1f, 0.6f, 0.8f)]
|
||||
public class BloomAction : PostprocessingActionBase
|
||||
{
|
||||
public override string DisplayName => "Anime Bloom";
|
||||
|
||||
[LabelText("强度曲线")]
|
||||
public FloatCurveChannel intensityCurve = FloatCurveChannel.CreateDefault(remapMax: 3f);
|
||||
|
||||
// ─── Threshold ───
|
||||
|
||||
[LabelText("修改阈值")]
|
||||
public bool modifyThreshold;
|
||||
|
||||
[HideIf("modifyThreshold")]
|
||||
[LabelText("阈值")]
|
||||
public float threshold = 1.1f;
|
||||
|
||||
[ShowIf("modifyThreshold")]
|
||||
[LabelText("阈值曲线")]
|
||||
public FloatCurveChannel thresholdCurve = FloatCurveChannel.CreateDefault(remapMax: 1.1f);
|
||||
|
||||
// ─── Scatter ───
|
||||
|
||||
[LabelText("修改扩散")]
|
||||
public bool modifyScatter;
|
||||
|
||||
[HideIf("modifyScatter")]
|
||||
[LabelText("扩散半径")]
|
||||
public float scatter = 0.7f;
|
||||
|
||||
[ShowIf("modifyScatter")]
|
||||
[LabelText("扩散曲线")]
|
||||
public FloatCurveChannel scatterCurve = FloatCurveChannel.CreateDefault(remapMax: 0.7f);
|
||||
|
||||
// ─── Tint ───
|
||||
|
||||
[LabelText("修改染色")]
|
||||
public bool modifyTint;
|
||||
|
||||
[HideIf("modifyTint")]
|
||||
[LabelText("泛光染色")]
|
||||
public Color tint = Color.white;
|
||||
|
||||
[ShowIf("modifyTint")]
|
||||
[LabelText("染色曲线")]
|
||||
public ColorCurveChannel tintCurve = ColorCurveChannel.CreateDefault();
|
||||
|
||||
protected override void TriggerEvent(FeedbackContext context)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
AnimeBloomShakeEvent.Trigger(
|
||||
context,
|
||||
intensityCurve,
|
||||
modifyThreshold,
|
||||
modifyThreshold ? thresholdCurve : default,
|
||||
threshold,
|
||||
modifyScatter,
|
||||
modifyScatter ? scatterCurve : default,
|
||||
scatter,
|
||||
modifyTint,
|
||||
modifyTint ? tintCurve : default,
|
||||
tint
|
||||
);
|
||||
}
|
||||
|
||||
protected override void StopEvent(FeedbackContext context)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
AnimeBloomShakeEvent.Trigger(context, intensityCurve, stop: true);
|
||||
}
|
||||
|
||||
public override bool Validate(out string error)
|
||||
{
|
||||
error = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,9 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
/// </summary>
|
||||
public float GetTimeScale(FeedbackTimeSettings settings)
|
||||
{
|
||||
if (settings == null || settings.timeScaleType == FeedbackTimeSettings.TimeScaleType.Unscaled) return 1f;
|
||||
if (_character == null ||
|
||||
settings == null ||
|
||||
settings.timeScaleType == FeedbackTimeSettings.TimeScaleType.Unscaled) return 1f;
|
||||
|
||||
float scale = 1f;
|
||||
|
||||
@@ -71,7 +73,9 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
/// </summary>
|
||||
public float GetDeltaTime(FeedbackTimeSettings settings)
|
||||
{
|
||||
return Time.unscaledDeltaTime * GetTimeScale(settings);
|
||||
if (_character == null) return Time.deltaTime;
|
||||
|
||||
return Time.deltaTime * GetTimeScale(settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
using System.Collections.Generic;
|
||||
using SLSUtilities.Feedback;
|
||||
using SLSUtilities.Rendering.PostProcessing;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// AnimeBloom 震动事件。由 BloomAction 触发,AnimeBloomShaker 监听。
|
||||
/// </summary>
|
||||
public struct AnimeBloomShakeEvent
|
||||
{
|
||||
private static event ShakeDelegate OnEvent;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void RuntimeInitialization() { OnEvent = null; }
|
||||
|
||||
public delegate void ShakeDelegate(
|
||||
FeedbackContext feedbackContext,
|
||||
FloatCurveChannel intensityCurve,
|
||||
bool modifyThreshold,
|
||||
FloatCurveChannel thresholdCurve,
|
||||
float threshold,
|
||||
bool modifyScatter,
|
||||
FloatCurveChannel scatterCurve,
|
||||
float scatter,
|
||||
bool modifyTint,
|
||||
ColorCurveChannel tintCurve,
|
||||
Color tint,
|
||||
bool stop
|
||||
);
|
||||
|
||||
public static void Register(ShakeDelegate callback) { OnEvent += callback; }
|
||||
public static void Unregister(ShakeDelegate callback) { OnEvent -= callback; }
|
||||
|
||||
public static void Trigger(
|
||||
FeedbackContext feedbackContext,
|
||||
FloatCurveChannel intensityCurve,
|
||||
bool modifyThreshold = false,
|
||||
FloatCurveChannel thresholdCurve = default,
|
||||
float threshold = 1.1f,
|
||||
bool modifyScatter = false,
|
||||
FloatCurveChannel scatterCurve = default,
|
||||
float scatter = 0.7f,
|
||||
bool modifyTint = false,
|
||||
ColorCurveChannel tintCurve = default,
|
||||
Color tint = default,
|
||||
bool stop = false)
|
||||
{
|
||||
OnEvent?.Invoke(feedbackContext, intensityCurve,
|
||||
modifyThreshold, thresholdCurve, threshold,
|
||||
modifyScatter, scatterCurve, scatter,
|
||||
modifyTint, tintCurve, tint,
|
||||
stop);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AnimeBloom 震动实例。
|
||||
/// </summary>
|
||||
public class AnimeBloomShakeInstance : ShakeInstanceBase
|
||||
{
|
||||
public readonly FloatCurveChannel intensityCurve;
|
||||
public readonly bool modifyThreshold;
|
||||
public readonly FloatCurveChannel thresholdCurve;
|
||||
public readonly float threshold;
|
||||
public readonly bool modifyScatter;
|
||||
public readonly FloatCurveChannel scatterCurve;
|
||||
public readonly float scatter;
|
||||
public readonly bool modifyTint;
|
||||
public readonly ColorCurveChannel tintCurve;
|
||||
public readonly Color tint;
|
||||
|
||||
public AnimeBloomShakeInstance(
|
||||
FeedbackContext feedbackContext,
|
||||
FloatCurveChannel intensityCurve,
|
||||
bool modifyThreshold,
|
||||
FloatCurveChannel thresholdCurve,
|
||||
float threshold,
|
||||
bool modifyScatter,
|
||||
FloatCurveChannel scatterCurve,
|
||||
float scatter,
|
||||
bool modifyTint,
|
||||
ColorCurveChannel tintCurve,
|
||||
Color tint)
|
||||
: base(feedbackContext.timeSettings, feedbackContext.player.TimeProvider, feedbackContext.duration)
|
||||
{
|
||||
this.intensityCurve = intensityCurve;
|
||||
this.modifyThreshold = modifyThreshold;
|
||||
this.thresholdCurve = thresholdCurve;
|
||||
this.threshold = threshold;
|
||||
this.modifyScatter = modifyScatter;
|
||||
this.scatterCurve = scatterCurve;
|
||||
this.scatter = scatter;
|
||||
this.modifyTint = modifyTint;
|
||||
this.tintCurve = tintCurve;
|
||||
this.tint = tint;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AnimeBloom 的震动聚合器。监听 AnimeBloomShakeEvent,驱动 AnimeBloom Volume 组件的参数动画。
|
||||
/// 默认驱动 intensity,可选驱动 threshold、scatter、tint。
|
||||
/// </summary>
|
||||
[AddComponentMenu("SLS Utilities/Feedback Shakers/Anime Bloom Shaker")]
|
||||
public class AnimeBloomShaker : MonoBehaviour
|
||||
{
|
||||
private AnimeBloom _component;
|
||||
private float _initialIntensity;
|
||||
private float _initialThreshold;
|
||||
private float _initialScatter;
|
||||
private Color _initialTint;
|
||||
private bool _resolved;
|
||||
|
||||
private readonly List<AnimeBloomShakeInstance> _activeShakes = new List<AnimeBloomShakeInstance>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_resolved = TryResolve();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
AnimeBloomShakeEvent.Register(OnShakeEvent);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
AnimeBloomShakeEvent.Unregister(OnShakeEvent);
|
||||
StopAll();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!_resolved || _activeShakes.Count == 0) return;
|
||||
|
||||
float additiveIntensity = 0f;
|
||||
float absoluteIntensity = 0f;
|
||||
bool hasAbsolute = false;
|
||||
|
||||
float latestThreshold = _initialThreshold;
|
||||
float latestScatter = _initialScatter;
|
||||
Color latestTint = _initialTint;
|
||||
bool hasThreshold = false;
|
||||
bool hasScatter = false;
|
||||
bool hasTint = false;
|
||||
|
||||
for (int i = _activeShakes.Count - 1; i >= 0; i--)
|
||||
{
|
||||
AnimeBloomShakeInstance shake = _activeShakes[i];
|
||||
shake.timer += shake.timeProvider.GetDeltaTime(shake.timeSettings);
|
||||
|
||||
float normalizedTime = shake.timer / shake.duration;
|
||||
|
||||
float curveValue = shake.intensityCurve.Evaluate(normalizedTime);
|
||||
if (shake.intensityCurve.relativeToInitial)
|
||||
additiveIntensity += curveValue;
|
||||
else
|
||||
{
|
||||
absoluteIntensity = curveValue;
|
||||
hasAbsolute = true;
|
||||
}
|
||||
|
||||
if (shake.modifyThreshold)
|
||||
{
|
||||
latestThreshold = shake.thresholdCurve.Evaluate(normalizedTime);
|
||||
hasThreshold = true;
|
||||
}
|
||||
|
||||
if (shake.modifyScatter)
|
||||
{
|
||||
latestScatter = shake.scatterCurve.Evaluate(normalizedTime);
|
||||
hasScatter = true;
|
||||
}
|
||||
|
||||
if (shake.modifyTint)
|
||||
{
|
||||
latestTint = shake.tintCurve.Evaluate(normalizedTime);
|
||||
hasTint = true;
|
||||
}
|
||||
|
||||
if (shake.IsFinished)
|
||||
{
|
||||
_activeShakes.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
float finalIntensity = hasAbsolute ? absoluteIntensity : _initialIntensity + additiveIntensity;
|
||||
_component.intensity.value = finalIntensity;
|
||||
|
||||
if (hasThreshold) _component.threshold.value = latestThreshold;
|
||||
if (hasScatter) _component.scatter.value = latestScatter;
|
||||
if (hasTint) _component.tint.value = latestTint;
|
||||
|
||||
if (_activeShakes.Count == 0)
|
||||
{
|
||||
Restore();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnShakeEvent(
|
||||
FeedbackContext feedbackContext,
|
||||
FloatCurveChannel intensityCurve,
|
||||
bool modifyThreshold,
|
||||
FloatCurveChannel thresholdCurve,
|
||||
float threshold,
|
||||
bool modifyScatter,
|
||||
FloatCurveChannel scatterCurve,
|
||||
float scatter,
|
||||
bool modifyTint,
|
||||
ColorCurveChannel tintCurve,
|
||||
Color tint,
|
||||
bool stop)
|
||||
{
|
||||
if (stop) { StopAll(); return; }
|
||||
if (!_resolved) _resolved = TryResolve();
|
||||
if (!_resolved) return;
|
||||
|
||||
var instance = new AnimeBloomShakeInstance(
|
||||
feedbackContext,
|
||||
intensityCurve,
|
||||
modifyThreshold, thresholdCurve, threshold,
|
||||
modifyScatter, scatterCurve, scatter,
|
||||
modifyTint, tintCurve, tint
|
||||
);
|
||||
_activeShakes.Add(instance);
|
||||
}
|
||||
|
||||
private bool TryResolve()
|
||||
{
|
||||
if (_component != null) return true;
|
||||
if (PostProcessingManager.Instance == null) return false;
|
||||
if (!PostProcessingManager.Instance.GetVolumeComponent(out _component)) return false;
|
||||
|
||||
_initialIntensity = _component.intensity.value;
|
||||
_initialThreshold = _component.threshold.value;
|
||||
_initialScatter = _component.scatter.value;
|
||||
_initialTint = _component.tint.value;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Restore()
|
||||
{
|
||||
if (!_resolved) return;
|
||||
_component.intensity.value = _initialIntensity;
|
||||
_component.threshold.value = _initialThreshold;
|
||||
_component.scatter.value = _initialScatter;
|
||||
_component.tint.value = _initialTint;
|
||||
}
|
||||
|
||||
private void StopAll()
|
||||
{
|
||||
_activeShakes.Clear();
|
||||
Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4696ff05092b2b74bb7009fb8e94681e
|
||||
Reference in New Issue
Block a user