From cd65db000888e6e0194378f4928bf56756a72bcb Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 2 Aug 2024 13:44:41 -0700 Subject: [PATCH] newtypes --- src/newtypes.rs | 3 +++ src/newtypes/gameplay_modes.rs | 5 ++++- src/newtypes/instruction.rs | 8 ++++++++ src/newtypes/mouse.rs | 8 ++++++++ src/newtypes/physics.rs | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/newtypes/instruction.rs create mode 100644 src/newtypes/mouse.rs create mode 100644 src/newtypes/physics.rs diff --git a/src/newtypes.rs b/src/newtypes.rs index 19e2e59..1b1f567 100644 --- a/src/newtypes.rs +++ b/src/newtypes.rs @@ -1,7 +1,10 @@ mod common; pub mod aabb; pub mod model; +pub mod mouse; pub mod integer; +pub mod physics; +pub mod instruction; pub mod gameplay_modes; pub mod gameplay_style; pub mod gameplay_attributes; diff --git a/src/newtypes/gameplay_modes.rs b/src/newtypes/gameplay_modes.rs index bda60af..4363208 100644 --- a/src/newtypes/gameplay_modes.rs +++ b/src/newtypes/gameplay_modes.rs @@ -1,10 +1,13 @@ use super::common::flag; +pub type ModeId=u32; +pub type StageId=u32; + #[binrw::binrw] #[brw(little)] pub struct StageElement{ pub header:u8, - pub stage_id:u32, + pub stage_id:StageId, #[br(if(header&Self::JUMP_LIMIT!=0))] pub jump_limit:Option, } diff --git a/src/newtypes/instruction.rs b/src/newtypes/instruction.rs new file mode 100644 index 0000000..7dc1622 --- /dev/null +++ b/src/newtypes/instruction.rs @@ -0,0 +1,8 @@ +use super::integer::Time; + +#[binrw::binrw] +#[brw(little)] +pub struct TimedPhysicsInstruction{ + pub time:Time, + pub instruction:super::physics::PhysicsInputInstruction, +} diff --git a/src/newtypes/mouse.rs b/src/newtypes/mouse.rs new file mode 100644 index 0000000..9000de5 --- /dev/null +++ b/src/newtypes/mouse.rs @@ -0,0 +1,8 @@ +use super::integer::Time; + +#[binrw::binrw] +#[brw(little)] +pub struct MouseState{ + pub pos:[i32;2], + pub time:Time, +} diff --git a/src/newtypes/physics.rs b/src/newtypes/physics.rs new file mode 100644 index 0000000..bf85399 --- /dev/null +++ b/src/newtypes/physics.rs @@ -0,0 +1,24 @@ +use super::common::Boolio; + +#[binrw::binrw] +#[brw(little)] +pub enum PhysicsInputInstruction{ + ReplaceMouse(super::mouse::MouseState,super::mouse::MouseState), + SetNextMouse(super::mouse::MouseState), + SetMoveRight(Boolio), + SetMoveUp(Boolio), + SetMoveBack(Boolio), + SetMoveLeft(Boolio), + SetMoveDown(Boolio), + SetMoveForward(Boolio), + SetJump(Boolio), + SetZoom(Boolio), + Restart, + Spawn(super::gameplay_modes::ModeId,super::gameplay_modes::StageId), + Idle, + //Idle: there were no input events, but the simulation is safe to advance to this timestep + //for interpolation / networking / playback reasons, most playback heads will always want + //to be 1 instruction ahead to generate the next state for interpolation. + PracticeFly, + SetSensitivity(super::integer::Ratio64Vec2), +}