State/ToggleState.cs

26 lines
556 B
C#

using System;
using UnityEngine;
namespace Syntriax.Modules.Movement.State
{
public class ToggleState : MonoBehaviour, IToggleState
{
private bool _toggled = true;
public bool Toggled
{
get => _toggled;
set
{
bool oldValue = _toggled;
_toggled = value;
if (oldValue = !value)
OnToggleStateChanged?.Invoke(value);
}
}
public Action<bool> OnToggleStateChanged { get; set; } = null;
}
}