newtypes from engine types (boilerplate)
This commit is contained in:
parent
3434cd394a
commit
47aef14ff3
@ -13,3 +13,11 @@ impl Into<strafesnet_common::aabb::Aabb> for Aabb{
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::aabb::Aabb> for Aabb{
|
||||
fn from(value:strafesnet_common::aabb::Aabb)->Self{
|
||||
Self{
|
||||
max:value.max().get().to_array(),
|
||||
min:value.min().get().to_array(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,16 @@ impl Into<strafesnet_common::gameplay_attributes::ContactingLadder> for Contacti
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::ContactingLadder> for ContactingLadder{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::ContactingLadder)->Self{
|
||||
Self{
|
||||
sticky:match value.sticky{
|
||||
true=>Some(()),
|
||||
false=>None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -40,6 +50,24 @@ impl Into<strafesnet_common::gameplay_attributes::ContactingBehaviour> for Conta
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::ContactingBehaviour> for ContactingBehaviour{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::ContactingBehaviour)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::Surf=>
|
||||
ContactingBehaviour::Surf,
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::Ladder(contacting_ladder)=>
|
||||
ContactingBehaviour::Ladder(
|
||||
contacting_ladder.into()
|
||||
),
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::NoJump=>
|
||||
ContactingBehaviour::NoJump,
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::Cling=>
|
||||
ContactingBehaviour::Cling,
|
||||
strafesnet_common::gameplay_attributes::ContactingBehaviour::Elastic(elasticity)=>
|
||||
ContactingBehaviour::Elastic(elasticity),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -57,6 +85,15 @@ impl Into<strafesnet_common::gameplay_attributes::IntersectingWater> for Interse
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::IntersectingWater> for IntersectingWater{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::IntersectingWater)->Self{
|
||||
Self{
|
||||
viscosity:value.viscosity.get(),
|
||||
density:value.density.get(),
|
||||
velocity:value.velocity.get().to_array(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -70,6 +107,13 @@ impl Into<strafesnet_common::gameplay_attributes::Accelerator> for Accelerator{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::Accelerator> for Accelerator{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::Accelerator)->Self{
|
||||
Self{
|
||||
acceleration:value.acceleration.get().to_array(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -92,6 +136,19 @@ impl Into<strafesnet_common::gameplay_attributes::Booster> for Booster{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::Booster> for Booster{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::Booster)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_attributes::Booster::Velocity(velocity)=>
|
||||
Booster::Velocity(velocity.get().to_array()),
|
||||
strafesnet_common::gameplay_attributes::Booster::Energy{direction,energy}=>
|
||||
Booster::Energy{
|
||||
direction:direction.get().to_array(),
|
||||
energy:energy.get(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little,repr=u8)]
|
||||
@ -109,6 +166,16 @@ impl Into<strafesnet_common::gameplay_attributes::TrajectoryChoice> for Trajecto
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::TrajectoryChoice> for TrajectoryChoice{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::TrajectoryChoice)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_attributes::TrajectoryChoice::HighArcLongDuration=>
|
||||
TrajectoryChoice::HighArcLongDuration,
|
||||
strafesnet_common::gameplay_attributes::TrajectoryChoice::LowArcShortDuration=>
|
||||
TrajectoryChoice::LowArcShortDuration,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -161,6 +228,40 @@ impl Into<strafesnet_common::gameplay_attributes::SetTrajectory> for SetTrajecto
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::SetTrajectory> for SetTrajectory{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::SetTrajectory)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::AirTime(time)=>
|
||||
SetTrajectory::AirTime(
|
||||
time.get()
|
||||
),
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::Height(height)=>
|
||||
SetTrajectory::Height(
|
||||
height.get()
|
||||
),
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::DotVelocity{direction,dot}=>
|
||||
SetTrajectory::DotVelocity{
|
||||
direction:direction.get().to_array(),
|
||||
dot:dot.get(),
|
||||
},
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointTime{target_point,time}=>
|
||||
SetTrajectory::TargetPointTime{
|
||||
target_point:target_point.get().to_array(),
|
||||
time:time.get(),
|
||||
},
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointSpeed{target_point,speed,trajectory_choice}=>
|
||||
SetTrajectory::TargetPointSpeed{
|
||||
target_point:target_point.get().to_array(),
|
||||
speed:speed.get(),
|
||||
trajectory_choice:trajectory_choice.into(),
|
||||
},
|
||||
strafesnet_common::gameplay_attributes::SetTrajectory::Velocity(velocity)=>
|
||||
SetTrajectory::Velocity(
|
||||
velocity.get().to_array()
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -174,6 +275,13 @@ impl Into<strafesnet_common::gameplay_attributes::Wormhole> for Wormhole{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::Wormhole> for Wormhole{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::Wormhole)->Self{
|
||||
Self{
|
||||
destination_model:value.destination_model.get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -193,6 +301,16 @@ impl Into<strafesnet_common::gameplay_attributes::GeneralAttributes> for General
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::GeneralAttributes> for GeneralAttributes{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::GeneralAttributes)->Self{
|
||||
Self{
|
||||
booster:value.booster.map(Into::into),
|
||||
trajectory:value.trajectory.map(Into::into),
|
||||
wormhole:value.wormhole.map(Into::into),
|
||||
accelerator:value.accelerator.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -206,6 +324,13 @@ impl Into<strafesnet_common::gameplay_attributes::ContactingAttributes> for Cont
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::ContactingAttributes> for ContactingAttributes{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::ContactingAttributes)->Self{
|
||||
Self{
|
||||
contact_behaviour:value.contact_behaviour.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -219,6 +344,14 @@ impl Into<strafesnet_common::gameplay_attributes::IntersectingAttributes> for In
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::IntersectingAttributes> for IntersectingAttributes{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::IntersectingAttributes)->Self{
|
||||
Self{
|
||||
water:value.water.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub enum CollisionAttributes{
|
||||
@ -244,3 +377,15 @@ impl Into<strafesnet_common::gameplay_attributes::CollisionAttributes> for Colli
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_attributes::CollisionAttributes> for CollisionAttributes{
|
||||
fn from(value:strafesnet_common::gameplay_attributes::CollisionAttributes)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Decoration=>
|
||||
CollisionAttributes::Decoration,
|
||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Contact{contacting,general}=>
|
||||
CollisionAttributes::Contact{contacting:contacting.into(),general:general.into()},
|
||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Intersect{intersecting,general}=>
|
||||
CollisionAttributes::Intersect{intersecting:intersecting.into(),general:general.into()},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,18 @@ impl Into<strafesnet_common::gameplay_modes::StageElementBehaviour> for StageEle
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_modes::StageElementBehaviour> for StageElementBehaviour{
|
||||
fn from(value:strafesnet_common::gameplay_modes::StageElementBehaviour)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_modes::StageElementBehaviour::SpawnAt=>StageElementBehaviour::SpawnAt,
|
||||
strafesnet_common::gameplay_modes::StageElementBehaviour::Trigger=>StageElementBehaviour::Trigger,
|
||||
strafesnet_common::gameplay_modes::StageElementBehaviour::Teleport=>StageElementBehaviour::Teleport,
|
||||
strafesnet_common::gameplay_modes::StageElementBehaviour::Platform=>StageElementBehaviour::Platform,
|
||||
strafesnet_common::gameplay_modes::StageElementBehaviour::Check=>StageElementBehaviour::Check,
|
||||
strafesnet_common::gameplay_modes::StageElementBehaviour::Checkpoint=>StageElementBehaviour::Checkpoint,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -41,6 +53,16 @@ impl Into<strafesnet_common::gameplay_modes::StageElement> for StageElement{
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_modes::StageElement> for StageElement{
|
||||
fn from(value:strafesnet_common::gameplay_modes::StageElement)->Self{
|
||||
Self{
|
||||
stage_id:value.stage_id().get(),
|
||||
behaviour:value.behaviour().into(),
|
||||
jump_limit:value.jump_limit(),
|
||||
force:match value.force(){true=>Some(()),false=>None},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -71,6 +93,25 @@ impl Into<strafesnet_common::gameplay_modes::Stage> for Stage{
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_modes::Stage> for Stage{
|
||||
fn from(value:strafesnet_common::gameplay_modes::Stage)->Self{
|
||||
let spawn=value.spawn().get();
|
||||
let ordered_checkpoints_count=value.ordered_checkpoints_count();
|
||||
let unordered_checkpoints_count=value.unordered_checkpoints_count();
|
||||
let (ordered_checkpoints,unordered_checkpoints)=value.into_inner();
|
||||
Self{
|
||||
spawn,
|
||||
ordered_checkpoints_count,
|
||||
unordered_checkpoints_count,
|
||||
ordered_checkpoints:ordered_checkpoints.into_iter()
|
||||
.map(|(checkpoint_id,model_id)|(checkpoint_id.get(),model_id.get()))
|
||||
.collect(),
|
||||
unordered_checkpoints:unordered_checkpoints.into_iter()
|
||||
.map(|model_id|model_id.get())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little,repr=u8)]
|
||||
@ -88,6 +129,15 @@ impl Into<strafesnet_common::gameplay_modes::Zone> for Zone{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_modes::Zone> for Zone{
|
||||
fn from(value:strafesnet_common::gameplay_modes::Zone)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_modes::Zone::Start=>Zone::Start,
|
||||
strafesnet_common::gameplay_modes::Zone::Finish=>Zone::Finish,
|
||||
strafesnet_common::gameplay_modes::Zone::Anticheat=>Zone::Anticheat,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -124,3 +174,26 @@ impl Into<strafesnet_common::gameplay_modes::Mode> for Mode{
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_modes::Mode> for Mode{
|
||||
fn from(value:strafesnet_common::gameplay_modes::Mode)->Self{
|
||||
let (style,start,zones,stages,elements)=value.into_inner();
|
||||
Self{
|
||||
header:ModeHeader{
|
||||
zones:zones.len() as u32,
|
||||
stages:stages.len() as u32,
|
||||
elements:elements.len() as u32,
|
||||
},
|
||||
style:style.into(),
|
||||
start:start.get(),
|
||||
zones:zones.into_iter()
|
||||
.map(|(model_id,zone)|(model_id.get(),zone.into()))
|
||||
.collect(),
|
||||
stages:stages.into_iter()
|
||||
.map(Into::into)
|
||||
.collect(),
|
||||
elements:elements.into_iter()
|
||||
.map(|(model_id,stage_element)|(model_id.get(),stage_element.into()))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,24 @@ impl Into<strafesnet_common::gameplay_style::StyleModifiers> for StyleModifiers{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::StyleModifiers> for StyleModifiers{
|
||||
fn from(value:strafesnet_common::gameplay_style::StyleModifiers)->Self{
|
||||
Self{
|
||||
controls_mask:value.controls_mask.bits(),
|
||||
controls_mask_state:value.controls_mask_state.bits(),
|
||||
strafe:value.strafe.map(Into::into),
|
||||
rocket:value.rocket.map(Into::into),
|
||||
jump:value.jump.map(Into::into),
|
||||
walk:value.walk.map(Into::into),
|
||||
ladder:value.ladder.map(Into::into),
|
||||
swim:value.swim.map(Into::into),
|
||||
gravity:value.gravity.get().to_array(),
|
||||
hitbox:value.hitbox.into(),
|
||||
camera_offset:value.camera_offset.get().to_array(),
|
||||
mass:value.mass.get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little,repr=u8)]
|
||||
@ -54,6 +72,15 @@ impl Into<strafesnet_common::gameplay_style::JumpCalculation> for JumpCalculatio
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::JumpCalculation> for JumpCalculation{
|
||||
fn from(value:strafesnet_common::gameplay_style::JumpCalculation)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_style::JumpCalculation::Capped=>JumpCalculation::Capped,
|
||||
strafesnet_common::gameplay_style::JumpCalculation::Energy=>JumpCalculation::Energy,
|
||||
strafesnet_common::gameplay_style::JumpCalculation::Linear=>JumpCalculation::Linear,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -73,6 +100,16 @@ impl Into<strafesnet_common::gameplay_style::JumpImpulse> for JumpImpulse{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::JumpImpulse> for JumpImpulse{
|
||||
fn from(value:strafesnet_common::gameplay_style::JumpImpulse)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_style::JumpImpulse::FromTime(time)=>JumpImpulse::FromTime(time.get()),
|
||||
strafesnet_common::gameplay_style::JumpImpulse::FromHeight(height)=>JumpImpulse::FromHeight(height.get()),
|
||||
strafesnet_common::gameplay_style::JumpImpulse::FromDeltaV(deltav)=>JumpImpulse::FromDeltaV(deltav.get()),
|
||||
strafesnet_common::gameplay_style::JumpImpulse::FromEnergy(energy)=>JumpImpulse::FromEnergy(energy.get()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -90,6 +127,15 @@ impl Into<strafesnet_common::gameplay_style::ControlsActivation> for ControlsAct
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::ControlsActivation> for ControlsActivation{
|
||||
fn from(value:strafesnet_common::gameplay_style::ControlsActivation)->Self{
|
||||
Self{
|
||||
controls_mask:value.controls_mask().bits(),
|
||||
controls_intersects:value.controls_intersects().bits(),
|
||||
controls_contains:value.controls_contains().bits(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -109,6 +155,17 @@ impl Into<strafesnet_common::gameplay_style::StrafeSettings> for StrafeSettings{
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::StrafeSettings> for StrafeSettings{
|
||||
fn from(value:strafesnet_common::gameplay_style::StrafeSettings)->Self{
|
||||
let (enable,mv,air_accel_limit,tick_rate)=value.into_inner();
|
||||
Self{
|
||||
enable:enable.into(),
|
||||
mv:mv.get(),
|
||||
air_accel_limit:air_accel_limit.map(|a|a.get()),
|
||||
tick_rate:tick_rate.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -122,6 +179,13 @@ impl Into<strafesnet_common::gameplay_style::PropulsionSettings> for PropulsionS
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::PropulsionSettings> for PropulsionSettings{
|
||||
fn from(value:strafesnet_common::gameplay_style::PropulsionSettings)->Self{
|
||||
Self{
|
||||
magnitude:value.magnitude().get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -137,6 +201,15 @@ impl Into<strafesnet_common::gameplay_style::JumpSettings> for JumpSettings{
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::JumpSettings> for JumpSettings{
|
||||
fn from(value:strafesnet_common::gameplay_style::JumpSettings)->Self{
|
||||
let (impulse,calculation)=value.into_inner();
|
||||
Self{
|
||||
impulse:impulse.into(),
|
||||
calculation:calculation.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -152,6 +225,14 @@ impl Into<strafesnet_common::gameplay_style::AccelerateSettings> for AccelerateS
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::AccelerateSettings> for AccelerateSettings{
|
||||
fn from(value:strafesnet_common::gameplay_style::AccelerateSettings)->Self{
|
||||
Self{
|
||||
accel:value.accel().get(),
|
||||
topspeed:value.topspeed().get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -171,6 +252,17 @@ impl Into<strafesnet_common::gameplay_style::WalkSettings> for WalkSettings{
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::WalkSettings> for WalkSettings{
|
||||
fn from(value:strafesnet_common::gameplay_style::WalkSettings)->Self{
|
||||
let (accelerate,static_friction,kinetic_friction,surf_dot)=value.into_inner();
|
||||
Self{
|
||||
accelerate:accelerate.into(),
|
||||
static_friction:static_friction.get(),
|
||||
kinetic_friction:kinetic_friction.get(),
|
||||
surf_dot:surf_dot.get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -186,6 +278,15 @@ impl Into<strafesnet_common::gameplay_style::LadderSettings> for LadderSettings{
|
||||
)
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::LadderSettings> for LadderSettings{
|
||||
fn from(value:strafesnet_common::gameplay_style::LadderSettings)->Self{
|
||||
let (accelerate,dot)=value.into_inner();
|
||||
Self{
|
||||
accelerate:accelerate.into(),
|
||||
dot:dot.get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little,repr=u8)]
|
||||
@ -201,6 +302,14 @@ impl Into<strafesnet_common::gameplay_style::HitboxMesh> for HitboxMesh{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::HitboxMesh> for HitboxMesh{
|
||||
fn from(value:strafesnet_common::gameplay_style::HitboxMesh)->Self{
|
||||
match value{
|
||||
strafesnet_common::gameplay_style::HitboxMesh::Box=>HitboxMesh::Box,
|
||||
strafesnet_common::gameplay_style::HitboxMesh::Cylinder=>HitboxMesh::Cylinder,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -216,3 +325,11 @@ impl Into<strafesnet_common::gameplay_style::Hitbox> for Hitbox{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::gameplay_style::Hitbox> for Hitbox{
|
||||
fn from(value:strafesnet_common::gameplay_style::Hitbox)->Self{
|
||||
Self{
|
||||
halfsize:value.halfsize.get().to_array(),
|
||||
mesh:value.mesh.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,14 @@ impl Into<strafesnet_common::integer::Ratio64> for Ratio64{
|
||||
strafesnet_common::integer::Ratio64::new(self.num,self.den).unwrap()
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::integer::Ratio64> for Ratio64{
|
||||
fn from(value:strafesnet_common::integer::Ratio64)->Self{
|
||||
Self{
|
||||
num:value.num(),
|
||||
den:value.den(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
|
@ -1,3 +1,5 @@
|
||||
use strafesnet_common::model::PolygonIter;
|
||||
|
||||
use super::integer::{Planar64Vec3,Planar64Affine3};
|
||||
|
||||
pub type TextureCoordinate=[f32;2];
|
||||
@ -11,6 +13,16 @@ pub struct IndexedVertex{
|
||||
pub normal:u32,
|
||||
pub color:u32,
|
||||
}
|
||||
impl From<strafesnet_common::model::IndexedVertex> for IndexedVertex{
|
||||
fn from(value:strafesnet_common::model::IndexedVertex)->Self{
|
||||
Self{
|
||||
pos:value.pos.get(),
|
||||
tex:value.tex.get(),
|
||||
normal:value.normal.get(),
|
||||
color:value.color.get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -26,6 +38,25 @@ pub struct PolygonGroup{
|
||||
#[br(count=count)]
|
||||
pub polys:Vec<Polygon>,
|
||||
}
|
||||
impl From<strafesnet_common::model::PolygonGroup> for PolygonGroup{
|
||||
fn from(value:strafesnet_common::model::PolygonGroup)->Self{
|
||||
match value{
|
||||
strafesnet_common::model::PolygonGroup::PolygonList(polygon_list)=>{
|
||||
let polys:Vec<Polygon>=polygon_list.polys().map(|poly|{
|
||||
let vertices:Vec<u32>=poly.iter().map(|vert|vert.get()).collect();
|
||||
Polygon{
|
||||
count:vertices.len() as u32,
|
||||
vertices,
|
||||
}
|
||||
}).collect();
|
||||
Self{
|
||||
count:polys.len() as u32,
|
||||
polys,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub struct RenderConfig{
|
||||
@ -38,6 +69,13 @@ impl Into<strafesnet_common::model::RenderConfig> for RenderConfig{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::model::RenderConfig> for RenderConfig{
|
||||
fn from(value:strafesnet_common::model::RenderConfig)->Self{
|
||||
Self{
|
||||
texture:value.texture.map(|texture_id|texture_id.get()),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub struct IndexedGraphicsGroup{
|
||||
@ -46,6 +84,15 @@ pub struct IndexedGraphicsGroup{
|
||||
#[br(count=count)]
|
||||
pub groups:Vec<u32>,
|
||||
}
|
||||
impl From<strafesnet_common::model::IndexedGraphicsGroup> for IndexedGraphicsGroup{
|
||||
fn from(value:strafesnet_common::model::IndexedGraphicsGroup)->Self{
|
||||
Self{
|
||||
count:value.groups.len() as u32,
|
||||
render:value.render.get(),
|
||||
groups:value.groups.into_iter().map(|group_id|group_id.get()).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
pub struct IndexedPhysicsGroup{
|
||||
@ -53,6 +100,14 @@ pub struct IndexedPhysicsGroup{
|
||||
#[br(count=count)]
|
||||
pub groups:Vec<u32>,
|
||||
}
|
||||
impl From<strafesnet_common::model::IndexedPhysicsGroup> for IndexedPhysicsGroup{
|
||||
fn from(value:strafesnet_common::model::IndexedPhysicsGroup)->Self{
|
||||
Self{
|
||||
count:value.groups.len() as u32,
|
||||
groups:value.groups.into_iter().map(|group_id|group_id.get()).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -123,6 +178,46 @@ impl Into<strafesnet_common::model::Mesh> for Mesh{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::model::Mesh> for Mesh{
|
||||
fn from(value:strafesnet_common::model::Mesh)->Self{
|
||||
Self{
|
||||
header:MeshHeader{
|
||||
unique_pos:value.unique_pos.len() as u32,
|
||||
unique_normal:value.unique_normal.len() as u32,
|
||||
unique_tex:value.unique_tex.len() as u32,
|
||||
unique_color:value.unique_color.len() as u32,
|
||||
unique_vertices:value.unique_vertices.len() as u32,
|
||||
polygon_groups:value.polygon_groups.len() as u32,
|
||||
graphics_groups:value.graphics_groups.len() as u32,
|
||||
physics_groups:value.physics_groups.len() as u32,
|
||||
},
|
||||
unique_pos:value.unique_pos.into_iter()
|
||||
.map(|pos|pos.get().to_array())
|
||||
.collect(),
|
||||
unique_normal:value.unique_normal.into_iter()
|
||||
.map(|normal|normal.get().to_array())
|
||||
.collect(),
|
||||
unique_tex:value.unique_tex.into_iter()
|
||||
.map(|tex|tex.to_array())
|
||||
.collect(),
|
||||
unique_color:value.unique_color.into_iter()
|
||||
.map(|color|color.to_array())
|
||||
.collect(),
|
||||
unique_vertices:value.unique_vertices.into_iter()
|
||||
.map(Into::into)
|
||||
.collect(),
|
||||
polygon_groups:value.polygon_groups.into_iter()
|
||||
.map(Into::into)
|
||||
.collect(),
|
||||
graphics_groups:value.graphics_groups.into_iter()
|
||||
.map(Into::into)
|
||||
.collect(),
|
||||
physics_groups:value.physics_groups.into_iter()
|
||||
.map(Into::into)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw::binrw]
|
||||
#[brw(little)]
|
||||
@ -150,3 +245,24 @@ impl Into<strafesnet_common::model::Model> for Model{
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<strafesnet_common::model::Model> for Model{
|
||||
fn from(value:strafesnet_common::model::Model)->Self{
|
||||
let (
|
||||
[_0,_1,_2],
|
||||
[_3,_4,_5],
|
||||
[_6,_7,_8],
|
||||
[_9,_a,_b]
|
||||
)=(
|
||||
value.transform.matrix3.x_axis.get().to_array(),
|
||||
value.transform.matrix3.y_axis.get().to_array(),
|
||||
value.transform.matrix3.z_axis.get().to_array(),
|
||||
value.transform.translation.get().to_array()
|
||||
);
|
||||
Self{
|
||||
mesh:value.mesh.get(),
|
||||
attributes:value.attributes.get(),
|
||||
color:value.color.to_array(),
|
||||
transform:[_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user