try_increment_jump_count monolithic function
This commit is contained in:
parent
62dfe23539
commit
4dca7fc369
@ -326,6 +326,15 @@ impl std::default::Default for PhysicsCamera{
|
|||||||
}
|
}
|
||||||
mod gameplay{
|
mod gameplay{
|
||||||
use super::{gameplay_modes,HashSet,HashMap,ModelId};
|
use super::{gameplay_modes,HashSet,HashMap,ModelId};
|
||||||
|
pub enum JumpIncrementResult{
|
||||||
|
Allowed,
|
||||||
|
ExceededLimit,
|
||||||
|
}
|
||||||
|
impl JumpIncrementResult{
|
||||||
|
pub const fn is_allowed(self)->bool{
|
||||||
|
matches!(self,JumpIncrementResult::Allowed)
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct ModeState{
|
pub struct ModeState{
|
||||||
mode_id:gameplay_modes::ModeId,
|
mode_id:gameplay_modes::ModeId,
|
||||||
@ -344,8 +353,14 @@ mod gameplay{
|
|||||||
pub const fn get_next_ordered_checkpoint_id(&self)->gameplay_modes::CheckpointId{
|
pub const fn get_next_ordered_checkpoint_id(&self)->gameplay_modes::CheckpointId{
|
||||||
self.next_ordered_checkpoint_id
|
self.next_ordered_checkpoint_id
|
||||||
}
|
}
|
||||||
pub fn get_jump_count(&self,model_id:ModelId)->Option<u32>{
|
fn increment_jump_count(&mut self,model_id:ModelId)->u32{
|
||||||
self.jump_counts.get(&model_id).copied()
|
*self.jump_counts.entry(model_id).and_modify(|c|*c+=1).or_insert(1)
|
||||||
|
}
|
||||||
|
pub fn try_increment_jump_count(&mut self,model_id:ModelId,jump_limit:Option<u8>)->JumpIncrementResult{
|
||||||
|
match jump_limit{
|
||||||
|
Some(jump_limit) if (jump_limit as u32)<self.increment_jump_count(model_id)=>JumpIncrementResult::ExceededLimit,
|
||||||
|
_=>JumpIncrementResult::Allowed,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub const fn ordered_checkpoint_count(&self)->u32{
|
pub const fn ordered_checkpoint_count(&self)->u32{
|
||||||
self.next_ordered_checkpoint_id.get()
|
self.next_ordered_checkpoint_id.get()
|
||||||
|
Loading…
Reference in New Issue
Block a user