Advertisement
dronkowitz

ActionScheduler.cs

Nov 30th, 2022
788
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ActionScheduler : MonoBehaviour
  6. {
  7.     IAction currentAction;
  8.     public void StartAction(IAction newAction)
  9.     {
  10.         if (currentAction == newAction)
  11.         {
  12.             return;
  13.         }
  14.         if (currentAction != null)
  15.         {
  16.             currentAction.Cancel();
  17.         }
  18.         currentAction = newAction;
  19.     }
  20.  
  21.     public void CancelCurrentAction()
  22.     {
  23.         StartAction(null);
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement