pub(crate) fn new_stack(&mut self, states: Vec<Box<dyn State<T, E>>>, data: StateData<'_, T>) {
        if self.running {
            // remove all current states
            let StateData {
                context: state_manager,
                world,
                data,
            } = data;
            while let Some(mut state) = self.state_stack.pop() {
                state.on_stop(StateData {
                    context: state_manager,
                    world,
                    data,
                });
            }

            // push the new states
            let state_count = states.len();
            for (count, state) in states.into_iter().enumerate() {
                self.state_stack.push(state);

                // State was just pushed, thus pop will always succeed
                let new_state = self.state_stack.last_mut().unwrap();
                new_state.on_start(StateData {
                    context: state_manager,
                    world,
                    data,
                });
                if count != state_count - 1 {
                    // pause on each state but the last
                    new_state.on_pause(StateData {
                        context: state_manager,
                        world,
                        data,
                    });
                }
            }
        }
    }
/// Removes all states from the stack and replaces it with a new stack.
Removes all states from the stack and replaces it with a new stack.
Removes all states from the stack and replaces it with a new stack .
pub(crate) fn new_stack(&mut self, states: Vec<Box<dyn State<T, E>>>, data: StateData<'_, T>) {
        if self.running {
            // remove all current states
            let StateData {
                context: state_manager,
                world,
                data,
            } = data;
            while let Some(mut state) = self.state_stack.pop() {
                state.on_stop(StateData {
                    context: state_manager,
                    world,
                    data,
                });
            }
            // push the new states
            let state_count = states.len();
            for (count, state) in states.into_iter().enumerate() {
                self.state_stack.push(state);
                // State was just pushed, thus pop will always succeed
                let new_state = self.state_stack.last_mut().unwrap();
                new_state.on_start(StateData {
                    context: state_manager,
                    world,
                    data,
                });
                if count != state_count - 1 {
                    // pause on each state but the last
                    new_state.on_pause(StateData {
                        context: state_manager,
                        world,
                        data,
                    });
                }
            }
        }
    }
pub ( crate ) fn new_stack ( & mut self , states : Vec < Box < dyn State < T , E > > > , data : StateData < ' _ , T > ) { if self . running { // remove all current states let StateData { context : state_manager , world , data , } = data ; while let Some ( mut state ) = self . state_stack . pop ( ) { state . on_stop ( StateData { context : state_manager , world , data , } ) ; } // push the new states let state_count = states . len ( ) ; for ( count , state ) in states . into_iter ( ) . enumerate ( ) { self . state_stack . push ( state ) ; // State was just pushed, thus pop will always succeed let new_state = self . state_stack . last_mut ( ) . unwrap ( ) ; new_state . on_start ( StateData { context : state_manager , world , data , } ) ; if count != state_count - 1 { // pause on each state but the last new_state . on_pause ( StateData { context : state_manager , world , data , } ) ; } } } }
Removes all states from the stack and replaces it with a new stack.
Removes all states from the stack and replaces it with a new stack .
&mut self
states
Vec<Box<dyn State<T, E>>>
data
StateData<'_, T>
&mut self
states
Vec<Box<dyn State<T, E>>>
data
StateData<'_, T>