pub fn step_simulation<BC: BlockContainer>(&mut self, input: PlayerInput, time: Instant, world: &BC) {
        // Recompute simulation if necessary
        if self.needs_recomputing {
            self.needs_recomputing = false;
            self.current_state = self.last_server_state.physics_state.clone();

            let mut previous_time = self.last_server_state.server_time;
            for &(time, player_input) in self.client_inputs.iter() {
                // First, we have to apply the current client input to the server's input
                self.last_server_state
                    .input
                    .player_inputs
                    .insert(self.player_id, player_input);
                // Only then can we step the simulation
                self.current_state.step_simulation(
                    &self.last_server_state.input,
                    time - previous_time,
                    world,
                );
                previous_time = time;
            }
        }

        let previous_instant = match self.client_inputs.last() {
            Some((time, _)) => *time,
            None => self.last_server_state.server_time,
        };

        // Store input for future processing
        self.client_inputs.push((time, input));
        self.last_server_state
            .input
            .player_inputs
            .insert(self.player_id, input);

        // Step local simulation
        self.current_state.step_simulation(
            &self.last_server_state.input,
            time - previous_instant,
            world,
        );
    }
/// Step the simulation according to the current input and time
Step the simulation according to the current input and time
Step the simulation according to the current input and time
pub fn step_simulation<BC: BlockContainer>(&mut self, input: PlayerInput, time: Instant, world: &BC) {
        // Recompute simulation if necessary
        if self.needs_recomputing {
            self.needs_recomputing = false;
            self.current_state = self.last_server_state.physics_state.clone();
            let mut previous_time = self.last_server_state.server_time;
            for &(time, player_input) in self.client_inputs.iter() {
                // First, we have to apply the current client input to the server's input
                self.last_server_state
                    .input
                    .player_inputs
                    .insert(self.player_id, player_input);
                // Only then can we step the simulation
                self.current_state.step_simulation(
                    &self.last_server_state.input,
                    time - previous_time,
                    world,
                );
                previous_time = time;
            }
        }
        let previous_instant = match self.client_inputs.last() {
            Some((time, _)) => *time,
            None => self.last_server_state.server_time,
        };
        // Store input for future processing
        self.client_inputs.push((time, input));
        self.last_server_state
            .input
            .player_inputs
            .insert(self.player_id, input);
        // Step local simulation
        self.current_state.step_simulation(
            &self.last_server_state.input,
            time - previous_instant,
            world,
        );
    }
pub fn step_simulation < BC : BlockContainer > ( & mut self , input : PlayerInput , time : Instant , world : & BC ) { // Recompute simulation if necessary if self . needs_recomputing { self . needs_recomputing = false ; self . current_state = self . last_server_state . physics_state . clone ( ) ; let mut previous_time = self . last_server_state . server_time ; for & ( time , player_input ) in self . client_inputs . iter ( ) { // First, we have to apply the current client input to the server's input self . last_server_state . input . player_inputs . insert ( self . player_id , player_input ) ; // Only then can we step the simulation self . current_state . step_simulation ( & self . last_server_state . input , time - previous_time , world , ) ; previous_time = time ; } } let previous_instant = match self . client_inputs . last ( ) { Some ( ( time , _ ) ) => * time , None => self . last_server_state . server_time , } ; // Store input for future processing self . client_inputs . push ( ( time , input ) ) ; self . last_server_state . input . player_inputs . insert ( self . player_id , input ) ; // Step local simulation self . current_state . step_simulation ( & self . last_server_state . input , time - previous_instant , world , ) ; }
Step the simulation according to the current input and time
Step the simulation according to the current input and time
&mut self
input
PlayerInput
time
Instant
world
&BC
&mut self
input
PlayerInput
time
Instant
world
&BC