53 lines
2.1 KiB
C#
53 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using Lean.Pool;
|
|
using MoreMountains.Feedbacks;
|
|
using MoreMountains.FeedbacksForThirdParty;
|
|
using SLSUtilities.FeelAssistance;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
{
|
|
public partial class FeedbackSubcontroller : SubcontrollerBase<CharacterBase>
|
|
{
|
|
public Dictionary<string, FeedbackUnit> feedbacks;
|
|
public FeedbackUnit this[string feedbackName] => feedbacks.GetValueOrDefault(feedbackName, null);
|
|
|
|
private void Update()
|
|
{
|
|
if (feedbacks == null) return;
|
|
|
|
foreach (var feedbackUnit in feedbacks.Values)
|
|
{
|
|
float timeScaleMultiplier = owner.selfTimeSm.TimeScale;
|
|
feedbackUnit.feedback.ExternalTimeScale = timeScaleMultiplier;
|
|
feedbackUnit.Update();
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class FeedbackSubcontroller
|
|
{
|
|
protected void Swing(Vector3 swingRotation, float rotationDuration, Vector3 swingPosition, float positionDuration)
|
|
{
|
|
MMF_Player swing = LeanPool.Spawn(MainGameBaseCollection.Instance.feedbackCollection["Swing"]).GetComponent<MMF_Player>();
|
|
|
|
MMF_CinemachineRotation cinemachineRotation = swing.GetFeedbackOfType<MMF_CinemachineRotation>();
|
|
if (cinemachineRotation != null)
|
|
{
|
|
cinemachineRotation.RotationAmplitude = swingRotation != default ? swingRotation : Vector3.zero;
|
|
cinemachineRotation.Duration = rotationDuration;
|
|
}
|
|
|
|
MMF_CinemachinePosition cinemachinePosition = swing.GetFeedbackOfType<MMF_CinemachinePosition>();
|
|
if (cinemachinePosition != null)
|
|
{
|
|
cinemachinePosition.PositionAmplitude = swingPosition != default ? swingPosition : Vector3.zero;
|
|
cinemachinePosition.Duration = positionDuration;
|
|
}
|
|
|
|
swing.Events.OnComplete.RemoveAllListeners();
|
|
swing.Events.OnComplete.AddListener(()=> LeanPool.Despawn(swing.gameObject));
|
|
swing.PlayFeedbacks();
|
|
}
|
|
}
|
|
} |