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 abstract class GameActionCondition : IComparable { public virtual string name { get; } public virtual GameActionsController controller { get => _controller; set => _controller = value; } protected internal GameActionsController _controller; [HideInInspector] public string typeName = "GameActionCondition"; public virtual string GetTypeName() => "GameActionCondition"; public virtual string GetActionName() => "Generic Condition"; [HideInInspector] public string className; /// The Restart function is fired once on each GameAction in a controller when all actions have the bool done set to True. public virtual bool Evaluate() { return true; } public static GameActionCondition InvokeStringMethod(string typeName, string methodName, string data) { Type calledType = Type.GetType(typeName); if(calledType == null) Debug.LogError($"type \"{typeName}\" is not valid"); GameActionCondition condition = (GameActionCondition)calledType.InvokeMember($"JSONTo{methodName}", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static, null, null, new object[] { data }); return condition; } public int CompareTo(GameActionCondition other) { if(other == null) return 1; else return -1; } public virtual void OnBeforeSerialize(GameActionObjectSerializer serializer, int n, int depth) { } public virtual void OnBeforeDeserialize(GameActionObjectSerializer serializer, int n, int depth) { } } public class GameActionConditionBase : GameActionCondition { } }