2022-11-14 12:15:32 +03:00
|
|
|
using System;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace Syntriax.Modules.Trigger
|
|
|
|
{
|
|
|
|
public class Trigger : MonoBehaviour, ITrigger
|
|
|
|
{
|
|
|
|
public Action<bool> OnTriggered { 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
|
|
|
|
{
|
|
|
|
bool oldValue = _isTrigerred;
|
|
|
|
|
|
|
|
_isTrigerred = value;
|
|
|
|
|
|
|
|
if (oldValue != value)
|
|
|
|
OnTriggered?.Invoke(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|