29 lines
758 B
C#
29 lines
758 B
C#
using System;
|
|
using Syntriax.Modules.State;
|
|
|
|
namespace Syntriax.Modules.Action
|
|
{
|
|
public abstract class ActionBaseWithDeactivation : ActionBase, IActionWithDeactivation
|
|
{
|
|
public Action<IAction> OnDeactivated { get; set; } = null;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
OnDeactivated += (_) => OnActionDeactivated();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when the current <see cref="ActionBase"/> gets deactivated
|
|
/// </summary>
|
|
protected abstract void OnActionDeactivated();
|
|
public virtual void Deactivate()
|
|
{
|
|
if (!StateEnable.IsEnabledNullChecked())
|
|
return;
|
|
|
|
OnDeactivated?.Invoke(this);
|
|
}
|
|
}
|
|
}
|