From 1ca11696975f97df295c60aace37187d360dee11 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 16 Feb 2024 00:16:50 -0800 Subject: [PATCH] fix jump limit --- src/gameplay_modes.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/gameplay_modes.rs b/src/gameplay_modes.rs index 7b4ebb9..5a15174 100644 --- a/src/gameplay_modes.rs +++ b/src/gameplay_modes.rs @@ -7,15 +7,17 @@ use crate::updatable::Updatable; pub struct StageElement{ stage_id:StageId,//which stage spawn to send to force:bool,//allow setting to lower spawn id i.e. 7->3 - behaviour:StageElementBehaviour + behaviour:StageElementBehaviour, + jump_limit:Option, } impl StageElement{ #[inline] - pub const fn new(stage_id:StageId,force:bool,behaviour:StageElementBehaviour)->Self{ + pub const fn new(stage_id:StageId,force:bool,behaviour:StageElementBehaviour,jump_limit:Option)->Self{ Self{ stage_id, force, behaviour, + jump_limit, } } #[inline] @@ -30,6 +32,10 @@ impl StageElement{ pub const fn behaviour(&self)->StageElementBehaviour{ self.behaviour } + #[inline] + pub const fn jump_limit(&self)->Option{ + self.jump_limit + } } #[derive(Clone,Copy,Hash,Eq,PartialEq)] @@ -128,7 +134,6 @@ pub struct Mode{ stages:Vec,//when you load the map you go to stages[0].spawn //mutually exlusive stage element behaviour elements:HashMap, - jump_limit:HashMap, } impl Mode{ pub fn new(style:gameplay_style::StyleModifiers,start:ModelId)->Self{ @@ -138,7 +143,6 @@ impl Mode{ zones:HashMap::new(), stages:Vec::new(), elements:HashMap::new(), - jump_limit:HashMap::new(), } } pub const fn get_start(&self)->ModelId{ @@ -165,9 +169,6 @@ impl Mode{ pub fn get_element(&self,model_id:ModelId)->Option<&StageElement>{ self.elements.get(&model_id) } - pub fn get_jump_limit(&self,model_id:ModelId)->Option{ - self.jump_limit.get(&model_id).copied() - } //TODO: put this in the SNF pub fn denormalize_data(&mut self){ //expand and index normalized data @@ -177,12 +178,14 @@ impl Mode{ stage_id:StageId(stage_id as u32), force:false, behaviour:StageElementBehaviour::SpawnAt, + jump_limit:None, }); for (_,&model) in &stage.ordered_checkpoints{ self.elements.insert(model,StageElement{ stage_id:StageId(stage_id as u32), force:false, behaviour:StageElementBehaviour::Checkpoint, + jump_limit:None, }); } for &model in &stage.unordered_checkpoints{ @@ -190,6 +193,7 @@ impl Mode{ stage_id:StageId(stage_id as u32), force:false, behaviour:StageElementBehaviour::Checkpoint, + jump_limit:None, }); } } @@ -202,7 +206,6 @@ pub struct ModeUpdate{ stages:HashMap, //mutually exlusive stage element behaviour elements:HashMap, - jump_limit:HashMap, } impl Updatable for Mode{ fn update(&mut self,update:ModeUpdate){ @@ -213,7 +216,6 @@ impl Updatable for Mode{ } } self.elements.extend(update.elements); - self.jump_limit.extend(update.jump_limit); } } impl ModeUpdate{ @@ -232,11 +234,6 @@ impl ModeUpdate{ mu.elements.insert(model_id,element); mu } - pub fn jump_limit(model_id:ModelId,jump_limit:u32)->Self{ - let mut mu=Self::default(); - mu.jump_limit.insert(model_id,jump_limit); - mu - } pub fn map_stage_element_idsStageId>(&mut self,f:F){ for (_,stage_element) in self.elements.iter_mut(){ stage_element.stage_id=f(stage_element.stage_id);