using System.Collections; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; using KairoEngine.Core; namespace KairoEngine.Core.GameActions { [HideMonoScript, AddComponentMenu("KairoEngine/Actions Controller")] public class GameActionsComponent : MonoBehaviour { [InlineProperty, HideLabel] [PropertySpace(0, 3)] public GameActionTriggersController triggersController = new GameActionTriggersController(); [InlineProperty, HideLabel] [OnInspectorInit("Initialize")] public GameActionsController controller; private void OnEnable() { Initialize(); if(triggersController != null) triggersController.OnEnable(); } private void OnDisable() { if(controller != null) controller.Stop(); if(triggersController != null) triggersController.OnDisable(); } private void Start() { Initialize(); if(controller == null) { controller = new GameActionsController(); controller.actions = new List(); } } private void Update() { if(triggersController != null) triggersController.Update(); } private void Initialize() { if(controller == null) return; controller.showContext = true; triggersController.actionsController = controller; if(!controller.context.HasVariable("GameObject")) { var variable = new GameActionContextGameObject(); variable.name = "GameObject"; variable.value = this.gameObject; variable.canEdit = false; controller.context.AddVariable(variable); } } public void StartGameActionsController() { if(controller != null) { controller.Start(); } } public void ResetGameActionsController() { if(controller != null) { controller.Restart(); } } } }