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