1234567891011121314151617181920212223242526272829 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace KairoEngine.Core
- {
- public class CommandInvoker : MonoBehaviour
- {
- static Queue<ICommand> commandBuffer;
- private void Awake()
- {
- commandBuffer = new Queue<ICommand>();
- }
- public static void AddCommand(ICommand command)
- {
- commandBuffer.Enqueue(command);
- }
- void Update()
- {
- while(commandBuffer.Count > 0)
- {
- ICommand command = commandBuffer.Dequeue();
- command.Execute();
- }
- }
- }
- }
|