狗屎Minimax坏我代码
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// 摄像机方向影响设置,嵌入到摄像机类 Action 中。
|
||||
/// 控制最终偏移/振幅是否受摄像机方向和角色朝向影响。
|
||||
/// 此类为可扩展设计:新增字段不会导致已有序列化数据重置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CameraDirectionSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否将偏移从本地空间转换到摄像机方向空间。
|
||||
/// 开启后,定义的振幅向量会根据摄像机的朝向进行旋转。
|
||||
/// </summary>
|
||||
[LabelText("Affected by Camera Direction")]
|
||||
[Tooltip("将偏移从本地空间转换到摄像机方向空间")]
|
||||
public bool affectedByCameraDirection;
|
||||
|
||||
/// <summary>
|
||||
/// 是否将偏移从本地空间转换到角色朝向空间。
|
||||
/// 开启后,定义的振幅向量会根据 owner(角色)的 forward 进行旋转。
|
||||
/// </summary>
|
||||
[LabelText("Affected by Character Direction")]
|
||||
[Tooltip("将偏移从本地空间转换到角色朝向空间")]
|
||||
public bool affectedByCharacterDirection;
|
||||
|
||||
// === 以下区域留给未来扩展 ===
|
||||
// 新增字段时请在此区域添加,并提供合理的默认值,
|
||||
// 以确保已有序列化资产不会被重置。
|
||||
// 例如:
|
||||
// public bool affectedByMovementDirection;
|
||||
// public float directionBlendFactor = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// 将给定的本地空间向量根据当前设置转换到世界空间。
|
||||
/// 如果两个方向都开启,角色方向优先。
|
||||
/// </summary>
|
||||
/// <param name="localAmplitude">本地空间下的振幅向量</param>
|
||||
/// <param name="ownerTransform">角色 Transform(可能为 null)</param>
|
||||
/// <returns>经方向变换后的振幅向量</returns>
|
||||
public Vector3 TransformAmplitude(Vector3 localAmplitude, Transform ownerTransform)
|
||||
{
|
||||
if (affectedByCharacterDirection && ownerTransform != null)
|
||||
{
|
||||
return ownerTransform.TransformDirection(localAmplitude);
|
||||
}
|
||||
|
||||
if (affectedByCameraDirection)
|
||||
{
|
||||
Camera mainCamera = MainGameManager.Instance.player.viewSc.playerCamera;
|
||||
if (mainCamera != null)
|
||||
{
|
||||
return mainCamera.transform.TransformDirection(localAmplitude);
|
||||
}
|
||||
}
|
||||
|
||||
return localAmplitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbd6096fecc72b7448c9314ed8140726
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.Feedback;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// 摄像机视野角(FOV)反馈动作,通过 CameraFovShakeEvent 触发 CameraFovShaker。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[FeedbackActionColor(0.2f, 0.8f, 0.9f)]
|
||||
public class CameraFieldOfViewAction : CinemachineActionBase
|
||||
{
|
||||
public override string DisplayName => "Camera Field of View";
|
||||
|
||||
[TitleGroup("FOV设置")]
|
||||
[LabelText("FOV曲线")]
|
||||
public FloatCurveChannel fovCurve = FloatCurveChannel.CreateDefault(remapMax: 10f);
|
||||
|
||||
protected override void TriggerEvent(FeedbackContext context)
|
||||
{
|
||||
CameraFovShakeEvent.Trigger(context, fovCurve);
|
||||
}
|
||||
|
||||
protected override void StopEvent(FeedbackContext context)
|
||||
{
|
||||
CameraFovShakeEvent.Trigger(context, fovCurve, true);
|
||||
}
|
||||
|
||||
public override bool Validate(out string error)
|
||||
{
|
||||
if (!fovCurve.active)
|
||||
{
|
||||
error = "FOV curve is not enabled.";
|
||||
return false;
|
||||
}
|
||||
error = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b01df3a292fc2748ab56454e289de8f
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.Feedback;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// 摄像机位移震动反馈,通过 CameraPositionShakeEvent 触发 CinemachinePositionShaker。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[FeedbackActionColor(0.4f, 0.8f, 0.4f)]
|
||||
public class CameraPositionShakeAction : CinemachineActionBase
|
||||
{
|
||||
public override string DisplayName => "Camera Position Shake";
|
||||
|
||||
[TitleGroup("位移震动设置")]
|
||||
[LabelText("震动曲线")]
|
||||
public FloatCurveChannel intensityCurve = FloatCurveChannel.CreateDefault();
|
||||
|
||||
[TitleGroup("位移震动设置")]
|
||||
[LabelText("振幅")]
|
||||
public Vector3 amplitude = new Vector3(0.5f, 0.5f, 0f);
|
||||
|
||||
[TitleGroup("方向设置")]
|
||||
public CameraDirectionSettings directionSettings = new CameraDirectionSettings();
|
||||
|
||||
[TitleGroup("距离衰减")]
|
||||
[LabelText("启用衰减")]
|
||||
public bool useAttenuation;
|
||||
|
||||
[ShowIf("useAttenuation")]
|
||||
[LabelText("衰减范围")]
|
||||
public float attenuationRange = 50f;
|
||||
|
||||
[ShowIf("useAttenuation")]
|
||||
[LabelText("衰减曲线")]
|
||||
public AnimationCurve attenuationCurve = new AnimationCurve(
|
||||
new Keyframe(0f, 1f),
|
||||
new Keyframe(1f, 0f)
|
||||
);
|
||||
|
||||
protected override void TriggerEvent(FeedbackContext context)
|
||||
{
|
||||
Vector3 finalAmplitude = directionSettings.TransformAmplitude(amplitude, context.owner);
|
||||
float intensityMultiplier = ComputeAttenuation(context);
|
||||
CameraRotationShakeEvent.Trigger(context, intensityCurve, finalAmplitude * intensityMultiplier);
|
||||
}
|
||||
|
||||
protected override void StopEvent(FeedbackContext context)
|
||||
{
|
||||
CameraPositionShakeEvent.Trigger(context, intensityCurve, Vector3.zero, true);
|
||||
}
|
||||
|
||||
private float ComputeAttenuation(FeedbackContext context)
|
||||
{
|
||||
if (!useAttenuation || context.owner == null) return 1f;
|
||||
|
||||
Camera mainCamera = Camera.main;
|
||||
if (mainCamera == null) return 1f;
|
||||
|
||||
float distance = Vector3.Distance(context.owner.position, mainCamera.transform.position);
|
||||
float normalizedDistance = Mathf.Clamp01(distance / attenuationRange);
|
||||
return attenuationCurve.Evaluate(normalizedDistance);
|
||||
}
|
||||
|
||||
public override bool Validate(out string error)
|
||||
{
|
||||
if (!intensityCurve.active)
|
||||
{
|
||||
error = "Intensity curve is not enabled.";
|
||||
return false;
|
||||
}
|
||||
error = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8630ea3ff64b8914191a50988d94d665
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.Feedback;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// 摄像机旋转震动反馈,通过 CameraRotationShakeEvent 触发 CinemachineRotationShaker。
|
||||
/// X/Y 作用于 FollowTarget 旋转,Z 作用于 Dutch 倾斜。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[FeedbackActionColor(0.3f, 0.7f, 0.3f)]
|
||||
public class CameraRotationShakeAction : CinemachineActionBase
|
||||
{
|
||||
public override string DisplayName => "Camera Rotation Shake";
|
||||
|
||||
public Vector3 amplitude;
|
||||
|
||||
[LabelText("X轴曲线")]
|
||||
public FloatCurveChannel intensityCurve = FloatCurveChannel.CreateDefault(remapMax: 5f);
|
||||
|
||||
public CameraDirectionSettings directionSettings = new CameraDirectionSettings();
|
||||
|
||||
[TitleGroup("距离衰减")]
|
||||
[LabelText("启用衰减")]
|
||||
public bool useAttenuation;
|
||||
|
||||
[ShowIf("useAttenuation")]
|
||||
[LabelText("衰减范围")]
|
||||
public float attenuationRange = 50f;
|
||||
|
||||
[ShowIf("useAttenuation")]
|
||||
[LabelText("衰减曲线")]
|
||||
public AnimationCurve attenuationCurve = new AnimationCurve(
|
||||
new Keyframe(0f, 1f),
|
||||
new Keyframe(1f, 0f)
|
||||
);
|
||||
|
||||
protected override void TriggerEvent(FeedbackContext context)
|
||||
{
|
||||
Vector3 finalAmplitude = directionSettings.TransformAmplitude(amplitude, context.owner);
|
||||
float intensityMultiplier = ComputeAttenuation(context);
|
||||
CameraRotationShakeEvent.Trigger(context, intensityCurve, finalAmplitude * intensityMultiplier);
|
||||
}
|
||||
|
||||
protected override void StopEvent(FeedbackContext context)
|
||||
{
|
||||
CameraRotationShakeEvent.Trigger(context, intensityCurve, Vector3.zero, true);
|
||||
}
|
||||
|
||||
private float ComputeAttenuation(FeedbackContext context)
|
||||
{
|
||||
if (!useAttenuation || context.owner == null) return 1f;
|
||||
|
||||
Camera mainCamera = Camera.main;
|
||||
if (mainCamera == null) return 1f;
|
||||
|
||||
float distance = Vector3.Distance(context.owner.position, mainCamera.transform.position);
|
||||
float normalizedDistance = Mathf.Clamp01(distance / attenuationRange);
|
||||
return attenuationCurve.Evaluate(normalizedDistance);
|
||||
}
|
||||
|
||||
public override bool Validate(out string error)
|
||||
{
|
||||
error = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33f1efd4ae9710e46bcd50df76f19c8e
|
||||
Reference in New Issue
Block a user