2020-03-11 16:11:27 -04:00
using UnityEngine ;
2020-03-08 08:24:46 -04:00
using System ;
namespace UnityAtoms.FSM
{
2020-03-21 17:45:39 -04:00
/// <summary>
/// Different Event Reference usages.
/// </summary>
2020-03-11 16:11:27 -04:00
public class FSMTransitionDataBaseEventReferenceUsage
{
public const int FSM = 2 ;
public const int FSM_INSTANCER = 3 ;
}
2020-03-08 08:24:46 -04:00
/// <summary>
/// Event Reference of type `FSMTransitionData`. Inherits from `AtomBaseEventReference<FSMTransitionData, FSMTransitionDataEvent, FSMTransitionDataEventInstancer>`.
/// </summary>
[Serializable]
public sealed class FSMTransitionDataBaseEventReference : AtomBaseEventReference <
FSMTransitionData ,
FSMTransitionDataEvent ,
FSMTransitionDataEventInstancer > , IGetEvent
2020-03-11 16:11:27 -04:00
{
/// <summary>
/// Get the value for the Reference.
/// </summary>
/// <value>The value of type `FiniteStateMachine`.</value>
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 ;
}
}
}
/// <summary>
/// Takes event from this FiniteStateMachine if `Usage` is set to `FSM`.
/// </summary>
[SerializeField]
private FiniteStateMachine _fsm = default ( FiniteStateMachine ) ;
/// <summary>
/// Takes event from this FiniteStateMachineInstancer if `Usage` is set to `FSM Instancer`.
/// </summary>
[SerializeField]
private FiniteStateMachineInstancer _fsmInstancer = default ( FiniteStateMachineInstancer ) ;
}
2020-03-08 08:24:46 -04:00
}