-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MovementInfo -> MovementBlock_UpdateFlag_Living
Fixes #31.
- Loading branch information
Gtker
committed
Feb 23, 2023
1 parent
49c69a5
commit e089206
Showing
6 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
mod item; | ||
pub use item::*; | ||
|
||
mod movement_info; | ||
pub use movement_info::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use crate::tbc::{ | ||
MovementBlock_MovementFlags, MovementBlock_MovementFlags_Jumping, | ||
MovementBlock_MovementFlags_OnTransport, MovementBlock_MovementFlags_SplineElevation, | ||
MovementBlock_MovementFlags_SplineEnabled, MovementBlock_MovementFlags_Swimming, | ||
MovementBlock_UpdateFlag_Living, MovementInfo, MovementInfo_MovementFlags_Swimming, | ||
}; | ||
|
||
impl MovementInfo { | ||
pub fn into_movement_block_update_flag_living( | ||
&self, | ||
backwards_flight_speed: f32, | ||
backwards_running_speed: f32, | ||
backwards_swimming_speed: f32, | ||
flight_speed: f32, | ||
running_speed: f32, | ||
swimming_speed: f32, | ||
turn_rate: f32, | ||
walking_speed: f32, | ||
spline_enabled: Option<MovementBlock_MovementFlags_SplineEnabled>, | ||
) -> MovementBlock_UpdateFlag_Living { | ||
let on_transport = self.flags.get_ON_TRANSPORT().map(|t| MovementBlock_MovementFlags_OnTransport { | ||
transport: t.transport.clone(), | ||
}); | ||
|
||
let jumping = self.flags.get_JUMPING().map(|t| MovementBlock_MovementFlags_Jumping { | ||
cos_angle: t.cos_angle, | ||
sin_angle: t.sin_angle, | ||
xy_speed: t.xy_speed, | ||
z_speed: t.z_speed, | ||
}); | ||
|
||
let swimming = self.flags.get_SWIMMING().map(|t| match *t { | ||
MovementInfo_MovementFlags_Swimming::Swimming { pitch1 } => { | ||
MovementBlock_MovementFlags_Swimming::Swimming { pitch1 } | ||
} | ||
MovementInfo_MovementFlags_Swimming::Ontransport { pitch2 } => { | ||
MovementBlock_MovementFlags_Swimming::Ontransport { pitch2 } | ||
} | ||
}); | ||
|
||
let spline_elevation = self.flags.get_SPLINE_ELEVATION().map(|t| MovementBlock_MovementFlags_SplineElevation { | ||
spline_elevation: t.spline_elevation, | ||
}); | ||
|
||
MovementBlock_UpdateFlag_Living::Living { | ||
living_orientation: self.orientation, | ||
living_position: self.position, | ||
timestamp: self.timestamp, | ||
extra_flags: self.extra_flags, | ||
fall_time: self.fall_time, | ||
flags: MovementBlock_MovementFlags::new( | ||
self.flags.as_int(), | ||
on_transport, | ||
jumping, | ||
swimming, | ||
spline_elevation, | ||
spline_enabled, | ||
), | ||
|
||
backwards_running_speed, | ||
backwards_swimming_speed, | ||
running_speed, | ||
swimming_speed, | ||
turn_rate, | ||
walking_speed, | ||
flying_speed: flight_speed, | ||
backwards_flying_speed: backwards_flight_speed, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
mod item; | ||
pub use item::*; | ||
|
||
mod movement_info; | ||
pub use movement_info::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::vanilla::{ | ||
MovementBlock_MovementFlags, MovementBlock_MovementFlags_Jumping, | ||
MovementBlock_MovementFlags_OnTransport, MovementBlock_MovementFlags_SplineElevation, | ||
MovementBlock_MovementFlags_SplineEnabled, MovementBlock_MovementFlags_Swimming, | ||
MovementBlock_UpdateFlag_Living, MovementInfo, | ||
}; | ||
|
||
impl MovementInfo { | ||
pub fn into_movement_block_update_flag_living( | ||
&self, | ||
backwards_running_speed: f32, | ||
backwards_swimming_speed: f32, | ||
running_speed: f32, | ||
swimming_speed: f32, | ||
turn_rate: f32, | ||
walking_speed: f32, | ||
spline_enabled: Option<MovementBlock_MovementFlags_SplineEnabled>, | ||
) -> MovementBlock_UpdateFlag_Living { | ||
let on_transport = self.flags.get_ON_TRANSPORT().map(|t| MovementBlock_MovementFlags_OnTransport { | ||
transport: t.transport.clone(), | ||
}); | ||
|
||
let jumping = self.flags.get_JUMPING().map(|t| MovementBlock_MovementFlags_Jumping { | ||
cos_angle: t.cos_angle, | ||
sin_angle: t.sin_angle, | ||
xy_speed: t.xy_speed, | ||
z_speed: t.z_speed, | ||
}); | ||
|
||
let swimming = self.flags.get_SWIMMING().map(|t| MovementBlock_MovementFlags_Swimming { pitch: t.pitch }); | ||
|
||
let spline_elevation = self.flags.get_SPLINE_ELEVATION().map(|t| MovementBlock_MovementFlags_SplineElevation { | ||
spline_elevation: t.spline_elevation, | ||
}); | ||
|
||
MovementBlock_UpdateFlag_Living::Living { | ||
living_orientation: self.orientation, | ||
living_position: self.position, | ||
timestamp: self.timestamp, | ||
fall_time: self.fall_time, | ||
flags: MovementBlock_MovementFlags::new( | ||
self.flags.as_int(), | ||
on_transport, | ||
jumping, | ||
swimming, | ||
spline_enabled, | ||
spline_elevation, | ||
), | ||
|
||
backwards_running_speed, | ||
backwards_swimming_speed, | ||
running_speed, | ||
swimming_speed, | ||
turn_rate, | ||
walking_speed, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
mod item; | ||
pub use item::*; | ||
|
||
mod movement_info; | ||
pub use movement_info::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use crate::wrath::{ | ||
MovementBlock_MovementFlags, MovementBlock_MovementFlags_Falling, | ||
MovementBlock_MovementFlags_OnTransport, MovementBlock_MovementFlags_SplineElevation, | ||
MovementBlock_MovementFlags_SplineEnabled, MovementBlock_MovementFlags_Swimming, | ||
MovementBlock_UpdateFlag_Living, MovementInfo, MovementInfo_MovementFlags_Swimming, | ||
}; | ||
|
||
impl MovementInfo { | ||
pub fn into_movement_block_update_flag_living( | ||
&self, | ||
backwards_flight_speed: f32, | ||
backwards_running_speed: f32, | ||
backwards_swimming_speed: f32, | ||
flight_speed: f32, | ||
pitch_rate: f32, | ||
running_speed: f32, | ||
swimming_speed: f32, | ||
turn_rate: f32, | ||
walking_speed: f32, | ||
spline_enabled: Option<MovementBlock_MovementFlags_SplineEnabled>, | ||
) -> MovementBlock_UpdateFlag_Living { | ||
let on_transport = self.flags.get_ON_TRANSPORT().map(|t| MovementBlock_MovementFlags_OnTransport { | ||
transport: t.transport.clone(), | ||
}); | ||
|
||
let falling = self.flags.get_FALLING().map(|t| MovementBlock_MovementFlags_Falling { | ||
cos_angle: t.cos_angle, | ||
sin_angle: t.sin_angle, | ||
xy_speed: t.xy_speed, | ||
z_speed: t.z_speed, | ||
}); | ||
|
||
let swimming = if let Some(t) = self.flags.get_SWIMMING() { | ||
let pitch = match t { | ||
MovementInfo_MovementFlags_Swimming::Swimming { pitch1: pitch } | ||
| MovementInfo_MovementFlags_Swimming::Flying { pitch2: pitch } => *pitch, | ||
}; | ||
Some(MovementBlock_MovementFlags_Swimming { pitch }) | ||
} else { | ||
None | ||
}; | ||
|
||
let spline_elevation = self.flags.get_SPLINE_ELEVATION().map(|t| MovementBlock_MovementFlags_SplineElevation { | ||
spline_elevation: t.spline_elevation, | ||
}); | ||
|
||
MovementBlock_UpdateFlag_Living::Living { | ||
living_orientation: self.orientation, | ||
living_position: self.position, | ||
timestamp: self.timestamp, | ||
extra_flags: self.extra_flags, | ||
fall_time: self.fall_time, | ||
flags: MovementBlock_MovementFlags::new( | ||
self.flags.as_int(), | ||
on_transport, | ||
falling, | ||
swimming, | ||
spline_elevation, | ||
spline_enabled, | ||
), | ||
|
||
backwards_flight_speed, | ||
backwards_running_speed, | ||
backwards_swimming_speed, | ||
flight_speed, | ||
pitch_rate, | ||
running_speed, | ||
swimming_speed, | ||
turn_rate, | ||
walking_speed, | ||
} | ||
} | ||
} |