This commit is contained in:
Quaternions 2024-02-04 22:36:43 -08:00
parent 5efdd3654a
commit f7b774c050
2 changed files with 59 additions and 12 deletions

View File

@ -5,14 +5,14 @@ use crate::updatable::Updatable;
#[derive(Clone)]
pub struct StageElement{
pub stage:StageId,//which stage spawn to send to
pub stage_id:StageId,//which stage spawn to send to
pub force:bool,//allow setting to lower spawn id i.e. 7->3
pub behaviour:StageElementBehaviour
}
impl StageElement{
pub fn new(stage_id:u32,force:bool,behaviour:StageElementBehaviour)->Self{
Self{
stage:StageId(stage_id),
stage_id:StageId(stage_id),
force,
behaviour,
}
@ -32,13 +32,26 @@ pub enum StageElementBehaviour{
}
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
pub struct CheckpointId(usize);
#[derive(Clone,Copy,Hash,Eq,PartialEq,Ord,PartialOrd)]
pub struct StageId(u32);
impl StageId{
pub struct CheckpointId(u32);
impl CheckpointId{
#[inline]
pub const fn id(id:u32)->Self{
Self(id)
}
#[inline]
pub const fn get(self)->u32{
self.0
}
}
#[derive(Clone,Copy,Hash,Eq,PartialEq,Ord,PartialOrd)]
pub struct StageId(u32);
impl StageId{
pub const FIRST:Self=Self(0);
#[inline]
pub const fn id(id:u32)->Self{
Self(id)
}
#[inline]
pub const fn get(self)->u32{
self.0
}
@ -60,6 +73,10 @@ impl Stage{
unordered_checkpoints:HashSet::new(),
}
}
#[inline]
pub const fn spawn(&self)->ModelId{
self.spawn
}
}
#[derive(Default)]
pub struct StageUpdate{
@ -85,9 +102,11 @@ pub struct ModeId(u32);
impl ModeId{
pub const MAIN:Self=Self(0);
pub const BONUS:Self=Self(1);
#[inline]
pub const fn id(id:u32)->Self{
Self(id)
}
#[inline]
pub const fn get(&self)->u32{
self.0
}
@ -139,20 +158,20 @@ impl Mode{
self.zones.insert(self.start,Zone::Start);
for (stage_id,stage) in self.stages.iter().enumerate(){
self.elements.insert(stage.spawn,StageElement{
stage:StageId(stage_id as u32),
stage_id:StageId(stage_id as u32),
force:false,
behaviour:StageElementBehaviour::SpawnAt,
});
for (_,&model) in &stage.ordered_checkpoints{
self.elements.insert(model,StageElement{
stage:StageId(stage_id as u32),
stage_id:StageId(stage_id as u32),
force:false,
behaviour:StageElementBehaviour::Checkpoint,
});
}
for &model in &stage.unordered_checkpoints{
self.elements.insert(model,StageElement{
stage:StageId(stage_id as u32),
stage_id:StageId(stage_id as u32),
force:false,
behaviour:StageElementBehaviour::Checkpoint,
});

View File

@ -8,30 +8,50 @@ pub type Color4=glam::Vec4;
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
pub struct PositionId(u32);
impl PositionId{
#[inline]
pub const fn id(id:u32)->Self{
Self(id)
}
#[inline]
pub const fn get(self)->u32{
self.0
}
}
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
pub struct TextureCoordinateId(u32);
impl TextureCoordinateId{
#[inline]
pub const fn id(id:u32)->Self{
Self(id)
}
#[inline]
pub const fn get(self)->u32{
self.0
}
}
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
pub struct NormalId(u32);
impl NormalId{
#[inline]
pub const fn id(id:u32)->Self{
Self(id)
}
#[inline]
pub const fn get(self)->u32{
self.0
}
}
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
pub struct ColorId(u32);
impl ColorId{
#[inline]
pub const fn id(id:u32)->Self{
Self(id)
}
#[inline]
pub const fn get(self)->u32{
self.0
}
}
#[derive(Clone,Hash,PartialEq,Eq)]
pub struct IndexedVertex{
@ -43,9 +63,14 @@ pub struct IndexedVertex{
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
pub struct VertexId(u32);
impl VertexId{
#[inline]
pub const fn id(id:u32)->Self{
Self(id)
}
#[inline]
pub const fn get(self)->u32{
self.0
}
}
pub struct IndexedVertexList{
pub vertices:Vec<VertexId>,
@ -119,12 +144,15 @@ pub struct IndexedModel{
pub physics_groups:Vec<IndexedPhysicsGroup>,
}
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
pub struct ModelId(u32);
impl ModelId{
pub const fn id(id:u32)->Self{
Self(id)
}
pub const fn get(&self)->u32{
self.0
}
}
pub struct Model{
pub model:IndexedModelId,
@ -134,8 +162,8 @@ pub struct Model{
}
pub struct Models{
indexed_models:HashMap<IndexedModelId,IndexedModel>,
models:HashMap<ModelId,Model>,
pub indexed_models:HashMap<IndexedModelId,IndexedModel>,
pub models:HashMap<ModelId,Model>,
}
impl Models{
pub fn new(