30 lines
733 B
C#
30 lines
733 B
C#
|
using System;
|
||
|
using Syntriax.Modules.State;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace Syntriax.Modules.Action
|
||
|
{
|
||
|
public class Action : MonoBehaviour, IAction
|
||
|
{
|
||
|
private IStateEnable _stateEnable = null;
|
||
|
public IStateEnable StateEnable
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
_stateEnable = _stateEnable ?? GetComponent<State.IStateEnable>() ?? gameObject.AddComponent<State.StateEnableMonoBehaviour>();
|
||
|
return _stateEnable;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Action<IAction> OnActivated { get; set; } = null;
|
||
|
|
||
|
public void Activate()
|
||
|
{
|
||
|
if (!StateEnable.IsEnabledNullChecked())
|
||
|
return;
|
||
|
|
||
|
OnActivated?.Invoke(this);
|
||
|
}
|
||
|
}
|
||
|
}
|