chore: initial commit

This commit is contained in:
2026-05-08 11:04:00 +08:00
commit f55d2a57c3
6278 changed files with 866081 additions and 0 deletions

View File

@@ -0,0 +1,165 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
#if MM_CINEMACHINE
using Cinemachine;
#elif MM_CINEMACHINE3
using Unity.Cinemachine;
#endif
using UnityEngine.Scripting.APIUpdating;
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
#if MM_CINEMACHINE || MM_CINEMACHINE3
[FeedbackPath("Camera/Cinemachine Impulse")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.Cinemachine")]
[FeedbackHelp("This feedback lets you trigger a Cinemachine Impulse event. You'll need a Cinemachine Impulse Listener on your camera for this to work.")]
public class MMF_CinemachineImpulse : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
public override bool HasCustomInspectors => true;
public override bool HasAutomaticShakerSetup => true;
#endif
public override bool HasRandomness => true;
#if MM_CINEMACHINE || MM_CINEMACHINE3
[MMFInspectorGroup("Cinemachine Impulse", true, 28)]
/// the impulse definition to broadcast
[Tooltip("the impulse definition to broadcast")]
public CinemachineImpulseDefinition m_ImpulseDefinition = new CinemachineImpulseDefinition();
/// the velocity to apply to the impulse shake
[Tooltip("the velocity to apply to the impulse shake")]
public Vector3 Velocity;
/// whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback
[Tooltip("whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback")]
public bool ClearImpulseOnStop = false;
#endif
[Header("Gizmos")]
/// whether or not to draw gizmos to showcase the various distance properties of this feedback, when applicable. Dissipation distance in blue, impact radius in yellow.
[Tooltip("whether or not to draw gizmos to showcase the various distance properties of this feedback, when applicable. Dissipation distance in blue, impact radius in yellow.")]
public bool DrawGizmos = false;
#if MM_CINEMACHINE
/// the duration of this feedback is the duration of the impulse
public override float FeedbackDuration { get { return m_ImpulseDefinition != null ? m_ImpulseDefinition.m_TimeEnvelope.Duration : 0f; } }
#elif MM_CINEMACHINE3
/// the duration of this feedback is the duration of the impulse
public override float FeedbackDuration { get { return m_ImpulseDefinition != null ? m_ImpulseDefinition.TimeEnvelope.Duration : 0f; } }
#endif
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE || MM_CINEMACHINE3
CinemachineImpulseManager.Instance.IgnoreTimeScale = !InScaledTimescaleMode;
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
m_ImpulseDefinition.CreateEvent(position, Velocity * intensityMultiplier);
#endif
}
/// <summary>
/// Stops the animation if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
#if MM_CINEMACHINE || MM_CINEMACHINE3
if (!Active || !FeedbackTypeAuthorized || !ClearImpulseOnStop)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
CinemachineImpulseManager.Instance.Clear();
#endif
}
/// <summary>
/// When adding the feedback we initialize its cinemachine impulse definition
/// </summary>
public override void OnAddFeedback()
{
#if MM_CINEMACHINE
// sets the feedback properties
if (this.m_ImpulseDefinition == null)
{
this.m_ImpulseDefinition = new CinemachineImpulseDefinition();
}
this.m_ImpulseDefinition.m_RawSignal = Resources.Load<NoiseSettings>("MM_6D_Shake");
this.Velocity = new Vector3(5f, 5f, 5f);
#elif MM_CINEMACHINE3
// sets the feedback properties
if (this.m_ImpulseDefinition == null)
{
this.m_ImpulseDefinition = new CinemachineImpulseDefinition();
}
this.m_ImpulseDefinition.RawSignal = Resources.Load<NoiseSettings>("MM_6D_Shake");
this.Velocity = new Vector3(5f, 5f, 5f);
#endif
}
/// <summary>
/// Draws dissipation distance and impact distance gizmos if necessary
/// </summary>
public override void OnDrawGizmosSelectedHandler()
{
if (!DrawGizmos)
{
return;
}
#if MM_CINEMACHINE
{
if ( (this.m_ImpulseDefinition.m_ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Dissipating)
|| (this.m_ImpulseDefinition.m_ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Propagating)
|| (this.m_ImpulseDefinition.m_ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Legacy) )
{
Gizmos.color = MMColors.Aqua;
Gizmos.DrawWireSphere(Owner.transform.position, this.m_ImpulseDefinition.m_DissipationDistance);
}
if (this.m_ImpulseDefinition.m_ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Legacy)
{
Gizmos.color = MMColors.ReunoYellow;
Gizmos.DrawWireSphere(Owner.transform.position, this.m_ImpulseDefinition.m_ImpactRadius);
}
}
#elif MM_CINEMACHINE3
if (this.m_ImpulseDefinition != null)
{
if ( (this.m_ImpulseDefinition.ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Dissipating)
|| (this.m_ImpulseDefinition.ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Propagating)
|| (this.m_ImpulseDefinition.ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Legacy) )
{
Gizmos.color = MMColors.Aqua;
Gizmos.DrawWireSphere(Owner.transform.position, this.m_ImpulseDefinition.DissipationDistance);
}
if (this.m_ImpulseDefinition.ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Legacy)
{
Gizmos.color = MMColors.ReunoYellow;
Gizmos.DrawWireSphere(Owner.transform.position, this.m_ImpulseDefinition.ImpactRadius);
}
}
#endif
}
/// <summary>
/// Automatically adds a Cinemachine Impulse Listener to the camera
/// </summary>
public override void AutomaticShakerSetup()
{
MMCinemachineHelpers.AutomaticCinemachineShakersSetup(Owner, "CinemachineImpulse");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ee48f409bf2e3e4baf85ca77d2ca0af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#elif MM_CINEMACHINE3
using Unity.Cinemachine;
#endif
using UnityEngine.Scripting.APIUpdating;
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
#if MM_CINEMACHINE || MM_CINEMACHINE3
[FeedbackPath("Camera/Cinemachine Impulse Clear")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.Cinemachine")]
[FeedbackHelp("This feedback lets you trigger a Cinemachine Impulse clear, stopping instantly any impulse that may be playing.")]
public class MMF_CinemachineImpulseClear : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
#endif
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE || MM_CINEMACHINE3
CinemachineImpulseManager.Instance.Clear();
#endif
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b2362762ee575ad4ab16bb938247878b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#elif MM_CINEMACHINE3
using Unity.Cinemachine;
#endif
using UnityEngine.Scripting.APIUpdating;
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
#if MM_CINEMACHINE || MM_CINEMACHINE3
[FeedbackPath("Camera/Cinemachine Impulse Source")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.Cinemachine")]
[FeedbackHelp("This feedback lets you generate an impulse on a Cinemachine Impulse source. You'll need a Cinemachine Impulse Listener on your camera for this to work.")]
public class MMF_CinemachineImpulseSource : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
#if MM_CINEMACHINE || MM_CINEMACHINE3
public override bool EvaluateRequiresSetup() { return (ImpulseSource == null); }
public override string RequiredTargetText { get { return ImpulseSource != null ? ImpulseSource.name : ""; } }
#endif
public override string RequiresSetupText { get { return "This feedback requires that an ImpulseSource be set to be able to work properly. You can set one below."; } }
#endif
[MMFInspectorGroup("Cinemachine Impulse Source", true, 28)]
/// the velocity to apply to the impulse shake
[Tooltip("the velocity to apply to the impulse shake")]
public Vector3 Velocity = new Vector3(1f,1f,1f);
#if MM_CINEMACHINE || MM_CINEMACHINE3
/// the impulse definition to broadcast
[Tooltip("the impulse definition to broadcast")]
public CinemachineImpulseSource ImpulseSource;
public override bool HasAutomatedTargetAcquisition => true;
protected override void AutomateTargetAcquisition() => ImpulseSource = FindAutomatedTarget<CinemachineImpulseSource>();
#endif
/// whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback
[Tooltip("whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback")]
public bool ClearImpulseOnStop = false;
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE || MM_CINEMACHINE3
if (ImpulseSource != null)
{
ImpulseSource.GenerateImpulse(Velocity);
}
#endif
}
/// <summary>
/// Stops the animation if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized || !ClearImpulseOnStop)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
#if MM_CINEMACHINE || MM_CINEMACHINE3
CinemachineImpulseManager.Instance.Clear();
#endif
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE || MM_CINEMACHINE3
CinemachineImpulseManager.Instance.Clear();
#endif
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f6892e7c981ffa45ad8e24c33bdac4e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,150 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#elif MM_CINEMACHINE3
using Unity.Cinemachine;
#endif
using UnityEngine.Scripting.APIUpdating;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback will let you change the priorities of your cameras.
/// It requires a bit of setup : adding a MMCinemachinePriorityListener to your different cameras, with unique Channel values on them.
/// Optionally, you can add a MMCinemachinePriorityBrainListener on your Cinemachine Brain to handle different transition types and durations.
/// Then all you have to do is pick a channel and a new priority on your feedback, and play it. Magic transition!
/// </summary>
[AddComponentMenu("")]
#if MM_CINEMACHINE || MM_CINEMACHINE3
[FeedbackPath("Camera/Cinemachine Transition")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.Cinemachine")]
[FeedbackHelp("This feedback will let you change the priorities of your cameras. It requires a bit of setup : " +
"adding a MMCinemachinePriorityListener to your different cameras, with unique Channel values on them. " +
"Optionally, you can add a MMCinemachinePriorityBrainListener on your Cinemachine Brain to handle different transition types and durations. " +
"Then all you have to do is pick a channel and a new priority on your feedback, and play it. Magic transition!")]
public class MMF_CinemachineTransition : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
public enum Modes { Event, Binding }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
public override string RequiredTargetText => RequiredChannelText;
#endif
#if MM_CINEMACHINE
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(BlendDefintion.m_Time); } set { BlendDefintion.m_Time = value; } }
#elif MM_CINEMACHINE3
public override float FeedbackDuration { get { return ApplyTimeMultiplier(BlendDefintion.Time); } set { BlendDefintion.Time = value; } }
#endif
#if MM_CINEMACHINE || MM_CINEMACHINE3
public override bool HasAutomatedTargetAcquisition => true;
#endif
#if MM_CINEMACHINE
protected override void AutomateTargetAcquisition() => TargetVirtualCamera = FindAutomatedTarget<CinemachineVirtualCamera>();
#elif MM_CINEMACHINE3
protected override void AutomateTargetAcquisition() => TargetCinemachineCamera = FindAutomatedTarget<CinemachineCamera>();
#endif
public override bool HasChannel => true;
[MMFInspectorGroup("Cinemachine Transition", true, 52)]
/// the selected mode (either via event, or via direct binding of a specific camera)
[Tooltip("the selected mode (either via event, or via direct binding of a specific camera)")]
public Modes Mode = Modes.Event;
#if MM_CINEMACHINE
/// the virtual camera to target
[Tooltip("the virtual camera to target")]
[MMFEnumCondition("Mode", (int)Modes.Binding)]
public CinemachineVirtualCamera TargetVirtualCamera;
#elif MM_CINEMACHINE3
/// the Cinemachine camera to target
[Tooltip("the Cinemachine camera to target")]
[MMFEnumCondition("Mode", (int)Modes.Binding)]
public CinemachineCamera TargetCinemachineCamera;
#endif
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetValuesAfterTransition = true;
[Header("Priority")]
/// the new priority to apply to all virtual cameras on the specified channel
[Tooltip("the new priority to apply to all virtual cameras on the specified channel")]
public int NewPriority = 10;
/// whether or not to force all virtual cameras on other channels to reset their priority to zero
[Tooltip("whether or not to force all virtual cameras on other channels to reset their priority to zero")]
public bool ForceMaxPriority = true;
/// whether or not to apply a new blend
[Tooltip("whether or not to apply a new blend")]
public bool ForceTransition = false;
#if MM_CINEMACHINE || MM_CINEMACHINE3
/// the new blend definition to apply
[Tooltip("the new blend definition to apply")]
[MMFCondition("ForceTransition", true)]
public CinemachineBlendDefinition BlendDefintion;
protected CinemachineBlendDefinition _tempBlend;
#endif
/// <summary>
/// Triggers a priority change on listening virtual cameras
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE || MM_CINEMACHINE3
_tempBlend = BlendDefintion;
#endif
#if MM_CINEMACHINE
_tempBlend.m_Time = FeedbackDuration;
#elif MM_CINEMACHINE3
_tempBlend.Time = FeedbackDuration;
#endif
#if MM_CINEMACHINE || MM_CINEMACHINE3
if (Mode == Modes.Event)
{
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, NewPriority, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode);
}
else
{
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, 0, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode);
SetPriority(NewPriority);
}
#endif
}
protected virtual void SetPriority(int newPriority)
{
#if MM_CINEMACHINE
TargetVirtualCamera.Priority = newPriority;
#elif MM_CINEMACHINE3
PrioritySettings prioritySettings = TargetCinemachineCamera.Priority;
prioritySettings.Value = newPriority;
TargetCinemachineCamera.Priority = prioritySettings;
#endif
}
/// <summary>
/// On restore, we restore our initial state
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE || MM_CINEMACHINE3
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, 0, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode, true);
#endif
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2838524600839f84591c1d8a457b2176
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: