diff --git a/src/gameplay_attributes.rs b/src/gameplay_attributes.rs index 75e9024..92ee4dd 100644 --- a/src/gameplay_attributes.rs +++ b/src/gameplay_attributes.rs @@ -1,3 +1,4 @@ +use crate::model; use crate::integer::{Time,Planar64,Planar64Vec3}; //you have this effect while in contact @@ -77,7 +78,7 @@ pub struct Wormhole{ //destination does not need to be another wormhole //this defines a one way portal to a destination model transform //two of these can create a two way wormhole - pub destination_model_id:u32, + pub destination_model:model::ModelId, //(position,angles)*=origin.transform.inverse()*destination.transform } //attributes listed in order of handling @@ -132,6 +133,12 @@ impl IntersectingAttributes{ } } pub struct CollisionAttributesId(u32); +impl CollisionAttributesId{ + pub fn new(id:u32)->Self{ + Self(id) + } +} +#[derive(Clone,Hash,Eq,PartialEq)] pub enum CollisionAttributes{ Decoration,//visual only Contact{//track whether you are contacting the object diff --git a/src/gameplay_modes.rs b/src/gameplay_modes.rs index 5d6d032..e844fca 100644 --- a/src/gameplay_modes.rs +++ b/src/gameplay_modes.rs @@ -33,8 +33,16 @@ pub enum StageElementBehaviour{ #[derive(Clone,Copy,Hash,Eq,PartialEq)] pub struct CheckpointId(usize); -#[derive(Clone,Hash,Eq,PartialEq)] +#[derive(Clone,Hash,Eq,PartialEq,Ord,PartialOrd)] pub struct StageId(u32); +impl StageId{ + pub const fn id(id:u32)->Self{ + Self(id) + } + pub const fn get(self)->u32{ + self.0 + } +} pub struct Stage{ spawn:ModelId, //open world support lol @@ -43,6 +51,16 @@ pub struct Stage{ ordered_checkpoints:HashMap<CheckpointId,ModelId>, unordered_checkpoints:HashSet<ModelId>, } +impl Stage{ + pub fn new(spawn:ModelId)->Self{ + Self{ + spawn, + ordered_checkpoints_count:0, + ordered_checkpoints:HashMap::new(), + unordered_checkpoints:HashSet::new(), + } + } +} #[derive(Default)] pub struct StageUpdate{ //other behaviour models of this stage can have @@ -62,13 +80,16 @@ pub enum Zone{ Finish, Anticheat, } -#[derive(Clone,Hash,Eq,PartialEq)] +#[derive(Clone,Hash,Eq,PartialEq,Ord,PartialOrd)] pub struct ModeId(u32); impl ModeId{ pub const MAIN:Self=Self(0); pub const BONUS:Self=Self(1); - pub const fn mode(mode_id:u32)->Self{ - Self(mode_id) + pub const fn id(id:u32)->Self{ + Self(id) + } + pub const fn get(&self)->u32{ + self.0 } } pub struct Mode{ @@ -81,6 +102,22 @@ pub struct Mode{ jump_limit:HashMap<ModelId,u32>, } impl Mode{ + pub fn new(style:gameplay_style::StyleModifiers,start:ModelId)->Self{ + Self{ + style, + start, + zones:HashMap::new(), + stages:Vec::new(), + elements:HashMap::new(), + jump_limit:HashMap::new(), + } + } + pub fn push_stage(&mut self,stage:Stage){ + self.stages.push(stage) + } + pub fn get_stage_mut(&mut self,stage:StageId)->Option<&mut Stage>{ + self.stages.get_mut(stage.0 as usize) + } pub fn get_spawn_model_id(&self,stage:StageId)->Option<ModelId>{ self.stages.get(stage.0 as usize).map(|s|s.spawn) } @@ -165,6 +202,9 @@ impl Modes{ modes, } } + pub fn push_mode(&mut self,mode:Mode){ + self.modes.push(mode) + } pub fn get_mode(&self,mode:ModeId)->Option<&Mode>{ self.modes.get(mode.0 as usize) } diff --git a/src/gameplay_style.rs b/src/gameplay_style.rs index ea2bb0c..7c6c7fd 100644 --- a/src/gameplay_style.rs +++ b/src/gameplay_style.rs @@ -70,7 +70,7 @@ impl StyleModifiers{ } } - fn roblox_bhop()->Self{ + pub fn roblox_bhop()->Self{ Self{ controls_used:!0, controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN), diff --git a/src/map.rs b/src/map.rs index d85c28b..aa4f6bc 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,11 +1,11 @@ -use std::collections::HashMap; - use crate::model; use crate::gameplay_modes; +use crate::gameplay_attributes; //this is the current map data loaded in memory pub struct Map{ - modes:gameplay_modes::Modes, - models:model::Models, + pub modes:gameplay_modes::Modes, + pub models:model::Models, + pub attributes:Vec<gameplay_attributes::CollisionAttributes>, //RenderPattern - textures:HashMap<u32,Vec<u8>>, + pub textures:Vec<Vec<u8>>, } diff --git a/src/model.rs b/src/model.rs index f2f9033..87ca4dc 100644 --- a/src/model.rs +++ b/src/model.rs @@ -34,6 +34,11 @@ pub struct IndexedPhysicsGroup{ //This is a superset of PhysicsModel and GraphicsModel #[derive(Clone,Copy,Hash,Eq,PartialEq)] pub struct IndexedModelId(u32); +impl IndexedModelId{ + pub const fn new(id:u32)->Self{ + Self(id) + } +} pub struct IndexedModel{ pub unique_pos:Vec<Planar64Vec3>,//Unit32Vec3 pub unique_normal:Vec<Planar64Vec3>,//Unit32Vec3 @@ -50,6 +55,11 @@ pub struct IndexedModel{ #[derive(Clone,Copy,Hash,Eq,PartialEq)] pub struct ModelId(u32); +impl ModelId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} pub struct Model{ pub model:IndexedModelId, pub attributes:gameplay_attributes::CollisionAttributesId, @@ -61,6 +71,17 @@ pub struct Models{ indexed_models:HashMap<IndexedModelId,IndexedModel>, models:HashMap<ModelId,Model>, } +impl Models{ + pub fn new( + indexed_models:HashMap<IndexedModelId,IndexedModel>, + models:HashMap<ModelId,Model>, + )->Self{ + Self{ + indexed_models, + models, + } + } +} impl Updatable<Models> for Models{ fn update(&mut self,update:Models){ self.indexed_models.extend(update.indexed_models);