compiles
This commit is contained in:
parent
41d1904f08
commit
2ddb546f73
@ -5,21 +5,34 @@ use crate::updatable::Updatable;
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StageElement{
|
pub struct StageElement{
|
||||||
pub stage_id:StageId,//which stage spawn to send to
|
stage_id:StageId,//which stage spawn to send to
|
||||||
pub force:bool,//allow setting to lower spawn id i.e. 7->3
|
force:bool,//allow setting to lower spawn id i.e. 7->3
|
||||||
pub behaviour:StageElementBehaviour
|
behaviour:StageElementBehaviour
|
||||||
}
|
}
|
||||||
impl StageElement{
|
impl StageElement{
|
||||||
pub fn new(stage_id:u32,force:bool,behaviour:StageElementBehaviour)->Self{
|
#[inline]
|
||||||
|
pub const fn new(stage_id:u32,force:bool,behaviour:StageElementBehaviour)->Self{
|
||||||
Self{
|
Self{
|
||||||
stage_id:StageId(stage_id),
|
stage_id:StageId(stage_id),
|
||||||
force,
|
force,
|
||||||
behaviour,
|
behaviour,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn stage_id(&self)->StageId{
|
||||||
|
self.stage_id
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn force(&self)->bool{
|
||||||
|
self.force
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn behaviour(&self)->StageElementBehaviour{
|
||||||
|
self.behaviour
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Hash,Eq,PartialEq)]
|
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
||||||
pub enum StageElementBehaviour{
|
pub enum StageElementBehaviour{
|
||||||
SpawnAt,//must be standing on top to get effect. except cancollide false
|
SpawnAt,//must be standing on top to get effect. except cancollide false
|
||||||
Trigger,
|
Trigger,
|
||||||
@ -33,6 +46,9 @@ pub enum StageElementBehaviour{
|
|||||||
|
|
||||||
#[derive(Clone,Copy,Hash,id::Id,Eq,PartialEq)]
|
#[derive(Clone,Copy,Hash,id::Id,Eq,PartialEq)]
|
||||||
pub struct CheckpointId(u32);
|
pub struct CheckpointId(u32);
|
||||||
|
impl CheckpointId{
|
||||||
|
pub const FIRST:Self=Self(0);
|
||||||
|
}
|
||||||
#[derive(Clone,Copy,Hash,id::Id,Eq,PartialEq,Ord,PartialOrd)]
|
#[derive(Clone,Copy,Hash,id::Id,Eq,PartialEq,Ord,PartialOrd)]
|
||||||
pub struct StageId(u32);
|
pub struct StageId(u32);
|
||||||
impl StageId{
|
impl StageId{
|
||||||
@ -43,7 +59,8 @@ pub struct Stage{
|
|||||||
spawn:ModelId,
|
spawn:ModelId,
|
||||||
//open world support lol
|
//open world support lol
|
||||||
ordered_checkpoints_count:u32,
|
ordered_checkpoints_count:u32,
|
||||||
//other behaviour models of this stage can have
|
unordered_checkpoints_count:u32,
|
||||||
|
//currently loaded checkpoint models
|
||||||
ordered_checkpoints:HashMap<CheckpointId,ModelId>,
|
ordered_checkpoints:HashMap<CheckpointId,ModelId>,
|
||||||
unordered_checkpoints:HashSet<ModelId>,
|
unordered_checkpoints:HashSet<ModelId>,
|
||||||
}
|
}
|
||||||
@ -52,6 +69,7 @@ impl Stage{
|
|||||||
Self{
|
Self{
|
||||||
spawn,
|
spawn,
|
||||||
ordered_checkpoints_count:0,
|
ordered_checkpoints_count:0,
|
||||||
|
unordered_checkpoints_count:0,
|
||||||
ordered_checkpoints:HashMap::new(),
|
ordered_checkpoints:HashMap::new(),
|
||||||
unordered_checkpoints:HashSet::new(),
|
unordered_checkpoints:HashSet::new(),
|
||||||
}
|
}
|
||||||
@ -60,6 +78,22 @@ impl Stage{
|
|||||||
pub const fn spawn(&self)->ModelId{
|
pub const fn spawn(&self)->ModelId{
|
||||||
self.spawn
|
self.spawn
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn is_empty(&self)->bool{
|
||||||
|
self.is_complete(0,0)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn is_complete(&self,ordered_checkpoints_count:u32,unordered_checkpoints_count:u32)->bool{
|
||||||
|
self.ordered_checkpoints_count==ordered_checkpoints_count&&self.unordered_checkpoints_count==unordered_checkpoints_count
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn is_next_ordered_checkpoint(&self,next_ordered_checkpoint_id:CheckpointId,model_id:ModelId)->bool{
|
||||||
|
self.ordered_checkpoints.get(&next_ordered_checkpoint_id).is_some_and(|&next_checkpoint|model_id==next_checkpoint)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn is_unordered_checkpoint(&self,model_id:ModelId)->bool{
|
||||||
|
self.unordered_checkpoints.contains(&model_id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct StageUpdate{
|
pub struct StageUpdate{
|
||||||
|
@ -294,6 +294,7 @@ impl std::ops::Mul<i64> for Ratio64Vec2{
|
|||||||
pub struct Angle32(i32);
|
pub struct Angle32(i32);
|
||||||
impl Angle32{
|
impl Angle32{
|
||||||
pub const FRAC_PI_2:Self=Self(1<<30);
|
pub const FRAC_PI_2:Self=Self(1<<30);
|
||||||
|
pub const NEG_FRAC_PI_2:Self=Self(-1<<30);
|
||||||
pub const PI:Self=Self(-1<<31);
|
pub const PI:Self=Self(-1<<31);
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn wrap_from_i64(theta:i64)->Self{
|
pub const fn wrap_from_i64(theta:i64)->Self{
|
||||||
|
Loading…
Reference in New Issue
Block a user