Prevents KeyNotFoundException when firing a trigger with no transition.
The following code throws a KeyNotFoundException because there is no transition from "TO" to "TO".
using FSM;
using UnityEngine;
public class Foo : MonoBehaviour
{
private StateMachine fsm;
private void Awake()
{
fsm = new StateMachine(this);
fsm.AddState("FROM", new State(needsExitTime: true));
fsm.AddState("TO", new State(needsExitTime: true));
fsm.AddTriggerTransition("TO", new Transition("FROM", "TO", forceInstantly: true));
fsm.AddTriggerTransition("FROM", new Transition("TO", "FROM", forceInstantly: true));
fsm.SetStartState("TO");
fsm.Init();
}
void Trigger()
{
fsm.Trigger("TO");
}
private void Start()
{
Invoke(nameof(Trigger), 3);
}
private void Update()
{
fsm.OnLogic();
}
}
Thanks for finding and solving the bug, and thanks for solving the merge conflict!
I checked your proposal and it works. I will merge this pull request. 👍
Prevents KeyNotFoundException when firing a trigger with no transition. The following code throws a KeyNotFoundException because there is no transition from
"TO"
to"TO"
.