pub fn move_to(&mut self, target: types::WorldPosition) {
        if self.movement.is_out_of_bounds(&target) {
            return;
        }
        if self.has_effect(Effects::PAUSED) == true {
            println!("Paused!");
            self.movement.last_position = self.movement.current_position;
            self.movement.current_position = types::WorldPosition::new_fill(
                -99999999999999999999999999999999999999.0,
                -99999999999999999999999999999999999999.0,
            );
            if self.movement.reset_pos == false {
                self.movement.reset_pos = true;
            }
            return; //dont calculate anything else, as we cant move
        } else if self.has_effect(Effects::PAUSED) == true && self.movement.reset_pos == true {
            self.movement.current_position = self.movement.server_position; //sets us back to whatever the server had recorded
            self.movement.reset_pos = false;
            return; //still cant move when coming out of being paused
        }
        let float_current_time = f32::from_bits(self.time_keeper.current_tick_time as u32);
        let float_last_time = f32::from_bits(self.time_keeper.last_tick_time as u32);
        let mut new_position = types::WorldPosition::new();
        let elapsed: f32;
        if float_current_time - float_last_time > 200.0 {
            elapsed = float_current_time - float_last_time;
        } else {
            elapsed = 200.0;
        }
        let step = self.get_move_speed() * elapsed;
        if self.movement.current_position.sq_distance_to(&target) > step * step {
            let angle = self.movement.current_position.angle_to(&target);
            new_position.x = self.movement.current_position.x + angle.cos() * step;
            new_position.y = self.movement.current_position.y + angle.sin() * step;
        } else {
            new_position = target;
        }
        self.movement.last_position = self.movement.current_position;
        self.movement.current_position = new_position;
    }
/// Moves the client position towards the target position
Moves the client position towards the target position
Moves the client position towards the target position
pub fn move_to(&mut self, target: types::WorldPosition) {
        if self.movement.is_out_of_bounds(&target) {
            return;
        }
        if self.has_effect(Effects::PAUSED) == true {
            println!("Paused!");
            self.movement.last_position = self.movement.current_position;
            self.movement.current_position = types::WorldPosition::new_fill(
                -99999999999999999999999999999999999999.0,
                -99999999999999999999999999999999999999.0,
            );
            if self.movement.reset_pos == false {
                self.movement.reset_pos = true;
            }
            return; //dont calculate anything else, as we cant move
        } else if self.has_effect(Effects::PAUSED) == true && self.movement.reset_pos == true {
            self.movement.current_position = self.movement.server_position; //sets us back to whatever the server had recorded
            self.movement.reset_pos = false;
            return; //still cant move when coming out of being paused
        }
        let float_current_time = f32::from_bits(self.time_keeper.current_tick_time as u32);
        let float_last_time = f32::from_bits(self.time_keeper.last_tick_time as u32);
        let mut new_position = types::WorldPosition::new();
        let elapsed: f32;
        if float_current_time - float_last_time > 200.0 {
            elapsed = float_current_time - float_last_time;
        } else {
            elapsed = 200.0;
        }
        let step = self.get_move_speed() * elapsed;
        if self.movement.current_position.sq_distance_to(&target) > step * step {
            let angle = self.movement.current_position.angle_to(&target);
            new_position.x = self.movement.current_position.x + angle.cos() * step;
            new_position.y = self.movement.current_position.y + angle.sin() * step;
        } else {
            new_position = target;
        }
        self.movement.last_position = self.movement.current_position;
        self.movement.current_position = new_position;
    }
pub fn move_to ( & mut self , target : types :: WorldPosition ) { if self . movement . is_out_of_bounds ( & target ) { return ; } if self . has_effect ( Effects :: PAUSED ) == true { println ! ( " " ) ; self . movement . last_position = self . movement . current_position ; self . movement . current_position = types :: WorldPosition :: new_fill ( - 99999999999999999999999999999999999999.0 , - 99999999999999999999999999999999999999.0 , ) ; if self . movement . reset_pos == false { self . movement . reset_pos = true ; } return ; //dont calculate anything else, as we cant move } else if self . has_effect ( Effects :: PAUSED ) == true && self . movement . reset_pos == true { self . movement . current_position = self . movement . server_position ; //sets us back to whatever the server had recorded self . movement . reset_pos = false ; return ; //still cant move when coming out of being paused } let float_current_time = f32 :: from_bits ( self . time_keeper . current_tick_time as u32 ) ; let float_last_time = f32 :: from_bits ( self . time_keeper . last_tick_time as u32 ) ; let mut new_position = types :: WorldPosition :: new ( ) ; let elapsed : f32 ; if float_current_time - float_last_time > 200.0 { elapsed = float_current_time - float_last_time ; } else { elapsed = 200.0 ; } let step = self . get_move_speed ( ) * elapsed ; if self . movement . current_position . sq_distance_to ( & target ) > step * step { let angle = self . movement . current_position . angle_to ( & target ) ; new_position . x = self . movement . current_position . x + angle . cos ( ) * step ; new_position . y = self . movement . current_position . y + angle . sin ( ) * step ; } else { new_position = target ; } self . movement . last_position = self . movement . current_position ; self . movement . current_position = new_position ; }
Moves the client position towards the target position
Moves the client position towards the target position
&mut self
target
types::WorldPosition
&mut self
target
types::WorldPosition