public static FSMVisualizerTransition <StateType>[] CreateArrayFromTransitions(Transition <StateType>[] tr) { FSMVisualizerTransition <StateType>[] arr = new FSMVisualizerTransition <StateType> [tr.Length]; for (int i = 0; i < arr.Length; i++) { arr[i] = new FSMVisualizerTransition <StateType>(tr[i].resultingState, tr[i].TransitionShouldOccur.ToString()); } return(arr); }
public StateMachineVisualizer(StateMachine <StateType, State> _FSM, Transform t, Vector3 [] _statesPos) { FSM = _FSM; statesPos = _statesPos; origin = t; var FSMDict = FSM.GetDict(); if (FSMDict.Count != statesPos.Length) { throw new Exception("FSMVisualizer Error: The given States Positions array does not have the same length as the FSM. Current size: " + statesPos.Length + ". Expected size: " + FSMDict.Count); } objs = new Dictionary <StateType, FSMVisualizerObject <StateType> >(); int counter = 0; foreach (var state in FSMDict) { objs.Add(state.Key, new FSMVisualizerObject <StateType>(statesPos[counter], FSMVisualizerTransition <StateType> .CreateArrayFromTransitions(state.Value.transitions))); counter++; } FSM.OnTransitionEvent += UpdateTransitionTimers; }