Movement/State/ToggleState.cs

26 lines
603 B
C#

using UnityEngine;
using UnityEngine.Events;
namespace Syntriax.Modules.Movement.State
{
public class ToggleState : MonoBehaviour, IToggleState
{
private bool _enabled = true;
public bool Toggled
{
get => _enabled;
set
{
bool isNewValue = _enabled != value;
_enabled = value;
if (isNewValue)
OnToggleStateChanged.Invoke(value);
}
}
public UnityEvent<bool> OnToggleStateChanged { get; protected set; } = new UnityEvent<bool>();
}
}