using UnityEngine; using System; namespace UnityAtoms.FSM { /// /// Different Event Reference usages. /// public class FSMTransitionDataBaseEventReferenceUsage { public const int FSM = 2; public const int FSM_INSTANCER = 3; } /// /// Event Reference of type `FSMTransitionData`. Inherits from `AtomBaseEventReference<FSMTransitionData, FSMTransitionDataEvent, FSMTransitionDataEventInstancer>`. /// [Serializable] public sealed class FSMTransitionDataBaseEventReference : AtomBaseEventReference< FSMTransitionData, FSMTransitionDataEvent, FSMTransitionDataEventInstancer>, IGetEvent { /// /// Get the value for the Reference. /// /// The value of type `FiniteStateMachine`. public override FSMTransitionDataEvent Event { get { switch (_usage) { case (FSMTransitionDataBaseEventReferenceUsage.FSM_INSTANCER): return ((FiniteStateMachine)_fsmInstancer.Variable).TransitionStarted; case (FSMTransitionDataBaseEventReferenceUsage.FSM): return _fsm.TransitionStarted; default: return base.Event; } } set { switch (_usage) { case (FSMTransitionDataBaseEventReferenceUsage.FSM_INSTANCER): ((FiniteStateMachine)_fsmInstancer.Variable).TransitionStarted = value; break; case (FSMTransitionDataBaseEventReferenceUsage.FSM): _fsm.TransitionStarted = value; break; default: base.Event = value; break; } } } /// /// Takes event from this FiniteStateMachine if `Usage` is set to `FSM`. /// [SerializeField] private FiniteStateMachine _fsm = default(FiniteStateMachine); /// /// Takes event from this FiniteStateMachineInstancer if `Usage` is set to `FSM Instancer`. /// [SerializeField] private FiniteStateMachineInstancer _fsmInstancer = default(FiniteStateMachineInstancer); } }