BITFALL/Assets/Artists/Scripts/Scenes/ActionBasedEvent.cs

39 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using BITKit;
using BITKit.Events;
using UnityEngine;
namespace BITFALL.Scene
{
public class ActionBasedEvent : ActionBasedComponent
{
[SerializeReference,SubclassSelector] private IAction onStart=new EmptyAction();
[SerializeReference,SubclassSelector] private IAction onCompleted=new EmptyAction();
[SerializeReference,SubclassSelector] private IAction onCanceled=new EmptyAction();
[SerializeReference,SubclassSelector] private IAction onInterrupt=new EmptyAction();
protected override void OnEnable()
{
base.OnEnable();
if (onStart is not null)
actionBasedObject.OnStarted += onStart.Execute;
actionBasedObject.OnCanceled += onCanceled.Execute;
actionBasedObject.OnCompleted += onCompleted.Execute;
actionBasedObject.OnCanceled += onInterrupt.Execute;
actionBasedObject.OnCompleted += onInterrupt.Execute;
}
protected override void OnDisable()
{
base.OnDisable();
actionBasedObject.OnStarted -= onStart.Execute;
actionBasedObject.OnCanceled -= onCanceled.Execute;
actionBasedObject.OnCompleted -= onCompleted.Execute;
actionBasedObject.OnCanceled -= onInterrupt.Execute;
actionBasedObject.OnCompleted -= onInterrupt.Execute;
}
}
}