Trigger/Runtime/TriggerBase.cs

28 lines
742 B
C#
Raw Normal View History

2022-11-14 12:15:32 +03:00
using System;
using Syntriax.Modules.ToggleState;
2022-11-14 12:15:32 +03:00
using UnityEngine;
namespace Syntriax.Modules.Trigger
{
public class TriggerBase : MonoBehaviour, ITrigger
2022-11-14 12:15:32 +03:00
{
public IToggleState ToggleStateMember { get; protected set; } = new ToggleStateMember(true);
public Action<bool> OnTriggerStateChanged { get; set; } = null;
private bool _isTrigerred = false;
2022-11-14 12:15:32 +03:00
public bool IsTrigerred
{
get => _isTrigerred;
protected set
{
if (value == _isTrigerred || !ToggleStateMember.IsToggledNullChecked())
2022-12-02 00:09:14 +03:00
return;
2022-11-14 12:15:32 +03:00
_isTrigerred = value;
OnTriggerStateChanged?.Invoke(value);
2022-11-14 12:15:32 +03:00
}
}
}
}