Movement/State/ToggleState.cs

26 lines
559 B
C#

using System;
using UnityEngine;
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 Action<bool> OnToggleStateChanged { get; set; } = null;
}
}