From 5a8bc141d38b0d7734ae5bf382f0070550d32276 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 16 Jan 2025 20:40:18 -0800 Subject: [PATCH] tweak ModeInstruction and document meaning --- lib/common/src/physics.rs | 8 +++++--- strafe-client/src/physics.rs | 9 ++++++--- strafe-client/src/session.rs | 5 +++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/common/src/physics.rs b/lib/common/src/physics.rs index 169427d..a70e060 100644 --- a/lib/common/src/physics.rs +++ b/lib/common/src/physics.rs @@ -1,4 +1,5 @@ use crate::mouse::MouseState; +use crate::gameplay_modes::{ModeId,StageId}; #[derive(Clone,Copy,Hash,Eq,PartialEq,PartialOrd,Debug)] pub enum TimeInner{} @@ -42,10 +43,11 @@ pub enum ModeInstruction{ /// This forgets all inputs and settings which need to be reapplied. Reset, /// Restart: Teleport to the start zone. - Restart, + /// This runs when you press R or teleport to a bonus + Restart(ModeId), /// Spawn: Teleport to a specific mode's spawn - /// Sets current mode & spawn - Spawn(crate::gameplay_modes::ModeId,crate::gameplay_modes::StageId), + /// This runs when the map loads to put you at the map lobby + Spawn(ModeId,StageId), } #[derive(Clone,Debug)] pub enum MiscInstruction{ diff --git a/strafe-client/src/physics.rs b/strafe-client/src/physics.rs index 56218f2..9896e6b 100644 --- a/strafe-client/src/physics.rs +++ b/strafe-client/src/physics.rs @@ -857,6 +857,9 @@ impl PhysicsState{ pub const fn camera(&self)->PhysicsCamera{ self.camera } + pub const fn mode(&self)->gameplay_modes::ModeId{ + self.mode_state.get_mode_id() + } pub fn clear(&mut self){ self.touching.clear(); } @@ -1801,9 +1804,9 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI state.reset_to_default(); b_refresh_walk_target=false; }, - Instruction::Mode(ModeInstruction::Restart)=>{ - //teleport to start zone - let mode=data.modes.get_mode(state.mode_state.get_mode_id()); + Instruction::Mode(ModeInstruction::Restart(mode_id))=>{ + //teleport to mode start zone + let mode=data.modes.get_mode(mode_id); let spawn_point=mode.and_then(|mode| //TODO: spawn at the bottom of the start zone plus the hitbox size //TODO: set camera andles to face the same way as the start zone diff --git a/strafe-client/src/session.rs b/strafe-client/src/session.rs index 4f62a37..7cccf38 100644 --- a/strafe-client/src/session.rs +++ b/strafe-client/src/session.rs @@ -36,7 +36,7 @@ pub enum SessionInputInstruction{ #[derive(Clone,Debug)] pub enum ImplicitModeInstruction{ ResetAndRestart, - ResetAndSpawn(strafesnet_common::gameplay_modes::ModeId,strafesnet_common::gameplay_modes::StageId), + ResetAndSpawn(ModeId,StageId), } pub enum SessionControlInstruction{ @@ -223,9 +223,10 @@ impl InstructionConsumer> for Session{ }, Instruction::Input(SessionInputInstruction::Mode(ImplicitModeInstruction::ResetAndRestart))=>{ self.clear_recording(); + let mode_id=self.simulation.physics.mode(); run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Mode(ModeInstruction::Reset)); run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Misc(MiscInstruction::SetSensitivity(self.user_settings().calculate_sensitivity()))); - run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Mode(ModeInstruction::Restart)); + run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Mode(ModeInstruction::Restart(mode_id))); }, Instruction::Input(SessionInputInstruction::Mode(ImplicitModeInstruction::ResetAndSpawn(mode_id,spawn_id)))=>{ self.clear_recording();