/// <summary> /// Checks the current active state's transitions against the new behaviour state. /// Performs no checking if the new state and current ActiveState have the same ID. /// </summary> /// <param name="newBehaviourState"></param> private void HandleBehaviourChange(uint newBehaviourState) { DebugUtils.AssertNotNull(ActiveState); // If we have not changed state then just return. if (newBehaviourState == ActiveState.StateID) { return; } // Check the transitions of the current active state if (ActiveState.CheckTransitions(newBehaviourState)) { SetNewActiveState(newBehaviourState); } // Check the global states foreach (State state in GlobalStates) { if (state != ActiveState && state.StateID == newBehaviourState) { SetNewActiveState(newBehaviourState); break; } } // Check that we have indeed transitioned to our new state Debug.Assert(newBehaviourState == ActiveState.StateID); // The new state we have moved to should not be playing already Debug.Assert(ActiveState.Animation.IsPlaying == false); ActiveState.Animation.IsPlaying = true; }