1
This commit is contained in:
@@ -60,17 +60,14 @@ namespace BITKit
|
||||
}
|
||||
public class MonoAction : MonoBehaviour, IAction
|
||||
{
|
||||
[SerializeField] private string mark;
|
||||
[SerializeReference, SubclassSelector] public List<IAction> actions;
|
||||
CancellationToken cancellationToken;
|
||||
void Start()
|
||||
{
|
||||
cancellationToken = gameObject.GetCancellationTokenOnDestroy();
|
||||
}
|
||||
public async void Execute()
|
||||
{
|
||||
BITAppForUnity.ThrowIfNotPlaying();
|
||||
try
|
||||
{
|
||||
await UniTask.SwitchToMainThread(cancellationToken);
|
||||
await UniTask.SwitchToMainThread(destroyCancellationToken);
|
||||
foreach (var x in actions)
|
||||
{
|
||||
x.Execute();
|
||||
@@ -80,12 +77,6 @@ namespace BITKit
|
||||
{
|
||||
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
|
@@ -29,6 +29,9 @@ namespace BITKit
|
||||
remove => stateMachine.OnStateChanged -= value;
|
||||
}
|
||||
|
||||
public event Action<T> OnStateRegistered;
|
||||
public event Action<T> OnStateUnRegistered;
|
||||
|
||||
public IDictionary<Type, T> StateDictionary => stateMachine.StateDictionary;
|
||||
|
||||
public virtual void Initialize()
|
||||
@@ -55,5 +58,17 @@ namespace BITKit
|
||||
{
|
||||
stateMachine.TransitionState(state);
|
||||
}
|
||||
|
||||
public virtual void Register(T newState) => StateMachineUtils.Register(this,newState);
|
||||
public virtual void UnRegister(T newState)=>StateMachineUtils.UnRegister(this,newState);
|
||||
void IStateMachine<T>.InvokeOnStateRegistered(T state)
|
||||
{
|
||||
OnStateRegistered?.Invoke(state);
|
||||
}
|
||||
|
||||
void IStateMachine<T>.InvokeOnStateUnRegistered(T state)
|
||||
{
|
||||
OnStateUnRegistered?.Invoke(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user