newtypes
This commit is contained in:
parent
9cc099a6eb
commit
50d1a3188e
@ -5,6 +5,13 @@ use super::integer::{Time,Planar64,Planar64Vec3};
|
||||
pub struct ContactingLadder{
|
||||
pub sticky:Option<()>,
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::ContactingLadder> for ContactingLadder{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::ContactingLadder{
|
||||
strafesnet_common::gameplay_attributes::ContactingLadder{
|
||||
sticky:self.sticky.is_some(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -15,6 +22,24 @@ pub enum ContactingBehaviour{
|
||||
Cling,
|
||||
Elastic(u32),
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::ContactingBehaviour> for ContactingBehaviour{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::ContactingBehaviour{
|
||||
match self{
|
||||
ContactingBehaviour::Surf=>
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::Surf,
|
||||
ContactingBehaviour::Ladder(contacting_ladder)=>
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::Ladder(
|
||||
contacting_ladder.into(),
|
||||
),
|
||||
ContactingBehaviour::NoJump=>
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::NoJump,
|
||||
ContactingBehaviour::Cling=>
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::Cling,
|
||||
ContactingBehaviour::Elastic(elasticity)=>
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::Elastic(elasticity),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -23,12 +48,28 @@ pub struct IntersectingWater{
|
||||
pub density:Planar64,
|
||||
pub velocity:Planar64Vec3,
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::IntersectingWater> for IntersectingWater{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::IntersectingWater{
|
||||
strafesnet_common::gameplay_attributes::IntersectingWater{
|
||||
viscosity:strafesnet_common::integer::Planar64::raw(self.viscosity),
|
||||
density:strafesnet_common::integer::Planar64::raw(self.density),
|
||||
velocity:strafesnet_common::integer::Planar64Vec3::raw_array(self.velocity),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub struct Accelerator{
|
||||
pub acceleration:Planar64Vec3
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::Accelerator> for Accelerator{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::Accelerator{
|
||||
strafesnet_common::gameplay_attributes::Accelerator{
|
||||
acceleration:strafesnet_common::integer::Planar64Vec3::raw_array(self.acceleration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -36,6 +77,21 @@ pub enum Booster{
|
||||
Velocity(Planar64Vec3),
|
||||
Energy{direction:Planar64Vec3,energy:Planar64},
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::Booster> for Booster{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::Booster{
|
||||
match self{
|
||||
Booster::Velocity(velocity)=>
|
||||
strafesnet_common::gameplay_attributes::Booster::Velocity(
|
||||
strafesnet_common::integer::Planar64Vec3::raw_array(velocity)
|
||||
),
|
||||
Booster::Energy{direction,energy}=>
|
||||
strafesnet_common::gameplay_attributes::Booster::Energy{
|
||||
direction:strafesnet_common::integer::Planar64Vec3::raw_array(direction),
|
||||
energy:strafesnet_common::integer::Planar64::raw(energy)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little,repr=u8)]
|
||||
@ -43,6 +99,16 @@ pub enum TrajectoryChoice{
|
||||
HighArcLongDuration,
|
||||
LowArcShortDuration,
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::TrajectoryChoice> for TrajectoryChoice{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::TrajectoryChoice{
|
||||
match self{
|
||||
TrajectoryChoice::HighArcLongDuration=>
|
||||
strafesnet_common::gameplay_attributes::TrajectoryChoice::HighArcLongDuration,
|
||||
TrajectoryChoice::LowArcShortDuration=>
|
||||
strafesnet_common::gameplay_attributes::TrajectoryChoice::LowArcShortDuration,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -61,12 +127,53 @@ pub enum SetTrajectory{
|
||||
},
|
||||
Velocity(Planar64Vec3),
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::SetTrajectory> for SetTrajectory{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::SetTrajectory{
|
||||
match self{
|
||||
SetTrajectory::AirTime(time)=>
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::AirTime(
|
||||
strafesnet_common::integer::Time::raw(time)
|
||||
),
|
||||
SetTrajectory::Height(height)=>
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::Height(
|
||||
strafesnet_common::integer::Planar64::raw(height)
|
||||
),
|
||||
SetTrajectory::DotVelocity{direction,dot}=>
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::DotVelocity{
|
||||
direction:strafesnet_common::integer::Planar64Vec3::raw_array(direction),
|
||||
dot:strafesnet_common::integer::Planar64::raw(dot),
|
||||
},
|
||||
SetTrajectory::TargetPointTime{target_point,time}=>
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointTime{
|
||||
target_point:strafesnet_common::integer::Planar64Vec3::raw_array(target_point),
|
||||
time:strafesnet_common::integer::Time::raw(time),
|
||||
},
|
||||
SetTrajectory::TargetPointSpeed{target_point,speed,trajectory_choice}=>
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointSpeed{
|
||||
target_point:strafesnet_common::integer::Planar64Vec3::raw_array(target_point),
|
||||
speed:strafesnet_common::integer::Planar64::raw(speed),
|
||||
trajectory_choice:trajectory_choice.into(),
|
||||
},
|
||||
SetTrajectory::Velocity(velocity)=>
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::Velocity(
|
||||
strafesnet_common::integer::Planar64Vec3::raw_array(velocity)
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub struct Wormhole{
|
||||
pub destination_model:u32,
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::Wormhole> for Wormhole{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::Wormhole{
|
||||
strafesnet_common::gameplay_attributes::Wormhole{
|
||||
destination_model:strafesnet_common::model::ModelId::new(self.destination_model),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -76,18 +183,42 @@ pub struct GeneralAttributes{
|
||||
pub wormhole:Option<Wormhole>,
|
||||
pub accelerator:Option<Accelerator>,
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::GeneralAttributes> for GeneralAttributes{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::GeneralAttributes{
|
||||
strafesnet_common::gameplay_attributes::GeneralAttributes{
|
||||
booster:self.booster.map(Into::into),
|
||||
trajectory:self.trajectory.map(Into::into),
|
||||
wormhole:self.wormhole.map(Into::into),
|
||||
accelerator:self.accelerator.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub struct ContactingAttributes{
|
||||
pub contact_behaviour:Option<ContactingBehaviour>,
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::ContactingAttributes> for ContactingAttributes{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::ContactingAttributes{
|
||||
strafesnet_common::gameplay_attributes::ContactingAttributes{
|
||||
contact_behaviour:self.contact_behaviour.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub struct IntersectingAttributes{
|
||||
pub water:Option<IntersectingWater>,
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::IntersectingAttributes> for IntersectingAttributes{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::IntersectingAttributes{
|
||||
strafesnet_common::gameplay_attributes::IntersectingAttributes{
|
||||
water:self.water.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub enum CollisionAttributes{
|
||||
@ -101,3 +232,15 @@ pub enum CollisionAttributes{
|
||||
general:GeneralAttributes,
|
||||
},
|
||||
}
|
||||
impl Into<strafesnet_common::gameplay_attributes::CollisionAttributes> for CollisionAttributes{
|
||||
fn into(self)->strafesnet_common::gameplay_attributes::CollisionAttributes{
|
||||
match self{
|
||||
CollisionAttributes::Decoration=>
|
||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Decoration,
|
||||
CollisionAttributes::Contact{contacting,general}=>
|
||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Contact{contacting:contacting.into(),general:general.into()},
|
||||
CollisionAttributes::Intersect{intersecting,general}=>
|
||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Intersect{intersecting:intersecting.into(),general:general.into()},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,13 @@ pub struct PolygonGroup{
|
||||
pub struct RenderConfig{
|
||||
pub texture:Option<u32>,
|
||||
}
|
||||
impl Into<strafesnet_common::model::RenderConfig> for RenderConfig{
|
||||
fn into(self)->strafesnet_common::model::RenderConfig{
|
||||
strafesnet_common::model::RenderConfig{
|
||||
texture:self.texture.map(strafesnet_common::model::TextureId::new),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub struct IndexedGraphicsGroup{
|
||||
|
Loading…
Reference in New Issue
Block a user