wip
This commit is contained in:
parent
5efdd3654a
commit
f7b774c050
@ -5,14 +5,14 @@ use crate::updatable::Updatable;
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StageElement{
|
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 force:bool,//allow setting to lower spawn id i.e. 7->3
|
||||||
pub behaviour:StageElementBehaviour
|
pub behaviour:StageElementBehaviour
|
||||||
}
|
}
|
||||||
impl StageElement{
|
impl StageElement{
|
||||||
pub fn new(stage_id:u32,force:bool,behaviour:StageElementBehaviour)->Self{
|
pub fn new(stage_id:u32,force:bool,behaviour:StageElementBehaviour)->Self{
|
||||||
Self{
|
Self{
|
||||||
stage:StageId(stage_id),
|
stage_id:StageId(stage_id),
|
||||||
force,
|
force,
|
||||||
behaviour,
|
behaviour,
|
||||||
}
|
}
|
||||||
@ -32,13 +32,26 @@ pub enum StageElementBehaviour{
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
||||||
pub struct CheckpointId(usize);
|
pub struct CheckpointId(u32);
|
||||||
#[derive(Clone,Copy,Hash,Eq,PartialEq,Ord,PartialOrd)]
|
impl CheckpointId{
|
||||||
pub struct StageId(u32);
|
#[inline]
|
||||||
impl StageId{
|
|
||||||
pub const fn id(id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(id)
|
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{
|
pub const fn get(self)->u32{
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
@ -60,6 +73,10 @@ impl Stage{
|
|||||||
unordered_checkpoints:HashSet::new(),
|
unordered_checkpoints:HashSet::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn spawn(&self)->ModelId{
|
||||||
|
self.spawn
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct StageUpdate{
|
pub struct StageUpdate{
|
||||||
@ -85,9 +102,11 @@ pub struct ModeId(u32);
|
|||||||
impl ModeId{
|
impl ModeId{
|
||||||
pub const MAIN:Self=Self(0);
|
pub const MAIN:Self=Self(0);
|
||||||
pub const BONUS:Self=Self(1);
|
pub const BONUS:Self=Self(1);
|
||||||
|
#[inline]
|
||||||
pub const fn id(id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(id)
|
Self(id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub const fn get(&self)->u32{
|
pub const fn get(&self)->u32{
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
@ -139,20 +158,20 @@ impl Mode{
|
|||||||
self.zones.insert(self.start,Zone::Start);
|
self.zones.insert(self.start,Zone::Start);
|
||||||
for (stage_id,stage) in self.stages.iter().enumerate(){
|
for (stage_id,stage) in self.stages.iter().enumerate(){
|
||||||
self.elements.insert(stage.spawn,StageElement{
|
self.elements.insert(stage.spawn,StageElement{
|
||||||
stage:StageId(stage_id as u32),
|
stage_id:StageId(stage_id as u32),
|
||||||
force:false,
|
force:false,
|
||||||
behaviour:StageElementBehaviour::SpawnAt,
|
behaviour:StageElementBehaviour::SpawnAt,
|
||||||
});
|
});
|
||||||
for (_,&model) in &stage.ordered_checkpoints{
|
for (_,&model) in &stage.ordered_checkpoints{
|
||||||
self.elements.insert(model,StageElement{
|
self.elements.insert(model,StageElement{
|
||||||
stage:StageId(stage_id as u32),
|
stage_id:StageId(stage_id as u32),
|
||||||
force:false,
|
force:false,
|
||||||
behaviour:StageElementBehaviour::Checkpoint,
|
behaviour:StageElementBehaviour::Checkpoint,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for &model in &stage.unordered_checkpoints{
|
for &model in &stage.unordered_checkpoints{
|
||||||
self.elements.insert(model,StageElement{
|
self.elements.insert(model,StageElement{
|
||||||
stage:StageId(stage_id as u32),
|
stage_id:StageId(stage_id as u32),
|
||||||
force:false,
|
force:false,
|
||||||
behaviour:StageElementBehaviour::Checkpoint,
|
behaviour:StageElementBehaviour::Checkpoint,
|
||||||
});
|
});
|
||||||
|
34
src/model.rs
34
src/model.rs
@ -8,30 +8,50 @@ pub type Color4=glam::Vec4;
|
|||||||
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
||||||
pub struct PositionId(u32);
|
pub struct PositionId(u32);
|
||||||
impl PositionId{
|
impl PositionId{
|
||||||
|
#[inline]
|
||||||
pub const fn id(id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(id)
|
Self(id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn get(self)->u32{
|
||||||
|
self.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
||||||
pub struct TextureCoordinateId(u32);
|
pub struct TextureCoordinateId(u32);
|
||||||
impl TextureCoordinateId{
|
impl TextureCoordinateId{
|
||||||
|
#[inline]
|
||||||
pub const fn id(id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(id)
|
Self(id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn get(self)->u32{
|
||||||
|
self.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
||||||
pub struct NormalId(u32);
|
pub struct NormalId(u32);
|
||||||
impl NormalId{
|
impl NormalId{
|
||||||
|
#[inline]
|
||||||
pub const fn id(id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(id)
|
Self(id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn get(self)->u32{
|
||||||
|
self.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
||||||
pub struct ColorId(u32);
|
pub struct ColorId(u32);
|
||||||
impl ColorId{
|
impl ColorId{
|
||||||
|
#[inline]
|
||||||
pub const fn id(id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(id)
|
Self(id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn get(self)->u32{
|
||||||
|
self.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[derive(Clone,Hash,PartialEq,Eq)]
|
#[derive(Clone,Hash,PartialEq,Eq)]
|
||||||
pub struct IndexedVertex{
|
pub struct IndexedVertex{
|
||||||
@ -43,9 +63,14 @@ pub struct IndexedVertex{
|
|||||||
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
#[derive(Clone,Copy,Hash,PartialEq,Eq)]
|
||||||
pub struct VertexId(u32);
|
pub struct VertexId(u32);
|
||||||
impl VertexId{
|
impl VertexId{
|
||||||
|
#[inline]
|
||||||
pub const fn id(id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(id)
|
Self(id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
|
pub const fn get(self)->u32{
|
||||||
|
self.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub struct IndexedVertexList{
|
pub struct IndexedVertexList{
|
||||||
pub vertices:Vec<VertexId>,
|
pub vertices:Vec<VertexId>,
|
||||||
@ -119,12 +144,15 @@ pub struct IndexedModel{
|
|||||||
pub physics_groups:Vec<IndexedPhysicsGroup>,
|
pub physics_groups:Vec<IndexedPhysicsGroup>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||||
pub struct ModelId(u32);
|
pub struct ModelId(u32);
|
||||||
impl ModelId{
|
impl ModelId{
|
||||||
pub const fn id(id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(id)
|
Self(id)
|
||||||
}
|
}
|
||||||
|
pub const fn get(&self)->u32{
|
||||||
|
self.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub struct Model{
|
pub struct Model{
|
||||||
pub model:IndexedModelId,
|
pub model:IndexedModelId,
|
||||||
@ -134,8 +162,8 @@ pub struct Model{
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Models{
|
pub struct Models{
|
||||||
indexed_models:HashMap<IndexedModelId,IndexedModel>,
|
pub indexed_models:HashMap<IndexedModelId,IndexedModel>,
|
||||||
models:HashMap<ModelId,Model>,
|
pub models:HashMap<ModelId,Model>,
|
||||||
}
|
}
|
||||||
impl Models{
|
impl Models{
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
Loading…
Reference in New Issue
Block a user