private void SaveStateMachine(Action[][] actions, bool[][] isDurationEnd, Duration[] durations, Condition[][][] conditions)
 {
     StateMachineReflections.SetTransitions(stateMachine, transitions.Select(a => a.ToArray()).ToArray());
     StateMachineReflections.SetActions(stateMachine, actions);
     StateMachineReflections.SetIsDurationsEnd(stateMachine, isDurationEnd);
     StateMachineReflections.SetDurations(stateMachine, durations);
     StateMachineReflections.SetConditions(stateMachine, conditions);
 }
        private void DeleteTransition(int stateIndex, int transitionIndex)
        {
            Undo.RegisterCompleteObjectUndo(new UnityEngine.Object[] { stateMachine, this }, "Transition Deleted");

            transitions[stateIndex].RemoveAt(transitionIndex);
            StateMachineReflections.SetTransitions(stateMachine, transitions.Select(a => a.ToArray()).ToArray());

            bool[][]    isDurationsEnd = StateMachineReflections.GetIsDurationsEnd(stateMachine);
            List <bool> isDurationEnd  = new List <bool>(isDurationsEnd[transitionIndex]);

            isDurationEnd.RemoveAt(transitionIndex);
            isDurationsEnd[transitionIndex] = isDurationEnd.ToArray();
            StateMachineReflections.SetIsDurationsEnd(stateMachine, isDurationsEnd);

            Condition[][][]    conditions      = StateMachineReflections.GetConditions(stateMachine);
            List <Condition[]> stateConditions = new List <Condition[]>(conditions[stateIndex]);

            stateConditions.RemoveAt(transitionIndex);
            conditions[stateIndex] = stateConditions.ToArray();
            StateMachineReflections.SetConditions(stateMachine, conditions);
        }
        private void CreateTransition(Vector2 mousePosition)
        {
            int stateIndex = GetStateIndex(mousePosition);

            if (stateIndex != -1 && stateIndex != creatingTransitionFromStateIndex)
            {
                Undo.RegisterCompleteObjectUndo(new UnityEngine.Object[] { stateMachine, this }, "Transition Created");

                transitions[creatingTransitionFromStateIndex].Add(stateIndex);
                StateMachineReflections.SetTransitions(stateMachine, transitions.Select(a => a.ToArray()).ToArray());

                bool[][]    isDurationsEnd = StateMachineReflections.GetIsDurationsEnd(stateMachine);
                List <bool> isDurationEnd  = new List <bool>(isDurationsEnd[creatingTransitionFromStateIndex]);
                isDurationEnd.Add(false);
                isDurationsEnd[creatingTransitionFromStateIndex] = isDurationEnd.ToArray();
                StateMachineReflections.SetIsDurationsEnd(stateMachine, isDurationsEnd);

                Condition[][][]    conditions      = StateMachineReflections.GetConditions(stateMachine);
                List <Condition[]> stateConditions = new List <Condition[]>(conditions[creatingTransitionFromStateIndex]);
                stateConditions.Add(new Condition[0]);
                conditions[creatingTransitionFromStateIndex] = stateConditions.ToArray();
                StateMachineReflections.SetConditions(stateMachine, conditions);
            }
        }
 private void SaveTransitions()
 {
     StateMachineReflections.SetTransitions(stateMachine, transitionsIndexes);
     StateMachineReflections.SetIsDurationsEnd(stateMachine, isDurationsEnd);
     StateMachineReflections.SetConditions(stateMachine, conditions);
 }