unity-atoms/Packages/FSM/Runtime/FiniteStateMachine/FiniteStateMachineReference.cs

52 lines
1.5 KiB
C#
Raw Normal View History

2020-03-09 00:16:40 +01:00
using System;
using UnityEngine;
using UnityAtoms.BaseAtoms;
namespace UnityAtoms.FSM
{
public class FiniteStateMachineReferenceUsage
{
2020-03-11 21:11:27 +01:00
public const int FSM = 0;
public const int FSM_INSTANCER = 1;
2020-03-09 00:16:40 +01:00
}
/// <summary>
/// Reference of type `FiniteStateMachine`. Inherits from `AtomBaseReference`.
/// </summary>
[Serializable]
public class FiniteStateMachineReference : AtomBaseReference
{
/// <summary>
/// Get the value for the Reference.
/// </summary>
/// <value>The value of type `FiniteStateMachine`.</value>
public FiniteStateMachine Machine
{
get
{
switch (_usage)
{
2020-03-11 21:11:27 +01:00
case (FiniteStateMachineReferenceUsage.FSM_INSTANCER):
return _fsmInstancer == null ? default(FiniteStateMachine) : (FiniteStateMachine)_fsmInstancer.Variable;
case (FiniteStateMachineReferenceUsage.FSM):
2020-03-09 00:16:40 +01:00
default:
2020-03-11 21:11:27 +01:00
return _fsm;
2020-03-09 00:16:40 +01:00
}
}
}
/// <summary>
2020-03-11 21:11:27 +01:00
/// Variable used if `Usage` is set to `FSM`.
2020-03-09 00:16:40 +01:00
/// </summary>
[SerializeField]
2020-03-11 21:11:27 +01:00
private FiniteStateMachine _fsm = default(FiniteStateMachine);
2020-03-09 00:16:40 +01:00
/// <summary>
2020-03-11 21:11:27 +01:00
/// Variable Instancer used if `Usage` is set to `FSM_INSTANCER`.
2020-03-09 00:16:40 +01:00
/// </summary>
[SerializeField]
2020-03-11 21:11:27 +01:00
private FiniteStateMachineInstancer _fsmInstancer = default(FiniteStateMachineInstancer);
2020-03-09 00:16:40 +01:00
}
}