From 6a198ad74609ee460e3f6954a8a4c90fcd8cddbb Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 9 Aug 2024 14:13:10 -0700 Subject: [PATCH] update common --- Cargo.lock | 4 +- Cargo.toml | 2 +- src/newtypes/gameplay_attributes.rs | 72 ++++++++++++++++++++++------- 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 007417e..52cc6b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "strafesnet_common" -version = "0.3.0" +version = "0.4.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "1077d45a0b064964906a57de765a5a2bfe47b41f2f807d13b18c70765e76d3dd" +checksum = "ea4126f6fbf9aecf89c9e319290f0221d177dcaa8659b4b9e3d82acc37829f12" dependencies = [ "arrayvec", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index a4a574a..d0b75ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,4 @@ edition = "2021" [dependencies] binrw = "0.14.0" id = { version = "0.1.0", registry = "strafesnet" } -strafesnet_common = { version = "0.3.0", registry = "strafesnet" } +strafesnet_common = { version = "0.4.0", registry = "strafesnet" } diff --git a/src/newtypes/gameplay_attributes.rs b/src/newtypes/gameplay_attributes.rs index 192aee8..a0082cd 100644 --- a/src/newtypes/gameplay_attributes.rs +++ b/src/newtypes/gameplay_attributes.rs @@ -409,31 +409,71 @@ impl From for In } } +#[binrw::binrw] +#[brw(little)] +pub struct ContactAttributes{ + contacting:ContactingAttributes, + general:GeneralAttributes, +} +impl Into for ContactAttributes{ + fn into(self)->strafesnet_common::gameplay_attributes::ContactAttributes{ + strafesnet_common::gameplay_attributes::ContactAttributes{ + contacting:self.contacting.into(), + general:self.general.into(), + } + } +} +impl From for ContactAttributes{ + fn from(value:strafesnet_common::gameplay_attributes::ContactAttributes)->Self{ + Self{ + contacting:value.contacting.into(), + general:value.general.into(), + } + } +} + +#[binrw::binrw] +#[brw(little)] +pub struct IntersectAttributes{ + intersecting:IntersectingAttributes, + general:GeneralAttributes, +} +impl Into for IntersectAttributes{ + fn into(self)->strafesnet_common::gameplay_attributes::IntersectAttributes{ + strafesnet_common::gameplay_attributes::IntersectAttributes{ + intersecting:self.intersecting.into(), + general:self.general.into(), + } + } +} +impl From for IntersectAttributes{ + fn from(value:strafesnet_common::gameplay_attributes::IntersectAttributes)->Self{ + Self{ + intersecting:value.intersecting.into(), + general:value.general.into(), + } + } +} + #[binrw::binrw] #[brw(little)] pub enum CollisionAttributes{ #[brw(magic=0u8)] Decoration, #[brw(magic=1u8)] - Contact{ - contacting:ContactingAttributes, - general:GeneralAttributes, - }, + Contact(ContactAttributes), #[brw(magic=2u8)] - Intersect{ - intersecting:IntersectingAttributes, - general:GeneralAttributes, - }, + Intersect(IntersectAttributes), } impl Into 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()}, + CollisionAttributes::Contact(attr)=> + strafesnet_common::gameplay_attributes::CollisionAttributes::Contact(attr.into()), + CollisionAttributes::Intersect(attr)=> + strafesnet_common::gameplay_attributes::CollisionAttributes::Intersect(attr.into()), } } } @@ -442,10 +482,10 @@ impl From for Colli 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()}, + strafesnet_common::gameplay_attributes::CollisionAttributes::Contact(attr)=> + CollisionAttributes::Contact(attr.into()), + strafesnet_common::gameplay_attributes::CollisionAttributes::Intersect(attr)=> + CollisionAttributes::Intersect(attr.into()), } } }