架构大更

This commit is contained in:
SoulliesOfficial
2026-03-20 11:56:50 -04:00
parent e60ef64d01
commit d09b58fd80
3663 changed files with 15232012 additions and 105579 deletions

View File

@@ -1,3 +1,3 @@
{
"reference": "GUID:4a1cb1490dc4df8409b2580d6b44e75e"
"reference": "GUID:4a1cb1490dc4df8409b2580d6b44e75e"
}

View File

@@ -1,62 +1,65 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
using UnityEngine;
#if MM_POSTPROCESSING
using UnityEngine.Rendering.PostProcessing;
#endif
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this class to a Camera with a depth of field post processing and it'll be able to "shake" its values by getting events
/// Add this class to a Camera with a depth of field post processing and it'll be able to "shake" its values by getting
/// events
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MM Depth Of Field Shaker")]
#if MM_POSTPROCESSING
#if MM_POSTPROCESSING
[RequireComponent(typeof(PostProcessVolume))]
#endif
public class MMDepthOfFieldShaker : MMShaker
{
/// whether or not to add to the initial value
public bool RelativeValues = true;
#endif
public class MMDepthOfFieldShaker : MMShaker
{
/// whether or not to add to the initial value
public bool RelativeValues = true;
[MMInspectorGroup("Focus Distance", true, 49)]
/// the curve used to animate the focus distance value on
[Tooltip("the curve used to animate the focus distance value on")]
public AnimationCurve ShakeFocusDistance = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapFocusDistanceZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapFocusDistanceOne = 3f;
[MMInspectorGroup("Focus Distance", true, 49)]
/// the curve used to animate the focus distance value on
[Tooltip("the curve used to animate the focus distance value on")]
public AnimationCurve ShakeFocusDistance = new(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
[MMInspectorGroup("Aperture", true, 50)]
/// the curve used to animate the aperture value on
[Tooltip("the curve used to animate the aperture value on")]
public AnimationCurve ShakeAperture = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0.1f, 32f)]
public float RemapApertureZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0.1f, 32f)]
public float RemapApertureOne = 0f;
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapFocusDistanceZero;
[MMInspectorGroup("Focal Length", true, 51)]
/// the curve used to animate the focal length value on
[Tooltip("the curve used to animate the focal length value on")]
public AnimationCurve ShakeFocalLength = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0f, 300f)]
public float RemapFocalLengthZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0f, 300f)]
public float RemapFocalLengthOne = 0f;
#if MM_POSTPROCESSING
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapFocusDistanceOne = 3f;
[MMInspectorGroup("Aperture", true, 50)]
/// the curve used to animate the aperture value on
[Tooltip("the curve used to animate the aperture value on")]
public AnimationCurve ShakeAperture = new(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")] [Range(0.1f, 32f)]
public float RemapApertureZero;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")] [Range(0.1f, 32f)]
public float RemapApertureOne;
[MMInspectorGroup("Focal Length", true, 51)]
/// the curve used to animate the focal length value on
[Tooltip("the curve used to animate the focal length value on")]
public AnimationCurve ShakeFocalLength = new(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")] [Range(0f, 300f)]
public float RemapFocalLengthZero;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")] [Range(0f, 300f)]
public float RemapFocalLengthOne;
#if MM_POSTPROCESSING
protected PostProcessVolume _volume;
protected DepthOfField _depthOfField;
protected float _initialFocusDistance;
@@ -89,13 +92,16 @@ namespace MoreMountains.FeedbacksForThirdParty
/// </summary>
protected override void Shake()
{
float newFocusDistance = ShakeFloat(ShakeFocusDistance, RemapFocusDistanceZero, RemapFocusDistanceOne, RelativeValues, _initialFocusDistance);
float newFocusDistance =
ShakeFloat(ShakeFocusDistance, RemapFocusDistanceZero, RemapFocusDistanceOne, RelativeValues, _initialFocusDistance);
_depthOfField.focusDistance.Override(newFocusDistance);
float newAperture = ShakeFloat(ShakeAperture, RemapApertureZero, RemapApertureOne, RelativeValues, _initialAperture);
float newAperture =
ShakeFloat(ShakeAperture, RemapApertureZero, RemapApertureOne, RelativeValues, _initialAperture);
_depthOfField.aperture.Override(newAperture);
float newFocalLength = ShakeFloat(ShakeFocalLength, RemapFocalLengthZero, RemapFocalLengthOne, RelativeValues, _initialFocalLength);
float newFocalLength =
ShakeFloat(ShakeFocalLength, RemapFocalLengthZero, RemapFocalLengthOne, RelativeValues, _initialFocalLength);
_depthOfField.focalLength.Override(newFocalLength);
}
@@ -130,8 +136,10 @@ namespace MoreMountains.FeedbacksForThirdParty
AnimationCurve aperture, float remapApertureMin, float remapApertureMax,
AnimationCurve focalLength, float remapFocalLengthMin, float remapFocalLengthMax,
bool relativeValues = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake =
true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop =
false, bool restore = false)
{
if (!CheckEventAllowed(channelData) || (!Interruptible && Shaking))
{
@@ -243,37 +251,57 @@ namespace MoreMountains.FeedbacksForThirdParty
base.StopListening();
MMDepthOfFieldShakeEvent.Unregister(OnDepthOfFieldShakeEvent);
}
#endif
}
#endif
}
/// <summary>
/// An event used to trigger vignette shakes
/// An event used to trigger vignette shakes
/// </summary>
public struct MMDepthOfFieldShakeEvent
{
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
{
private static event Delegate OnEvent;
public delegate void Delegate(AnimationCurve focusDistance, float duration, float remapFocusDistanceMin, float remapFocusDistanceMax,
AnimationCurve aperture, float remapApertureMin, float remapApertureMax,
AnimationCurve focalLength, float remapFocalLengthMin, float remapFocalLengthMax,
bool relativeValues = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false);
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void RuntimeInitialization()
{
OnEvent = null;
}
static public void Trigger(AnimationCurve focusDistance, float duration, float remapFocusDistanceMin, float remapFocusDistanceMax,
AnimationCurve aperture, float remapApertureMin, float remapApertureMax,
AnimationCurve focalLength, float remapFocalLengthMin, float remapFocalLengthMax,
bool relativeValues = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
OnEvent?.Invoke(focusDistance, duration, remapFocusDistanceMin, remapFocusDistanceMax,
aperture, remapApertureMin, remapApertureMax,
focalLength, remapFocalLengthMin, remapFocalLengthMax, relativeValues,
feedbacksIntensity, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
}
}
public static void Register(Delegate callback)
{
OnEvent += callback;
}
public static void Unregister(Delegate callback)
{
OnEvent -= callback;
}
public delegate void Delegate(AnimationCurve focusDistance, float duration, float remapFocusDistanceMin,
float remapFocusDistanceMax,
AnimationCurve aperture, float remapApertureMin, float remapApertureMax,
AnimationCurve focalLength, float remapFocalLengthMin, float remapFocalLengthMax,
bool relativeValues = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true,
bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false,
bool restore = false);
public static void Trigger(AnimationCurve focusDistance, float duration, float remapFocusDistanceMin,
float remapFocusDistanceMax,
AnimationCurve aperture, float remapApertureMin, float remapApertureMax,
AnimationCurve focalLength, float remapFocalLengthMin, float remapFocalLengthMax,
bool relativeValues = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true,
bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false,
bool restore = false)
{
OnEvent?.Invoke(focusDistance, duration, remapFocusDistanceMin, remapFocusDistanceMax,
aperture, remapApertureMin, remapApertureMax,
focalLength, remapFocalLengthMin, remapFocalLengthMax, relativeValues,
feedbacksIntensity, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake,
forwardDirection, timescaleMode, stop, restore);
}
}
}