From d4e3235935134fc86091337fe54b9b5dc8316458 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 25 Jul 2024 11:32:58 -0700 Subject: [PATCH] boiling wip --- src/newtypes/aabb.rs | 8 ++ src/newtypes/gameplay_attributes.rs | 145 ++++++++++++++++++++++++++++ src/newtypes/gameplay_modes.rs | 41 ++++++++ 3 files changed, 194 insertions(+) diff --git a/src/newtypes/aabb.rs b/src/newtypes/aabb.rs index 3908287..ae8cb52 100644 --- a/src/newtypes/aabb.rs +++ b/src/newtypes/aabb.rs @@ -13,3 +13,11 @@ impl Into for Aabb{ ) } } +impl From for Aabb{ + fn from(value:strafesnet_common::aabb::Aabb)->Self{ + Self{ + max:value.max().get().to_array(), + min:value.min().get().to_array(), + } + } +} diff --git a/src/newtypes/gameplay_attributes.rs b/src/newtypes/gameplay_attributes.rs index 10921cd..c8039d7 100644 --- a/src/newtypes/gameplay_attributes.rs +++ b/src/newtypes/gameplay_attributes.rs @@ -12,6 +12,16 @@ impl Into for Contacti } } } +impl From 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 for Conta } } } +impl From 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 for Interse } } } +impl From 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 for Accelerator{ } } } +impl From 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 for Booster{ } } } +impl From 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 for Trajecto } } } +impl From 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 for SetTrajecto } } } +impl From 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 for Wormhole{ } } } +impl From 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 for General } } } +impl From 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 for Cont } } } +impl From 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 for In } } } +impl From 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 for Colli } } } +impl From 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()}, + } + } +} diff --git a/src/newtypes/gameplay_modes.rs b/src/newtypes/gameplay_modes.rs index 73c2eb4..eaf21bd 100644 --- a/src/newtypes/gameplay_modes.rs +++ b/src/newtypes/gameplay_modes.rs @@ -22,6 +22,18 @@ impl Into for StageEle } } } +impl From 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 for StageElement{ ) } } +impl From 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 for Stage{ ) } } +impl From 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)]