/// <summary> /// Stops all other animations, plays the `state`, and returns it. /// <para></para> /// The animation will continue playing from its current <see cref="AnimancerState.Time"/>. /// If you wish to force it back to the start, you can simply set the `state`s time to 0. /// </summary> public AnimancerState Play(AnimancerState state) { Validate.Root(state, Root); if (TargetWeight != 1) { Weight = 1; } AddChild(state); CurrentState = state; state.Play(); var count = States.Count; for (int i = 0; i < count; i++) { var otherState = States[i]; if (otherState != state) { otherState.Stop(); } } return(state); }
/************************************************************************************************************************/ // Starting /************************************************************************************************************************/ /// <summary> /// Stops all other animations, plays the 'state', and returns it. /// <para></para> /// The animation will continue playing from its current <see cref="AnimancerState.Time"/>. /// If you wish to force it back to the start, you can simply set the 'state's time to 0. /// </summary> public AnimancerState Play(AnimancerState state) { ValidateState(state); CurrentState = state; state.Play(); var count = States.Count; for (int i = 0; i < count; i++) { var otherState = States[i]; if (otherState != state) { otherState.Stop(); } } return(state); }
/// <summary> /// Stops all other animations, plays the `state`, and returns it. /// <para></para> /// The animation will continue playing from its current <see cref="AnimancerState.Time"/>. /// If you wish to force it back to the start, you can simply set the `state`s time to 0. /// </summary> public AnimancerState Play(AnimancerState state) { if (TargetWeight != 1) { Weight = 1; } AddChild(state); CurrentState = state; state.Play(); for (int i = States.Count - 1; i >= 0; i--) { var otherState = States[i]; if (otherState != state) { otherState.Stop(); } } return(state); }