work
This commit is contained in:
parent
9291b77679
commit
96d813a3a6
@ -1,3 +1,4 @@
|
|||||||
|
use crate::model;
|
||||||
use crate::integer::{Time,Planar64,Planar64Vec3};
|
use crate::integer::{Time,Planar64,Planar64Vec3};
|
||||||
|
|
||||||
//you have this effect while in contact
|
//you have this effect while in contact
|
||||||
@ -77,7 +78,7 @@ pub struct Wormhole{
|
|||||||
//destination does not need to be another wormhole
|
//destination does not need to be another wormhole
|
||||||
//this defines a one way portal to a destination model transform
|
//this defines a one way portal to a destination model transform
|
||||||
//two of these can create a two way wormhole
|
//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
|
//(position,angles)*=origin.transform.inverse()*destination.transform
|
||||||
}
|
}
|
||||||
//attributes listed in order of handling
|
//attributes listed in order of handling
|
||||||
@ -132,6 +133,12 @@ impl IntersectingAttributes{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct CollisionAttributesId(u32);
|
pub struct CollisionAttributesId(u32);
|
||||||
|
impl CollisionAttributesId{
|
||||||
|
pub fn new(id:u32)->Self{
|
||||||
|
Self(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[derive(Clone,Hash,Eq,PartialEq)]
|
||||||
pub enum CollisionAttributes{
|
pub enum CollisionAttributes{
|
||||||
Decoration,//visual only
|
Decoration,//visual only
|
||||||
Contact{//track whether you are contacting the object
|
Contact{//track whether you are contacting the object
|
||||||
|
@ -5,9 +5,9 @@ use crate::updatable::Updatable;
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StageElement{
|
pub struct StageElement{
|
||||||
stage:StageId,//which stage spawn to send to
|
pub stage:StageId,//which stage spawn to send to
|
||||||
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
|
||||||
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{
|
||||||
@ -33,8 +33,16 @@ pub enum StageElementBehaviour{
|
|||||||
|
|
||||||
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
||||||
pub struct CheckpointId(usize);
|
pub struct CheckpointId(usize);
|
||||||
#[derive(Clone,Hash,Eq,PartialEq)]
|
#[derive(Clone,Hash,Eq,PartialEq,Ord,PartialOrd)]
|
||||||
pub struct StageId(u32);
|
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{
|
pub struct Stage{
|
||||||
spawn:ModelId,
|
spawn:ModelId,
|
||||||
//open world support lol
|
//open world support lol
|
||||||
@ -43,6 +51,16 @@ pub struct Stage{
|
|||||||
ordered_checkpoints:HashMap<CheckpointId,ModelId>,
|
ordered_checkpoints:HashMap<CheckpointId,ModelId>,
|
||||||
unordered_checkpoints:HashSet<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)]
|
#[derive(Default)]
|
||||||
pub struct StageUpdate{
|
pub struct StageUpdate{
|
||||||
//other behaviour models of this stage can have
|
//other behaviour models of this stage can have
|
||||||
@ -62,13 +80,16 @@ pub enum Zone{
|
|||||||
Finish,
|
Finish,
|
||||||
Anticheat,
|
Anticheat,
|
||||||
}
|
}
|
||||||
#[derive(Clone,Hash,Eq,PartialEq)]
|
#[derive(Clone,Hash,Eq,PartialEq,Ord,PartialOrd)]
|
||||||
pub struct ModeId(u32);
|
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);
|
||||||
pub const fn mode(mode_id:u32)->Self{
|
pub const fn id(id:u32)->Self{
|
||||||
Self(mode_id)
|
Self(id)
|
||||||
|
}
|
||||||
|
pub const fn get(&self)->u32{
|
||||||
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct Mode{
|
pub struct Mode{
|
||||||
@ -81,9 +102,37 @@ pub struct Mode{
|
|||||||
jump_limit:HashMap<ModelId,u32>,
|
jump_limit:HashMap<ModelId,u32>,
|
||||||
}
|
}
|
||||||
impl Mode{
|
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>{
|
pub fn get_spawn_model_id(&self,stage:StageId)->Option<ModelId>{
|
||||||
self.stages.get(stage.0 as usize).map(|s|s.spawn)
|
self.stages.get(stage.0 as usize).map(|s|s.spawn)
|
||||||
}
|
}
|
||||||
|
pub fn get_zone(&self,model_id:ModelId)->Option<&Zone>{
|
||||||
|
self.zones.get(&model_id)
|
||||||
|
}
|
||||||
|
pub fn get_stage(&self,stage_id:StageId)->Option<&Stage>{
|
||||||
|
self.stages.get(stage_id.0 as usize)
|
||||||
|
}
|
||||||
|
pub fn get_element(&self,model_id:ModelId)->Option<&StageElement>{
|
||||||
|
self.elements.get(&model_id)
|
||||||
|
}
|
||||||
|
pub fn get_jump_limit(&self,model_id:ModelId)->Option<u32>{
|
||||||
|
self.jump_limit.get(&model_id).copied()
|
||||||
|
}
|
||||||
//TODO: put this in the SNF
|
//TODO: put this in the SNF
|
||||||
pub fn denormalize_data(&mut self){
|
pub fn denormalize_data(&mut self){
|
||||||
//expand and index normalized data
|
//expand and index normalized data
|
||||||
@ -165,6 +214,9 @@ impl Modes{
|
|||||||
modes,
|
modes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn push_mode(&mut self,mode:Mode){
|
||||||
|
self.modes.push(mode)
|
||||||
|
}
|
||||||
pub fn get_mode(&self,mode:ModeId)->Option<&Mode>{
|
pub fn get_mode(&self,mode:ModeId)->Option<&Mode>{
|
||||||
self.modes.get(mode.0 as usize)
|
self.modes.get(mode.0 as usize)
|
||||||
}
|
}
|
||||||
|
@ -3,26 +3,26 @@ const VALVE_SCALE:i64=16;
|
|||||||
use crate::integer::{Time,Ratio64,Planar64,Planar64Vec3};
|
use crate::integer::{Time,Ratio64,Planar64,Planar64Vec3};
|
||||||
|
|
||||||
pub struct StyleModifiers{
|
pub struct StyleModifiers{
|
||||||
controls_used:u32,//controls which are allowed to pass into gameplay
|
pub controls_used:u32,//controls which are allowed to pass into gameplay
|
||||||
controls_mask:u32,//controls which are masked from control state (e.g. jump in scroll style)
|
pub controls_mask:u32,//controls which are masked from control state (e.g. jump in scroll style)
|
||||||
strafe:Option<StrafeSettings>,
|
pub strafe:Option<StrafeSettings>,
|
||||||
jump_impulse:JumpImpulse,
|
pub jump_impulse:JumpImpulse,
|
||||||
jump_calculation:JumpCalculation,
|
pub jump_calculation:JumpCalculation,
|
||||||
static_friction:Planar64,
|
pub static_friction:Planar64,
|
||||||
kinetic_friction:Planar64,
|
pub kinetic_friction:Planar64,
|
||||||
walk_speed:Planar64,
|
pub walk_speed:Planar64,
|
||||||
walk_accel:Planar64,
|
pub walk_accel:Planar64,
|
||||||
ladder_speed:Planar64,
|
pub ladder_speed:Planar64,
|
||||||
ladder_accel:Planar64,
|
pub ladder_accel:Planar64,
|
||||||
ladder_dot:Planar64,
|
pub ladder_dot:Planar64,
|
||||||
swim_speed:Planar64,
|
pub swim_speed:Planar64,
|
||||||
mass:Planar64,
|
pub mass:Planar64,
|
||||||
mv:Planar64,
|
pub mv:Planar64,
|
||||||
surf_slope:Option<Planar64>,
|
pub surf_slope:Option<Planar64>,
|
||||||
rocket_force:Option<Planar64>,
|
pub rocket_force:Option<Planar64>,
|
||||||
gravity:Planar64Vec3,
|
pub gravity:Planar64Vec3,
|
||||||
hitbox:Hitbox,
|
pub hitbox:Hitbox,
|
||||||
camera_offset:Planar64Vec3,
|
pub camera_offset:Planar64Vec3,
|
||||||
}
|
}
|
||||||
impl std::default::Default for StyleModifiers{
|
impl std::default::Default for StyleModifiers{
|
||||||
fn default()->Self{
|
fn default()->Self{
|
||||||
@ -30,18 +30,18 @@ impl std::default::Default for StyleModifiers{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl StyleModifiers{
|
impl StyleModifiers{
|
||||||
const CONTROL_MOVEFORWARD:u32=0b00000001;
|
pub const CONTROL_MOVEFORWARD:u32=0b00000001;
|
||||||
const CONTROL_MOVEBACK:u32=0b00000010;
|
pub const CONTROL_MOVEBACK:u32=0b00000010;
|
||||||
const CONTROL_MOVERIGHT:u32=0b00000100;
|
pub const CONTROL_MOVERIGHT:u32=0b00000100;
|
||||||
const CONTROL_MOVELEFT:u32=0b00001000;
|
pub const CONTROL_MOVELEFT:u32=0b00001000;
|
||||||
const CONTROL_MOVEUP:u32=0b00010000;
|
pub const CONTROL_MOVEUP:u32=0b00010000;
|
||||||
const CONTROL_MOVEDOWN:u32=0b00100000;
|
pub const CONTROL_MOVEDOWN:u32=0b00100000;
|
||||||
const CONTROL_JUMP:u32=0b01000000;
|
pub const CONTROL_JUMP:u32=0b01000000;
|
||||||
const CONTROL_ZOOM:u32=0b10000000;
|
pub const CONTROL_ZOOM:u32=0b10000000;
|
||||||
|
|
||||||
const RIGHT_DIR:Planar64Vec3=Planar64Vec3::X;
|
pub const RIGHT_DIR:Planar64Vec3=Planar64Vec3::X;
|
||||||
const UP_DIR:Planar64Vec3=Planar64Vec3::Y;
|
pub const UP_DIR:Planar64Vec3=Planar64Vec3::Y;
|
||||||
const FORWARD_DIR:Planar64Vec3=Planar64Vec3::NEG_Z;
|
pub const FORWARD_DIR:Planar64Vec3=Planar64Vec3::NEG_Z;
|
||||||
|
|
||||||
fn neo()->Self{
|
fn neo()->Self{
|
||||||
Self{
|
Self{
|
||||||
@ -72,7 +72,7 @@ impl StyleModifiers{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn roblox_bhop()->Self{
|
pub fn roblox_bhop()->Self{
|
||||||
Self{
|
Self{
|
||||||
controls_used:!0,
|
controls_used:!0,
|
||||||
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
||||||
@ -211,13 +211,13 @@ impl StyleModifiers{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum JumpCalculation{
|
pub enum JumpCalculation{
|
||||||
Capped,//roblox
|
Capped,//roblox
|
||||||
Energy,//new
|
Energy,//new
|
||||||
Linear,//source
|
Linear,//source
|
||||||
}
|
}
|
||||||
|
|
||||||
enum JumpImpulse{
|
pub enum JumpImpulse{
|
||||||
FromTime(Time),//jump time is invariant across mass and gravity changes
|
FromTime(Time),//jump time is invariant across mass and gravity changes
|
||||||
FromHeight(Planar64),//jump height is invariant across mass and gravity changes
|
FromHeight(Planar64),//jump height is invariant across mass and gravity changes
|
||||||
FromDeltaV(Planar64),//jump velocity is invariant across mass and gravity changes
|
FromDeltaV(Planar64),//jump velocity is invariant across mass and gravity changes
|
||||||
@ -228,20 +228,32 @@ enum JumpImpulse{
|
|||||||
//Energy means it adds energy
|
//Energy means it adds energy
|
||||||
//Linear means it linearly adds on
|
//Linear means it linearly adds on
|
||||||
|
|
||||||
enum EnableStrafe{
|
pub enum EnableStrafe{
|
||||||
Always,
|
Always,
|
||||||
MaskAny(u32),//hsw, shsw
|
MaskAny(u32),//hsw, shsw
|
||||||
MaskAll(u32),
|
MaskAll(u32),
|
||||||
//Function(Box<dyn Fn(u32)->bool>),
|
//Function(Box<dyn Fn(u32)->bool>),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StrafeSettings{
|
pub struct StrafeSettings{
|
||||||
enable:EnableStrafe,
|
enable:EnableStrafe,
|
||||||
air_accel_limit:Option<Planar64>,
|
air_accel_limit:Option<Planar64>,
|
||||||
tick_rate:Ratio64,
|
tick_rate:Ratio64,
|
||||||
}
|
}
|
||||||
|
impl StrafeSettings{
|
||||||
|
pub fn next_tick(&self,time:Time)->Time{
|
||||||
|
Time::from_nanos(self.tick_rate.rhs_div_int(self.tick_rate.mul_int(time.nanos())+1))
|
||||||
|
}
|
||||||
|
pub fn mask(&self,controls:u32)->bool{
|
||||||
|
match self.enable{
|
||||||
|
EnableStrafe::Always=>true,
|
||||||
|
EnableStrafe::MaskAny(mask)=>mask&controls!=0,
|
||||||
|
EnableStrafe::MaskAll(mask)=>mask&controls==mask,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum HitboxMesh{
|
pub enum HitboxMesh{
|
||||||
Box,//source
|
Box,//source
|
||||||
Cylinder,//roblox
|
Cylinder,//roblox
|
||||||
//Sphere,//roblox old physics
|
//Sphere,//roblox old physics
|
||||||
@ -250,9 +262,9 @@ enum HitboxMesh{
|
|||||||
//DualCone,
|
//DualCone,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Hitbox{
|
pub struct Hitbox{
|
||||||
halfsize:Planar64Vec3,
|
pub halfsize:Planar64Vec3,
|
||||||
mesh:HitboxMesh,
|
pub mesh:HitboxMesh,
|
||||||
}
|
}
|
||||||
impl Hitbox{
|
impl Hitbox{
|
||||||
fn roblox()->Self{
|
fn roblox()->Self{
|
||||||
|
10
src/map.rs
10
src/map.rs
@ -1,11 +1,11 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use crate::model;
|
use crate::model;
|
||||||
use crate::gameplay_modes;
|
use crate::gameplay_modes;
|
||||||
|
use crate::gameplay_attributes;
|
||||||
//this is the current map data loaded in memory
|
//this is the current map data loaded in memory
|
||||||
pub struct Map{
|
pub struct Map{
|
||||||
modes:gameplay_modes::Modes,
|
pub modes:gameplay_modes::Modes,
|
||||||
models:model::Models,
|
pub models:model::Models,
|
||||||
|
pub attributes:Vec<gameplay_attributes::CollisionAttributes>,
|
||||||
//RenderPattern
|
//RenderPattern
|
||||||
textures:HashMap<u32,Vec<u8>>,
|
pub textures:Vec<Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
21
src/model.rs
21
src/model.rs
@ -34,6 +34,11 @@ pub struct IndexedPhysicsGroup{
|
|||||||
//This is a superset of PhysicsModel and GraphicsModel
|
//This is a superset of PhysicsModel and GraphicsModel
|
||||||
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
||||||
pub struct IndexedModelId(u32);
|
pub struct IndexedModelId(u32);
|
||||||
|
impl IndexedModelId{
|
||||||
|
pub const fn id(id:u32)->Self{
|
||||||
|
Self(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
pub struct IndexedModel{
|
pub struct IndexedModel{
|
||||||
pub unique_pos:Vec<Planar64Vec3>,//Unit32Vec3
|
pub unique_pos:Vec<Planar64Vec3>,//Unit32Vec3
|
||||||
pub unique_normal:Vec<Planar64Vec3>,//Unit32Vec3
|
pub unique_normal:Vec<Planar64Vec3>,//Unit32Vec3
|
||||||
@ -50,6 +55,11 @@ pub struct IndexedModel{
|
|||||||
|
|
||||||
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
||||||
pub struct ModelId(u32);
|
pub struct ModelId(u32);
|
||||||
|
impl ModelId{
|
||||||
|
pub const fn id(id:u32)->Self{
|
||||||
|
Self(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
pub struct Model{
|
pub struct Model{
|
||||||
pub model:IndexedModelId,
|
pub model:IndexedModelId,
|
||||||
pub attributes:gameplay_attributes::CollisionAttributesId,
|
pub attributes:gameplay_attributes::CollisionAttributesId,
|
||||||
@ -61,6 +71,17 @@ pub struct Models{
|
|||||||
indexed_models:HashMap<IndexedModelId,IndexedModel>,
|
indexed_models:HashMap<IndexedModelId,IndexedModel>,
|
||||||
models:HashMap<ModelId,Model>,
|
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{
|
impl Updatable<Models> for Models{
|
||||||
fn update(&mut self,update:Models){
|
fn update(&mut self,update:Models){
|
||||||
self.indexed_models.extend(update.indexed_models);
|
self.indexed_models.extend(update.indexed_models);
|
||||||
|
Loading…
Reference in New Issue
Block a user