Example #1
0
        private void AddTransition(StateNode endState, Transition transition)
        {
            if (!connectedStates.Contains(endState.state))
            {
                connectedStates.Add(endState.state);
                TransitionDataHolder t = ScriptableObject.CreateInstance <TransitionDataHolder>();
                t.Init(RemoveTransition, RemoveTransitionFromInspector);
                t.TransitionsForState = new List <Transition>();
                t.TransitionsForState.Add(transition);

                // If the other state transitions to this one, it needs to be two ways
                if (endState.connectedStates.Contains(state))
                {
                    t.TwoWayTransition = true;
                    endState.stateTransitionInfo[state].TwoWayTransition = true;
                    t.OtherWayTransition = endState.stateTransitionInfo[state];
                    endState.stateTransitionInfo[state].OtherWayTransition = t;
                    endState.UpdateTriangleRotation(state);
                }

                stateTransitionInfo.Add(endState.state, t);
            }
            else
            {
                stateTransitionInfo[endState.state].TransitionsForState.Add(transition);
            }

            UpdateTriangleRotation(endState.state);
        }