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

30 lines
1.1 KiB
C#
Raw Normal View History

2020-03-08 13:24:46 +01:00
using UnityEngine;
using UnityAtoms.BaseAtoms;
namespace UnityAtoms.FSM
{
[EditorIcon("atom-icon-hotpink")]
2020-03-09 00:16:40 +01:00
[AddComponentMenu("Unity Atoms/FSM/Finite State Machine Instancer")]
2020-03-11 21:11:27 +01:00
public class FiniteStateMachineInstancer : StringVariableInstancer
2020-03-08 13:24:46 +01:00
{
2020-03-11 21:11:27 +01:00
public override StringVariable Base { get => (StringVariable)_fsmBase; }
/// <summary>
/// The variable that the in memory copy will be based on when created at runtime.
/// </summary>
[SerializeField]
private FiniteStateMachine _fsmBase = null;
2020-03-08 13:24:46 +01:00
protected override void ImplSpecificSetup()
{
2020-03-11 21:11:27 +01:00
if (((FiniteStateMachine)Base).TransitionStarted != null)
2020-03-08 13:24:46 +01:00
{
2020-03-11 21:11:27 +01:00
((FiniteStateMachine)_inMemoryCopy).TransitionStarted = Instantiate(((FiniteStateMachine)Base).TransitionStarted);
2020-03-08 13:24:46 +01:00
}
2020-03-11 21:11:27 +01:00
if (((FiniteStateMachine)Base).CompleteCurrentTransition != null)
2020-03-08 13:24:46 +01:00
{
2020-03-11 21:11:27 +01:00
((FiniteStateMachine)_inMemoryCopy).CompleteCurrentTransition = Instantiate(((FiniteStateMachine)Base).CompleteCurrentTransition);
2020-03-08 13:24:46 +01:00
}
}
}
}