28 lines
742 B
C#
28 lines
742 B
C#
using System;
|
|
using Syntriax.Modules.ToggleState;
|
|
using UnityEngine;
|
|
|
|
namespace Syntriax.Modules.Trigger
|
|
{
|
|
public class TriggerBase : MonoBehaviour, ITrigger
|
|
{
|
|
public IToggleState ToggleStateMember { get; protected set; } = new ToggleStateMember(true);
|
|
|
|
public Action<bool> OnTriggerStateChanged { get; set; } = null;
|
|
|
|
private bool _isTrigerred = false;
|
|
public bool IsTrigerred
|
|
{
|
|
get => _isTrigerred;
|
|
protected set
|
|
{
|
|
if (value == _isTrigerred || !ToggleStateMember.IsToggledNullChecked())
|
|
return;
|
|
|
|
_isTrigerred = value;
|
|
OnTriggerStateChanged?.Invoke(value);
|
|
}
|
|
}
|
|
}
|
|
}
|