using System; using UnityEngine; using UnityEngine.Serialization; namespace UnityAtoms { [Serializable] public abstract class ConditionalGameActionHelper where GA : GameAction where C : GameFunction { [FormerlySerializedAs("Condition")] [SerializeField] private C _condition; [FormerlySerializedAs("Action")] [SerializeField] private GA _action; [FormerlySerializedAs("VoidAction")] [SerializeField] private VoidAction _voidAction; [FormerlySerializedAs("ElseAction")] [SerializeField] private GA _elseAction; [FormerlySerializedAs("ElseVoidAction")] [SerializeField] private VoidAction _elseVoidAction; public void Do(T1 t1) { if (_condition == null || _condition.Call(t1)) { if (_action != null) { _action.Do(t1); } if (_voidAction != null) { _voidAction.Do(); } } else { if (_elseAction != null) { _elseAction.Do(t1); } if (_elseVoidAction != null) { _elseVoidAction.Do(); } } } } [Serializable] public abstract class ConditionalGameActionHelper where GA : GameAction where C : GameFunction { [SerializeField] private C _condition; [SerializeField] private GA _action; [SerializeField] private VoidAction _voidAction; [SerializeField] private GA _elseAction; [SerializeField] private VoidAction _elseVoidAction; public void Do(T1 t1, T2 t2) { if (_condition == null || _condition.Call(t1, t2)) { if (_action != null) { _action.Do(t1, t2); } if (_voidAction != null) { _voidAction.Do(); } } else { if (_elseAction != null) { _elseAction.Do(t1, t2); } if (_elseVoidAction != null) { _elseVoidAction.Do(); } } } } [Serializable] public abstract class ConditionalGameActionHelper where GA : GameAction where C : GameFunction { [SerializeField] private C _condition; [SerializeField] private GA _action; [SerializeField] private VoidAction _voidAction; [SerializeField] private GA _elseAction; [SerializeField] private VoidAction _elseVoidAction; public void Do(T1 t1, T2 t2, T3 t3) { if (_condition == null || _condition.Call(t1, t2, t3)) { if (_action != null) { _action.Do(t1, t2, t3); } if (_voidAction != null) { _voidAction.Do(); } } else { if (_elseAction != null) { _elseAction.Do(t1, t2, t3); } if (_elseVoidAction != null) { _elseVoidAction.Do(); } } } } [Serializable] public abstract class ConditionalGameActionHelper where GA : GameAction where C : GameFunction { [SerializeField] private C _condition; [SerializeField] private GA _action; [SerializeField] private VoidAction _voidAction; [SerializeField] private GA _elseAction; [SerializeField] private VoidAction _elseVoidAction; public void Do(T1 t1, T2 t2, T3 t3, T4 t4) { if (_condition == null || _condition.Call(t1, t2, t3, t4)) { if (_action != null) { _action.Do(t1, t2, t3, t4); } if (_voidAction != null) { _voidAction.Do(); } } else { if (_elseAction != null) { _elseAction.Do(t1, t2, t3, t4); } if (_elseVoidAction != null) { _elseVoidAction.Do(); } } } } [Serializable] public abstract class ConditionalGameActionHelper where GA : GameAction where C : GameFunction { [SerializeField] private C _condition; [SerializeField] private GA _action; [SerializeField] private VoidAction _voidAction; [SerializeField] private GA _elseAction; [SerializeField] private VoidAction _elseVoidAction; public void Do(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) { if (_condition == null || _condition.Call(t1, t2, t3, t4, t5)) { if (_action != null) { _action.Do(t1, t2, t3, t4, t5); } if (_voidAction != null) { _voidAction.Do(); } } else { if (_elseAction != null) { _elseAction.Do(t1, t2, t3, t4, t5); } if (_elseVoidAction != null) { _elseVoidAction.Do(); } } } } }