using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; using KairoEngine.Core; namespace KairoEngine.Core.GameActions { [System.Serializable, HideReferenceObjectPicker] public class GameActionTrigger : IComparable { public virtual string name { get; } public virtual GameActionTriggersController controller { get => _controller; set => _controller = value; } protected internal GameActionTriggersController _controller; public virtual string GetTypeName() => "GameActionTrigger"; public virtual string GetTriggerName() => "Generic Trigger"; [HideInInspector] public string typeName = "GameActionTrigger"; [HideInInspector] public string className; /// Fired when the action starts executing. public virtual void OnEnable() { } /// Fired every frame while executing this trigger. public virtual void Update() { } /// Fired when the trigger stops executing. public virtual void OnDisable() { } public static GameActionTriggerBase InvokeStringMethod(string typeName, string methodName, string data) { Type calledType = Type.GetType(typeName); GameActionTriggerBase trigger = (GameActionTriggerBase)calledType.InvokeMember($"JSONTo{methodName}", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static, null, null, new object[] { data }); return trigger; } public int CompareTo(GameActionTrigger other) { if(other == null) return 1; else return -1; } public virtual void OnBeforeSerialize(GameActionObjectSerializer serializer, int n) { } public virtual void OnBeforeDeserialize(GameActionObjectSerializer serializer, int n) { } } public class GameActionTriggerBase : GameActionTrigger { } }