using System.Collections; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; using KairoEngine.Core; using KairoEngine.Core.GameActions; using KairoEngine.Stats.GameActions; namespace KairoEngine.Stats { [CreateAssetMenu(fileName = "StatusEffect", menuName = "KairoEngine/Status Effect", order = 8)] [HideMonoScript] public class StatusEffectTemplate : ScriptableObject { public string title = ""; public string description = ""; public bool hasDuration = true; [ShowIf("@hasDuration")] public float duration = 1; [Range(1, 10)] public int maxStack = 1; // [ListDrawerSettings(HideAddButton = false, HideRemoveButton = false, DraggableItems = false, Expanded = true, ShowPaging = false, ShowItemCount = false)] // [Space] // public List modifiers = new List(); [TitleGroup("Actions")] [HideLabel, InlineProperty, OnInspectorInit("SetupContext"), PropertySpace(2, 4)] public GameActionContext context = new GameActionContext(); [TabGroup("Actions/Triggers", "On Add"), InlineProperty, HideLabel, PropertySpace(1, 2)] [InfoBox("Execute actions when the StatusEffect is added to a StatsController", InfoMessageType.Info)] public GameActionsController onAddController; [TabGroup("Actions/Triggers", "On Stack"), InlineProperty, HideLabel, ShowIf("@maxStack > 1"), PropertySpace(1, 2)] [InfoBox("Executes when the StatusEffect stack is increased", InfoMessageType.Info)] public GameActionsController onStackController; [TabGroup("Actions/Triggers", "While"), InlineProperty, HideLabel, PropertySpace(1, 2)] [InfoBox("Executes every frame while the StatusEffect is active", InfoMessageType.Info)] public GameActionsController onWhileController; [TabGroup("Actions/Triggers", "On Destack"), InlineProperty, HideLabel, ShowIf("@maxStack > 1"), PropertySpace(1, 2)] [InfoBox("Executes when the StatusEffect stack is decreased", InfoMessageType.Info)] public GameActionsController onDestackController; [TabGroup("Actions/Triggers", "On Remove"), InlineProperty, HideLabel, PropertySpace(1, 2)] [InfoBox("Executes when the StatusEffect is removed from the StatsController", InfoMessageType.Info)] public GameActionsController onRemoveController; private void SetupContext() { if(context == null) return; onAddController.context = context; onStackController.context = context; onWhileController.context = context; onDestackController.context = context; onRemoveController.context = context; if(!context.HasVariable("Target GameObject")) { var variable = new GameActionContextGameObject(); variable.name = "Target GameObject"; variable.value = null; variable.canEdit = false; context.variables.Add(variable); } if(!context.HasVariable("Stats")) { var variable = new GameActionContextStatsController(); variable.name = "Stats"; variable.value = null; variable.canEdit = false; context.variables.Add(variable); } } } }