tweak ModeInstruction and document meaning

This commit is contained in:
Quaternions 2025-01-16 20:40:18 -08:00
parent 83a067320b
commit 5a8bc141d3
3 changed files with 14 additions and 8 deletions

View File

@ -1,4 +1,5 @@
use crate::mouse::MouseState; use crate::mouse::MouseState;
use crate::gameplay_modes::{ModeId,StageId};
#[derive(Clone,Copy,Hash,Eq,PartialEq,PartialOrd,Debug)] #[derive(Clone,Copy,Hash,Eq,PartialEq,PartialOrd,Debug)]
pub enum TimeInner{} pub enum TimeInner{}
@ -42,10 +43,11 @@ pub enum ModeInstruction{
/// This forgets all inputs and settings which need to be reapplied. /// This forgets all inputs and settings which need to be reapplied.
Reset, Reset,
/// Restart: Teleport to the start zone. /// 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 /// Spawn: Teleport to a specific mode's spawn
/// Sets current mode & spawn /// This runs when the map loads to put you at the map lobby
Spawn(crate::gameplay_modes::ModeId,crate::gameplay_modes::StageId), Spawn(ModeId,StageId),
} }
#[derive(Clone,Debug)] #[derive(Clone,Debug)]
pub enum MiscInstruction{ pub enum MiscInstruction{

View File

@ -857,6 +857,9 @@ impl PhysicsState{
pub const fn camera(&self)->PhysicsCamera{ pub const fn camera(&self)->PhysicsCamera{
self.camera self.camera
} }
pub const fn mode(&self)->gameplay_modes::ModeId{
self.mode_state.get_mode_id()
}
pub fn clear(&mut self){ pub fn clear(&mut self){
self.touching.clear(); self.touching.clear();
} }
@ -1801,9 +1804,9 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
state.reset_to_default(); state.reset_to_default();
b_refresh_walk_target=false; b_refresh_walk_target=false;
}, },
Instruction::Mode(ModeInstruction::Restart)=>{ Instruction::Mode(ModeInstruction::Restart(mode_id))=>{
//teleport to start zone //teleport to mode start zone
let mode=data.modes.get_mode(state.mode_state.get_mode_id()); let mode=data.modes.get_mode(mode_id);
let spawn_point=mode.and_then(|mode| let spawn_point=mode.and_then(|mode|
//TODO: spawn at the bottom of the start zone plus the hitbox size //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 //TODO: set camera andles to face the same way as the start zone

View File

@ -36,7 +36,7 @@ pub enum SessionInputInstruction{
#[derive(Clone,Debug)] #[derive(Clone,Debug)]
pub enum ImplicitModeInstruction{ pub enum ImplicitModeInstruction{
ResetAndRestart, ResetAndRestart,
ResetAndSpawn(strafesnet_common::gameplay_modes::ModeId,strafesnet_common::gameplay_modes::StageId), ResetAndSpawn(ModeId,StageId),
} }
pub enum SessionControlInstruction{ pub enum SessionControlInstruction{
@ -223,9 +223,10 @@ impl InstructionConsumer<Instruction<'_>> for Session{
}, },
Instruction::Input(SessionInputInstruction::Mode(ImplicitModeInstruction::ResetAndRestart))=>{ Instruction::Input(SessionInputInstruction::Mode(ImplicitModeInstruction::ResetAndRestart))=>{
self.clear_recording(); self.clear_recording();
let mode_id=self.simulation.physics.mode();
run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Mode(ModeInstruction::Reset)); 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::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)))=>{ Instruction::Input(SessionInputInstruction::Mode(ImplicitModeInstruction::ResetAndSpawn(mode_id,spawn_id)))=>{
self.clear_recording(); self.clear_recording();