Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
4e1ed43161 | |||
00ac7960e0 | |||
f2e9f81fe4 | |||
bfcf973524 | |||
97da935d9d | |||
68ccee81b1 | |||
2c000cca67 | |||
cd65db0008 | |||
91b90675c4 | |||
8911968a7c |
131
Cargo.lock
generated
131
Cargo.lock
generated
@ -8,12 +8,6 @@ version = "2.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc"
|
checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arrayvec"
|
|
||||||
version = "0.7.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "binrw"
|
name = "binrw"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
@ -45,16 +39,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bnum"
|
name = "bytemuck"
|
||||||
version = "0.12.0"
|
version = "1.16.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "50202def95bf36cb7d1d7a7962cea1c36a3f8ad42425e5d2b71d7acb8041b5b8"
|
checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "byteorder"
|
||||||
version = "1.16.3"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83"
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
@ -63,15 +63,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fixed_wide"
|
name = "getrandom"
|
||||||
version = "0.1.0"
|
version = "0.2.15"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a8d6e10c51c9df39ead915c62288afbc41d13e00368e526037e530ee5c58e13"
|
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"cfg-if",
|
||||||
"bnum",
|
"libc",
|
||||||
"paste",
|
"wasi",
|
||||||
"ratio_ops",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -92,15 +91,10 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linear_ops"
|
name = "libc"
|
||||||
version = "0.1.0"
|
version = "0.2.155"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b2e6977ac24f47086d8a7a2d4ae1c720e86dfdc8407cf5e34c18bfa01053c456"
|
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||||
dependencies = [
|
|
||||||
"fixed_wide",
|
|
||||||
"paste",
|
|
||||||
"ratio_ops",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "owo-colors"
|
name = "owo-colors"
|
||||||
@ -109,10 +103,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
|
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paste"
|
name = "ppv-lite86"
|
||||||
version = "1.0.15"
|
version = "0.2.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
@ -133,32 +130,53 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ratio_ops"
|
name = "rand"
|
||||||
version = "0.1.0"
|
version = "0.8.5"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "01239195d6afe0509e7e3511b716c0540251dfe7ece0a9a5a27116afb766c42c"
|
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.6.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafesnet_common"
|
name = "strafesnet_common"
|
||||||
version = "0.5.0"
|
version = "0.2.0"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||||
checksum = "d8fcc44793ae84a1d80882f367980913292241c94eb87584de4010bdad4a918d"
|
checksum = "74580c59a09194ce39db49cd814a5c2fc2d61513c88c6b811b5b40c0da6de057"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"fixed_wide",
|
|
||||||
"glam",
|
"glam",
|
||||||
"id",
|
"id",
|
||||||
"linear_ops",
|
|
||||||
"ratio_ops",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafesnet_snf"
|
name = "strafesnet_snf"
|
||||||
version = "0.2.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"binrw",
|
"binrw",
|
||||||
"id",
|
"id",
|
||||||
|
"rand",
|
||||||
"strafesnet_common",
|
"strafesnet_common",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -189,3 +207,30 @@ name = "unicode-ident"
|
|||||||
version = "1.0.12"
|
version = "1.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.6.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"zerocopy-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.6.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.72",
|
||||||
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "strafesnet_snf"
|
name = "strafesnet_snf"
|
||||||
version = "0.2.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@ -8,4 +8,5 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
binrw = "0.14.0"
|
binrw = "0.14.0"
|
||||||
id = { version = "0.1.0", registry = "strafesnet" }
|
id = { version = "0.1.0", registry = "strafesnet" }
|
||||||
strafesnet_common = { version = "0.5.0", registry = "strafesnet" }
|
rand = "0.8.5"
|
||||||
|
strafesnet_common = { version = "0.2.0", registry = "strafesnet" }
|
||||||
|
45
src/bot.rs
45
src/bot.rs
@ -1,4 +1,7 @@
|
|||||||
use binrw::{BinReaderExt, binrw};
|
use std::io::Seek;
|
||||||
|
|
||||||
|
use binrw::{binrw,BinReaderExt,BinWriterExt};
|
||||||
|
use crate::newtypes::instruction::TimedPhysicsInstruction;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum Error{
|
||||||
@ -8,6 +11,46 @@ pub enum Error{
|
|||||||
File(crate::file::Error),
|
File(crate::file::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct BotDebug{
|
||||||
|
name:String,
|
||||||
|
file:std::fs::File,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BotDebug{
|
||||||
|
pub fn new()->std::io::Result<Self>{
|
||||||
|
let rng:u128=rand::random();
|
||||||
|
let name=format!("debug_bots/{rng:x}");
|
||||||
|
Ok(Self{
|
||||||
|
file:std::fs::File::create(name.as_str())?,
|
||||||
|
name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pub fn delete(self)->std::io::Result<()>{
|
||||||
|
std::mem::drop(self.file);
|
||||||
|
std::fs::remove_file(self.name)
|
||||||
|
}
|
||||||
|
pub fn push(&mut self,ins:strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>)->Result<(),binrw::Error>{
|
||||||
|
let ret=match TryInto::<TimedPhysicsInstruction>::try_into(ins){
|
||||||
|
Ok(ins)=>self.file.write_le(&ins),
|
||||||
|
Err(crate::newtypes::physics::PhysicsInputInstructionError::DropInstruction)=>Ok(()),
|
||||||
|
};
|
||||||
|
//check if too much data has written to be reasonable
|
||||||
|
//avoid filling my hard drive on an infinite loop basically
|
||||||
|
if self.file.stream_position().is_ok_and(|pos|50*1024*1024<pos){
|
||||||
|
panic!();
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn read_bot_debug(mut reader:impl BinReaderExt)->Result<Vec<strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>>,binrw::Error>{
|
||||||
|
let mut instructions=Vec::new();
|
||||||
|
while let Ok(ins)=reader.read_le::<TimedPhysicsInstruction>(){
|
||||||
|
instructions.push(ins.try_into().unwrap());
|
||||||
|
}
|
||||||
|
Ok(instructions)
|
||||||
|
}
|
||||||
|
|
||||||
/* block types
|
/* block types
|
||||||
|
|
||||||
BLOCK_BOT_HEADER:
|
BLOCK_BOT_HEADER:
|
||||||
|
@ -357,7 +357,7 @@ pub fn write_map<W:BinWriterExt>(mut writer:W,map:strafesnet_common::map::Comple
|
|||||||
let mesh=map.meshes.get(model.mesh.get() as usize).ok_or(Error::InvalidMeshId(model.mesh))?;
|
let mesh=map.meshes.get(model.mesh.get() as usize).ok_or(Error::InvalidMeshId(model.mesh))?;
|
||||||
let mut aabb=strafesnet_common::aabb::Aabb::default();
|
let mut aabb=strafesnet_common::aabb::Aabb::default();
|
||||||
for &pos in &mesh.unique_pos{
|
for &pos in &mesh.unique_pos{
|
||||||
aabb.grow(model.transform.transform_point3(pos).fix_1());
|
aabb.grow(model.transform.transform_point3(pos));
|
||||||
}
|
}
|
||||||
Ok(((model::ModelId::new(model_id as u32),model.into()),aabb))
|
Ok(((model::ModelId::new(model_id as u32),model.into()),aabb))
|
||||||
}).collect::<Result<Vec<_>,_>>()?;
|
}).collect::<Result<Vec<_>,_>>()?;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
mod common;
|
mod common;
|
||||||
pub mod aabb;
|
pub mod aabb;
|
||||||
pub mod model;
|
pub mod model;
|
||||||
|
pub mod mouse;
|
||||||
pub mod integer;
|
pub mod integer;
|
||||||
|
pub mod physics;
|
||||||
|
pub mod instruction;
|
||||||
pub mod gameplay_modes;
|
pub mod gameplay_modes;
|
||||||
pub mod gameplay_style;
|
pub mod gameplay_style;
|
||||||
pub mod gameplay_attributes;
|
pub mod gameplay_attributes;
|
||||||
|
@ -8,16 +8,16 @@ pub struct Aabb{
|
|||||||
impl Into<strafesnet_common::aabb::Aabb> for Aabb{
|
impl Into<strafesnet_common::aabb::Aabb> for Aabb{
|
||||||
fn into(self)->strafesnet_common::aabb::Aabb{
|
fn into(self)->strafesnet_common::aabb::Aabb{
|
||||||
strafesnet_common::aabb::Aabb::new(
|
strafesnet_common::aabb::Aabb::new(
|
||||||
strafesnet_common::integer::vec3::raw_array(self.min),
|
strafesnet_common::integer::Planar64Vec3::raw_array(self.min),
|
||||||
strafesnet_common::integer::vec3::raw_array(self.max),
|
strafesnet_common::integer::Planar64Vec3::raw_array(self.max),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<strafesnet_common::aabb::Aabb> for Aabb{
|
impl From<strafesnet_common::aabb::Aabb> for Aabb{
|
||||||
fn from(value:strafesnet_common::aabb::Aabb)->Self{
|
fn from(value:strafesnet_common::aabb::Aabb)->Self{
|
||||||
Self{
|
Self{
|
||||||
max:value.max().map(|t|t.to_raw()).to_array(),
|
max:value.max().get().to_array(),
|
||||||
min:value.min().map(|t|t.to_raw()).to_array(),
|
min:value.min().get().to_array(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,16 +84,16 @@ impl Into<strafesnet_common::gameplay_attributes::IntersectingWater> for Interse
|
|||||||
strafesnet_common::gameplay_attributes::IntersectingWater{
|
strafesnet_common::gameplay_attributes::IntersectingWater{
|
||||||
viscosity:strafesnet_common::integer::Planar64::raw(self.viscosity),
|
viscosity:strafesnet_common::integer::Planar64::raw(self.viscosity),
|
||||||
density:strafesnet_common::integer::Planar64::raw(self.density),
|
density:strafesnet_common::integer::Planar64::raw(self.density),
|
||||||
velocity:strafesnet_common::integer::vec3::raw_array(self.velocity),
|
velocity:strafesnet_common::integer::Planar64Vec3::raw_array(self.velocity),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<strafesnet_common::gameplay_attributes::IntersectingWater> for IntersectingWater{
|
impl From<strafesnet_common::gameplay_attributes::IntersectingWater> for IntersectingWater{
|
||||||
fn from(value:strafesnet_common::gameplay_attributes::IntersectingWater)->Self{
|
fn from(value:strafesnet_common::gameplay_attributes::IntersectingWater)->Self{
|
||||||
Self{
|
Self{
|
||||||
viscosity:value.viscosity.to_raw(),
|
viscosity:value.viscosity.get(),
|
||||||
density:value.density.to_raw(),
|
density:value.density.get(),
|
||||||
velocity:value.velocity.map(|t|t.to_raw()).to_array(),
|
velocity:value.velocity.get().to_array(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,14 +106,14 @@ pub struct Accelerator{
|
|||||||
impl Into<strafesnet_common::gameplay_attributes::Accelerator> for Accelerator{
|
impl Into<strafesnet_common::gameplay_attributes::Accelerator> for Accelerator{
|
||||||
fn into(self)->strafesnet_common::gameplay_attributes::Accelerator{
|
fn into(self)->strafesnet_common::gameplay_attributes::Accelerator{
|
||||||
strafesnet_common::gameplay_attributes::Accelerator{
|
strafesnet_common::gameplay_attributes::Accelerator{
|
||||||
acceleration:strafesnet_common::integer::vec3::raw_array(self.acceleration)
|
acceleration:strafesnet_common::integer::Planar64Vec3::raw_array(self.acceleration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<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{
|
fn from(value:strafesnet_common::gameplay_attributes::Accelerator)->Self{
|
||||||
Self{
|
Self{
|
||||||
acceleration:value.acceleration.map(|t|t.to_raw()).to_array(),
|
acceleration:value.acceleration.get().to_array(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,32 +125,19 @@ pub enum Booster{
|
|||||||
Velocity(Planar64Vec3),
|
Velocity(Planar64Vec3),
|
||||||
#[brw(magic=1u8)]
|
#[brw(magic=1u8)]
|
||||||
Energy{direction:Planar64Vec3,energy:Planar64},
|
Energy{direction:Planar64Vec3,energy:Planar64},
|
||||||
#[brw(magic=2u8)]
|
|
||||||
AirTime(Time),
|
|
||||||
#[brw(magic=3u8)]
|
|
||||||
Height(Planar64),
|
|
||||||
|
|
||||||
}
|
}
|
||||||
impl Into<strafesnet_common::gameplay_attributes::Booster> for Booster{
|
impl Into<strafesnet_common::gameplay_attributes::Booster> for Booster{
|
||||||
fn into(self)->strafesnet_common::gameplay_attributes::Booster{
|
fn into(self)->strafesnet_common::gameplay_attributes::Booster{
|
||||||
match self{
|
match self{
|
||||||
Booster::Velocity(velocity)=>
|
Booster::Velocity(velocity)=>
|
||||||
strafesnet_common::gameplay_attributes::Booster::Velocity(
|
strafesnet_common::gameplay_attributes::Booster::Velocity(
|
||||||
strafesnet_common::integer::vec3::raw_array(velocity)
|
strafesnet_common::integer::Planar64Vec3::raw_array(velocity)
|
||||||
),
|
),
|
||||||
Booster::Energy{direction,energy}=>
|
Booster::Energy{direction,energy}=>
|
||||||
strafesnet_common::gameplay_attributes::Booster::Energy{
|
strafesnet_common::gameplay_attributes::Booster::Energy{
|
||||||
direction:strafesnet_common::integer::vec3::raw_array(direction),
|
direction:strafesnet_common::integer::Planar64Vec3::raw_array(direction),
|
||||||
energy:strafesnet_common::integer::Planar64::raw(energy)
|
energy:strafesnet_common::integer::Planar64::raw(energy)
|
||||||
},
|
},
|
||||||
Booster::AirTime(time)=>
|
|
||||||
strafesnet_common::gameplay_attributes::Booster::AirTime(
|
|
||||||
strafesnet_common::integer::Time::raw(time)
|
|
||||||
),
|
|
||||||
Booster::Height(height)=>
|
|
||||||
strafesnet_common::gameplay_attributes::Booster::Height(
|
|
||||||
strafesnet_common::integer::Planar64::raw(height)
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,16 +145,12 @@ impl From<strafesnet_common::gameplay_attributes::Booster> for Booster{
|
|||||||
fn from(value:strafesnet_common::gameplay_attributes::Booster)->Self{
|
fn from(value:strafesnet_common::gameplay_attributes::Booster)->Self{
|
||||||
match value{
|
match value{
|
||||||
strafesnet_common::gameplay_attributes::Booster::Velocity(velocity)=>
|
strafesnet_common::gameplay_attributes::Booster::Velocity(velocity)=>
|
||||||
Booster::Velocity(velocity.map(|t|t.to_raw()).to_array()),
|
Booster::Velocity(velocity.get().to_array()),
|
||||||
strafesnet_common::gameplay_attributes::Booster::Energy{direction,energy}=>
|
strafesnet_common::gameplay_attributes::Booster::Energy{direction,energy}=>
|
||||||
Booster::Energy{
|
Booster::Energy{
|
||||||
direction:direction.map(|t|t.to_raw()).to_array(),
|
direction:direction.get().to_array(),
|
||||||
energy:energy.to_raw(),
|
energy:energy.get(),
|
||||||
},
|
},
|
||||||
strafesnet_common::gameplay_attributes::Booster::AirTime(time)=>
|
|
||||||
Booster::AirTime(time.get()),
|
|
||||||
strafesnet_common::gameplay_attributes::Booster::Height(height)=>
|
|
||||||
Booster::Height(height.to_raw()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,23 +218,23 @@ impl Into<strafesnet_common::gameplay_attributes::SetTrajectory> for SetTrajecto
|
|||||||
),
|
),
|
||||||
SetTrajectory::DotVelocity{direction,dot}=>
|
SetTrajectory::DotVelocity{direction,dot}=>
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::DotVelocity{
|
strafesnet_common::gameplay_attributes::SetTrajectory::DotVelocity{
|
||||||
direction:strafesnet_common::integer::vec3::raw_array(direction),
|
direction:strafesnet_common::integer::Planar64Vec3::raw_array(direction),
|
||||||
dot:strafesnet_common::integer::Planar64::raw(dot),
|
dot:strafesnet_common::integer::Planar64::raw(dot),
|
||||||
},
|
},
|
||||||
SetTrajectory::TargetPointTime{target_point,time}=>
|
SetTrajectory::TargetPointTime{target_point,time}=>
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointTime{
|
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointTime{
|
||||||
target_point:strafesnet_common::integer::vec3::raw_array(target_point),
|
target_point:strafesnet_common::integer::Planar64Vec3::raw_array(target_point),
|
||||||
time:strafesnet_common::integer::Time::raw(time),
|
time:strafesnet_common::integer::Time::raw(time),
|
||||||
},
|
},
|
||||||
SetTrajectory::TargetPointSpeed{target_point,speed,trajectory_choice}=>
|
SetTrajectory::TargetPointSpeed{target_point,speed,trajectory_choice}=>
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointSpeed{
|
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointSpeed{
|
||||||
target_point:strafesnet_common::integer::vec3::raw_array(target_point),
|
target_point:strafesnet_common::integer::Planar64Vec3::raw_array(target_point),
|
||||||
speed:strafesnet_common::integer::Planar64::raw(speed),
|
speed:strafesnet_common::integer::Planar64::raw(speed),
|
||||||
trajectory_choice:trajectory_choice.into(),
|
trajectory_choice:trajectory_choice.into(),
|
||||||
},
|
},
|
||||||
SetTrajectory::Velocity(velocity)=>
|
SetTrajectory::Velocity(velocity)=>
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::Velocity(
|
strafesnet_common::gameplay_attributes::SetTrajectory::Velocity(
|
||||||
strafesnet_common::integer::vec3::raw_array(velocity)
|
strafesnet_common::integer::Planar64Vec3::raw_array(velocity)
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,27 +248,27 @@ impl From<strafesnet_common::gameplay_attributes::SetTrajectory> for SetTrajecto
|
|||||||
),
|
),
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::Height(height)=>
|
strafesnet_common::gameplay_attributes::SetTrajectory::Height(height)=>
|
||||||
SetTrajectory::Height(
|
SetTrajectory::Height(
|
||||||
height.to_raw()
|
height.get()
|
||||||
),
|
),
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::DotVelocity{direction,dot}=>
|
strafesnet_common::gameplay_attributes::SetTrajectory::DotVelocity{direction,dot}=>
|
||||||
SetTrajectory::DotVelocity{
|
SetTrajectory::DotVelocity{
|
||||||
direction:direction.map(|t|t.to_raw()).to_array(),
|
direction:direction.get().to_array(),
|
||||||
dot:dot.to_raw(),
|
dot:dot.get(),
|
||||||
},
|
},
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointTime{target_point,time}=>
|
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointTime{target_point,time}=>
|
||||||
SetTrajectory::TargetPointTime{
|
SetTrajectory::TargetPointTime{
|
||||||
target_point:target_point.map(|t|t.to_raw()).to_array(),
|
target_point:target_point.get().to_array(),
|
||||||
time:time.get(),
|
time:time.get(),
|
||||||
},
|
},
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointSpeed{target_point,speed,trajectory_choice}=>
|
strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointSpeed{target_point,speed,trajectory_choice}=>
|
||||||
SetTrajectory::TargetPointSpeed{
|
SetTrajectory::TargetPointSpeed{
|
||||||
target_point:target_point.map(|t|t.to_raw()).to_array(),
|
target_point:target_point.get().to_array(),
|
||||||
speed:speed.to_raw(),
|
speed:speed.get(),
|
||||||
trajectory_choice:trajectory_choice.into(),
|
trajectory_choice:trajectory_choice.into(),
|
||||||
},
|
},
|
||||||
strafesnet_common::gameplay_attributes::SetTrajectory::Velocity(velocity)=>
|
strafesnet_common::gameplay_attributes::SetTrajectory::Velocity(velocity)=>
|
||||||
SetTrajectory::Velocity(
|
SetTrajectory::Velocity(
|
||||||
velocity.map(|t|t.to_raw()).to_array()
|
velocity.get().to_array()
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,71 +392,31 @@ impl From<strafesnet_common::gameplay_attributes::IntersectingAttributes> for In
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw::binrw]
|
|
||||||
#[brw(little)]
|
|
||||||
pub struct ContactAttributes{
|
|
||||||
contacting:ContactingAttributes,
|
|
||||||
general:GeneralAttributes,
|
|
||||||
}
|
|
||||||
impl Into<strafesnet_common::gameplay_attributes::ContactAttributes> 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<strafesnet_common::gameplay_attributes::ContactAttributes> 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<strafesnet_common::gameplay_attributes::IntersectAttributes> 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<strafesnet_common::gameplay_attributes::IntersectAttributes> for IntersectAttributes{
|
|
||||||
fn from(value:strafesnet_common::gameplay_attributes::IntersectAttributes)->Self{
|
|
||||||
Self{
|
|
||||||
intersecting:value.intersecting.into(),
|
|
||||||
general:value.general.into(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[binrw::binrw]
|
#[binrw::binrw]
|
||||||
#[brw(little)]
|
#[brw(little)]
|
||||||
pub enum CollisionAttributes{
|
pub enum CollisionAttributes{
|
||||||
#[brw(magic=0u8)]
|
#[brw(magic=0u8)]
|
||||||
Decoration,
|
Decoration,
|
||||||
#[brw(magic=1u8)]
|
#[brw(magic=1u8)]
|
||||||
Contact(ContactAttributes),
|
Contact{
|
||||||
|
contacting:ContactingAttributes,
|
||||||
|
general:GeneralAttributes,
|
||||||
|
},
|
||||||
#[brw(magic=2u8)]
|
#[brw(magic=2u8)]
|
||||||
Intersect(IntersectAttributes),
|
Intersect{
|
||||||
|
intersecting:IntersectingAttributes,
|
||||||
|
general:GeneralAttributes,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
impl Into<strafesnet_common::gameplay_attributes::CollisionAttributes> for CollisionAttributes{
|
impl Into<strafesnet_common::gameplay_attributes::CollisionAttributes> for CollisionAttributes{
|
||||||
fn into(self)->strafesnet_common::gameplay_attributes::CollisionAttributes{
|
fn into(self)->strafesnet_common::gameplay_attributes::CollisionAttributes{
|
||||||
match self{
|
match self{
|
||||||
CollisionAttributes::Decoration=>
|
CollisionAttributes::Decoration=>
|
||||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Decoration,
|
strafesnet_common::gameplay_attributes::CollisionAttributes::Decoration,
|
||||||
CollisionAttributes::Contact(attr)=>
|
CollisionAttributes::Contact{contacting,general}=>
|
||||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Contact(attr.into()),
|
strafesnet_common::gameplay_attributes::CollisionAttributes::Contact{contacting:contacting.into(),general:general.into()},
|
||||||
CollisionAttributes::Intersect(attr)=>
|
CollisionAttributes::Intersect{intersecting,general}=>
|
||||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Intersect(attr.into()),
|
strafesnet_common::gameplay_attributes::CollisionAttributes::Intersect{intersecting:intersecting.into(),general:general.into()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,10 +425,10 @@ impl From<strafesnet_common::gameplay_attributes::CollisionAttributes> for Colli
|
|||||||
match value{
|
match value{
|
||||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Decoration=>
|
strafesnet_common::gameplay_attributes::CollisionAttributes::Decoration=>
|
||||||
CollisionAttributes::Decoration,
|
CollisionAttributes::Decoration,
|
||||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Contact(attr)=>
|
strafesnet_common::gameplay_attributes::CollisionAttributes::Contact{contacting,general}=>
|
||||||
CollisionAttributes::Contact(attr.into()),
|
CollisionAttributes::Contact{contacting:contacting.into(),general:general.into()},
|
||||||
strafesnet_common::gameplay_attributes::CollisionAttributes::Intersect(attr)=>
|
strafesnet_common::gameplay_attributes::CollisionAttributes::Intersect{intersecting,general}=>
|
||||||
CollisionAttributes::Intersect(attr.into()),
|
CollisionAttributes::Intersect{intersecting:intersecting.into(),general:general.into()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,9 @@ impl TryInto<strafesnet_common::gameplay_style::StyleModifiers> for StyleModifie
|
|||||||
walk:self.walk.map(Into::into),
|
walk:self.walk.map(Into::into),
|
||||||
ladder:self.ladder.map(Into::into),
|
ladder:self.ladder.map(Into::into),
|
||||||
swim:self.swim.map(Into::into),
|
swim:self.swim.map(Into::into),
|
||||||
gravity:strafesnet_common::integer::vec3::raw_array(self.gravity),
|
gravity:strafesnet_common::integer::Planar64Vec3::raw_array(self.gravity),
|
||||||
hitbox:self.hitbox.into(),
|
hitbox:self.hitbox.into(),
|
||||||
camera_offset:strafesnet_common::integer::vec3::raw_array(self.camera_offset),
|
camera_offset:strafesnet_common::integer::Planar64Vec3::raw_array(self.camera_offset),
|
||||||
mass:strafesnet_common::integer::Planar64::raw(self.mass),
|
mass:strafesnet_common::integer::Planar64::raw(self.mass),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -94,10 +94,10 @@ impl From<strafesnet_common::gameplay_style::StyleModifiers> for StyleModifiers{
|
|||||||
walk:value.walk.map(Into::into),
|
walk:value.walk.map(Into::into),
|
||||||
ladder:value.ladder.map(Into::into),
|
ladder:value.ladder.map(Into::into),
|
||||||
swim:value.swim.map(Into::into),
|
swim:value.swim.map(Into::into),
|
||||||
gravity:value.gravity.map(|t|t.to_raw()).to_array(),
|
gravity:value.gravity.get().to_array(),
|
||||||
hitbox:value.hitbox.into(),
|
hitbox:value.hitbox.into(),
|
||||||
camera_offset:value.camera_offset.map(|t|t.to_raw()).to_array(),
|
camera_offset:value.camera_offset.get().to_array(),
|
||||||
mass:value.mass.to_raw(),
|
mass:value.mass.get(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,52 +105,52 @@ impl From<strafesnet_common::gameplay_style::StyleModifiers> for StyleModifiers{
|
|||||||
#[binrw::binrw]
|
#[binrw::binrw]
|
||||||
#[brw(little,repr=u8)]
|
#[brw(little,repr=u8)]
|
||||||
pub enum JumpCalculation{
|
pub enum JumpCalculation{
|
||||||
Max,
|
Capped,
|
||||||
BoostThenJump,
|
Energy,
|
||||||
JumpThenBoost,
|
Linear,
|
||||||
}
|
}
|
||||||
impl Into<strafesnet_common::gameplay_style::JumpCalculation> for JumpCalculation{
|
impl Into<strafesnet_common::gameplay_style::JumpCalculation> for JumpCalculation{
|
||||||
fn into(self)->strafesnet_common::gameplay_style::JumpCalculation{
|
fn into(self)->strafesnet_common::gameplay_style::JumpCalculation{
|
||||||
match self{
|
match self{
|
||||||
JumpCalculation::Max=>strafesnet_common::gameplay_style::JumpCalculation::Max,
|
JumpCalculation::Capped=>strafesnet_common::gameplay_style::JumpCalculation::Capped,
|
||||||
JumpCalculation::BoostThenJump=>strafesnet_common::gameplay_style::JumpCalculation::BoostThenJump,
|
JumpCalculation::Energy=>strafesnet_common::gameplay_style::JumpCalculation::Energy,
|
||||||
JumpCalculation::JumpThenBoost=>strafesnet_common::gameplay_style::JumpCalculation::JumpThenBoost,
|
JumpCalculation::Linear=>strafesnet_common::gameplay_style::JumpCalculation::Linear,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<strafesnet_common::gameplay_style::JumpCalculation> for JumpCalculation{
|
impl From<strafesnet_common::gameplay_style::JumpCalculation> for JumpCalculation{
|
||||||
fn from(value:strafesnet_common::gameplay_style::JumpCalculation)->Self{
|
fn from(value:strafesnet_common::gameplay_style::JumpCalculation)->Self{
|
||||||
match value{
|
match value{
|
||||||
strafesnet_common::gameplay_style::JumpCalculation::Max=>JumpCalculation::Max,
|
strafesnet_common::gameplay_style::JumpCalculation::Capped=>JumpCalculation::Capped,
|
||||||
strafesnet_common::gameplay_style::JumpCalculation::BoostThenJump=>JumpCalculation::BoostThenJump,
|
strafesnet_common::gameplay_style::JumpCalculation::Energy=>JumpCalculation::Energy,
|
||||||
strafesnet_common::gameplay_style::JumpCalculation::JumpThenBoost=>JumpCalculation::JumpThenBoost,
|
strafesnet_common::gameplay_style::JumpCalculation::Linear=>JumpCalculation::Linear,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum JumpImpulse{
|
pub enum JumpImpulse{
|
||||||
Time(Time),
|
FromTime(Time),
|
||||||
Height(Planar64),
|
FromHeight(Planar64),
|
||||||
Linear(Planar64),
|
FromDeltaV(Planar64),
|
||||||
Energy(Planar64),
|
FromEnergy(Planar64),
|
||||||
}
|
}
|
||||||
impl Into<strafesnet_common::gameplay_style::JumpImpulse> for JumpImpulse{
|
impl Into<strafesnet_common::gameplay_style::JumpImpulse> for JumpImpulse{
|
||||||
fn into(self)->strafesnet_common::gameplay_style::JumpImpulse{
|
fn into(self)->strafesnet_common::gameplay_style::JumpImpulse{
|
||||||
match self{
|
match self{
|
||||||
JumpImpulse::Time(time)=>strafesnet_common::gameplay_style::JumpImpulse::Time(strafesnet_common::integer::Time::raw(time)),
|
JumpImpulse::FromTime(time)=>strafesnet_common::gameplay_style::JumpImpulse::FromTime(strafesnet_common::integer::Time::raw(time)),
|
||||||
JumpImpulse::Height(height)=>strafesnet_common::gameplay_style::JumpImpulse::Height(strafesnet_common::integer::Planar64::raw(height)),
|
JumpImpulse::FromHeight(height)=>strafesnet_common::gameplay_style::JumpImpulse::FromHeight(strafesnet_common::integer::Planar64::raw(height)),
|
||||||
JumpImpulse::Linear(deltav)=>strafesnet_common::gameplay_style::JumpImpulse::Linear(strafesnet_common::integer::Planar64::raw(deltav)),
|
JumpImpulse::FromDeltaV(deltav)=>strafesnet_common::gameplay_style::JumpImpulse::FromDeltaV(strafesnet_common::integer::Planar64::raw(deltav)),
|
||||||
JumpImpulse::Energy(energy)=>strafesnet_common::gameplay_style::JumpImpulse::Energy(strafesnet_common::integer::Planar64::raw(energy)),
|
JumpImpulse::FromEnergy(energy)=>strafesnet_common::gameplay_style::JumpImpulse::FromEnergy(strafesnet_common::integer::Planar64::raw(energy)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<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{
|
fn from(value:strafesnet_common::gameplay_style::JumpImpulse)->Self{
|
||||||
match value{
|
match value{
|
||||||
strafesnet_common::gameplay_style::JumpImpulse::Time(time)=>JumpImpulse::Time(time.get()),
|
strafesnet_common::gameplay_style::JumpImpulse::FromTime(time)=>JumpImpulse::FromTime(time.get()),
|
||||||
strafesnet_common::gameplay_style::JumpImpulse::Height(height)=>JumpImpulse::Height(height.to_raw()),
|
strafesnet_common::gameplay_style::JumpImpulse::FromHeight(height)=>JumpImpulse::FromHeight(height.get()),
|
||||||
strafesnet_common::gameplay_style::JumpImpulse::Linear(deltav)=>JumpImpulse::Linear(deltav.to_raw()),
|
strafesnet_common::gameplay_style::JumpImpulse::FromDeltaV(deltav)=>JumpImpulse::FromDeltaV(deltav.get()),
|
||||||
strafesnet_common::gameplay_style::JumpImpulse::Energy(energy)=>JumpImpulse::Energy(energy.to_raw()),
|
strafesnet_common::gameplay_style::JumpImpulse::FromEnergy(energy)=>JumpImpulse::FromEnergy(energy.get()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,19 +165,19 @@ pub struct ControlsActivation{
|
|||||||
impl TryInto<strafesnet_common::gameplay_style::ControlsActivation> for ControlsActivation{
|
impl TryInto<strafesnet_common::gameplay_style::ControlsActivation> for ControlsActivation{
|
||||||
type Error=ControlsError;
|
type Error=ControlsError;
|
||||||
fn try_into(self)->Result<strafesnet_common::gameplay_style::ControlsActivation,Self::Error>{
|
fn try_into(self)->Result<strafesnet_common::gameplay_style::ControlsActivation,Self::Error>{
|
||||||
Ok(strafesnet_common::gameplay_style::ControlsActivation{
|
Ok(strafesnet_common::gameplay_style::ControlsActivation::new(
|
||||||
controls_mask:strafesnet_common::controls_bitflag::Controls::from_bits(self.controls_mask).ok_or(ControlsError::UnknownBits)?,
|
strafesnet_common::controls_bitflag::Controls::from_bits(self.controls_mask).ok_or(ControlsError::UnknownBits)?,
|
||||||
controls_intersects:strafesnet_common::controls_bitflag::Controls::from_bits(self.controls_intersects).ok_or(ControlsError::UnknownBits)?,
|
strafesnet_common::controls_bitflag::Controls::from_bits(self.controls_intersects).ok_or(ControlsError::UnknownBits)?,
|
||||||
controls_contains:strafesnet_common::controls_bitflag::Controls::from_bits(self.controls_contains).ok_or(ControlsError::UnknownBits)?,
|
strafesnet_common::controls_bitflag::Controls::from_bits(self.controls_contains).ok_or(ControlsError::UnknownBits)?,
|
||||||
})
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<strafesnet_common::gameplay_style::ControlsActivation> for ControlsActivation{
|
impl From<strafesnet_common::gameplay_style::ControlsActivation> for ControlsActivation{
|
||||||
fn from(value:strafesnet_common::gameplay_style::ControlsActivation)->Self{
|
fn from(value:strafesnet_common::gameplay_style::ControlsActivation)->Self{
|
||||||
Self{
|
Self{
|
||||||
controls_mask:value.controls_mask.bits(),
|
controls_mask:value.controls_mask().bits(),
|
||||||
controls_intersects:value.controls_intersects.bits(),
|
controls_intersects:value.controls_intersects().bits(),
|
||||||
controls_contains:value.controls_contains.bits(),
|
controls_contains:value.controls_contains().bits(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,23 +209,24 @@ impl std::error::Error for StrafeSettingsError{}
|
|||||||
impl TryInto<strafesnet_common::gameplay_style::StrafeSettings> for StrafeSettings{
|
impl TryInto<strafesnet_common::gameplay_style::StrafeSettings> for StrafeSettings{
|
||||||
type Error=StrafeSettingsError;
|
type Error=StrafeSettingsError;
|
||||||
fn try_into(self)->Result<strafesnet_common::gameplay_style::StrafeSettings,Self::Error>{
|
fn try_into(self)->Result<strafesnet_common::gameplay_style::StrafeSettings,Self::Error>{
|
||||||
Ok(strafesnet_common::gameplay_style::StrafeSettings{
|
Ok(strafesnet_common::gameplay_style::StrafeSettings::new(
|
||||||
enable:self.enable.try_into().map_err(StrafeSettingsError::Controls)?,
|
self.enable.try_into().map_err(StrafeSettingsError::Controls)?,
|
||||||
mv:strafesnet_common::integer::Planar64::raw(self.mv),
|
strafesnet_common::integer::Planar64::raw(self.mv),
|
||||||
air_accel_limit:self.air_accel_limit.map(strafesnet_common::integer::Planar64::raw),
|
self.air_accel_limit.map(strafesnet_common::integer::Planar64::raw),
|
||||||
tick_rate:self.tick_rate.try_into().map_err(StrafeSettingsError::Ratio)?,
|
self.tick_rate.try_into().map_err(StrafeSettingsError::Ratio)?,
|
||||||
})
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<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{
|
fn from(value:strafesnet_common::gameplay_style::StrafeSettings)->Self{
|
||||||
let header=flag(value.air_accel_limit.is_some(),StrafeSettings::AIR_ACCEL_LIMIT);
|
let (enable,mv,air_accel_limit,tick_rate)=value.into_inner();
|
||||||
|
let header=flag(air_accel_limit.is_some(),StrafeSettings::AIR_ACCEL_LIMIT);
|
||||||
Self{
|
Self{
|
||||||
header,
|
header,
|
||||||
enable:value.enable.into(),
|
enable:enable.into(),
|
||||||
mv:value.mv.to_raw(),
|
mv:mv.get(),
|
||||||
air_accel_limit:value.air_accel_limit.map(|a|a.to_raw()),
|
air_accel_limit:air_accel_limit.map(|a|a.get()),
|
||||||
tick_rate:value.tick_rate.into(),
|
tick_rate:tick_rate.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,15 +238,15 @@ pub struct PropulsionSettings{
|
|||||||
}
|
}
|
||||||
impl Into<strafesnet_common::gameplay_style::PropulsionSettings> for PropulsionSettings{
|
impl Into<strafesnet_common::gameplay_style::PropulsionSettings> for PropulsionSettings{
|
||||||
fn into(self)->strafesnet_common::gameplay_style::PropulsionSettings{
|
fn into(self)->strafesnet_common::gameplay_style::PropulsionSettings{
|
||||||
strafesnet_common::gameplay_style::PropulsionSettings{
|
strafesnet_common::gameplay_style::PropulsionSettings::new(
|
||||||
magnitude:strafesnet_common::integer::Planar64::raw(self.magnitude)
|
strafesnet_common::integer::Planar64::raw(self.magnitude)
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<strafesnet_common::gameplay_style::PropulsionSettings> for PropulsionSettings{
|
impl From<strafesnet_common::gameplay_style::PropulsionSettings> for PropulsionSettings{
|
||||||
fn from(value:strafesnet_common::gameplay_style::PropulsionSettings)->Self{
|
fn from(value:strafesnet_common::gameplay_style::PropulsionSettings)->Self{
|
||||||
Self{
|
Self{
|
||||||
magnitude:value.magnitude.to_raw(),
|
magnitude:value.magnitude().get(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,29 +258,25 @@ pub struct JumpSettings{
|
|||||||
impulse:i64,
|
impulse:i64,
|
||||||
}
|
}
|
||||||
impl JumpSettings{
|
impl JumpSettings{
|
||||||
const IMPULSE:u8=0b00011;
|
const IMPULSE:u8=0b0011;
|
||||||
const CALCULATION:u8=0b01100;
|
const CALCULATION:u8=0b1100;
|
||||||
const LIMIT_MINIMUM:u8=0b10000;
|
|
||||||
const fn impulse(&self)->Option<strafesnet_common::gameplay_style::JumpImpulse>{
|
const fn impulse(&self)->Option<strafesnet_common::gameplay_style::JumpImpulse>{
|
||||||
match self.header&Self::IMPULSE{
|
match self.header&Self::IMPULSE{
|
||||||
0=>Some(strafesnet_common::gameplay_style::JumpImpulse::Time(strafesnet_common::integer::Time::raw(self.impulse))),
|
0=>Some(strafesnet_common::gameplay_style::JumpImpulse::FromTime(strafesnet_common::integer::Time::raw(self.impulse))),
|
||||||
1=>Some(strafesnet_common::gameplay_style::JumpImpulse::Height(strafesnet_common::integer::Planar64::raw(self.impulse))),
|
1=>Some(strafesnet_common::gameplay_style::JumpImpulse::FromHeight(strafesnet_common::integer::Planar64::raw(self.impulse))),
|
||||||
2=>Some(strafesnet_common::gameplay_style::JumpImpulse::Linear(strafesnet_common::integer::Planar64::raw(self.impulse))),
|
2=>Some(strafesnet_common::gameplay_style::JumpImpulse::FromDeltaV(strafesnet_common::integer::Planar64::raw(self.impulse))),
|
||||||
3=>Some(strafesnet_common::gameplay_style::JumpImpulse::Energy(strafesnet_common::integer::Planar64::raw(self.impulse))),
|
3=>Some(strafesnet_common::gameplay_style::JumpImpulse::FromEnergy(strafesnet_common::integer::Planar64::raw(self.impulse))),
|
||||||
_=>None,
|
_=>None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const fn calculation(&self)->Option<strafesnet_common::gameplay_style::JumpCalculation>{
|
const fn calculation(&self)->Option<strafesnet_common::gameplay_style::JumpCalculation>{
|
||||||
match (self.header&Self::CALCULATION)>>2{
|
match (self.header&Self::CALCULATION)>>2{
|
||||||
0=>Some(strafesnet_common::gameplay_style::JumpCalculation::Max),
|
0=>Some(strafesnet_common::gameplay_style::JumpCalculation::Capped),
|
||||||
1=>Some(strafesnet_common::gameplay_style::JumpCalculation::JumpThenBoost),
|
1=>Some(strafesnet_common::gameplay_style::JumpCalculation::Energy),
|
||||||
2=>Some(strafesnet_common::gameplay_style::JumpCalculation::BoostThenJump),
|
2=>Some(strafesnet_common::gameplay_style::JumpCalculation::Linear),
|
||||||
_=>None,
|
_=>None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const fn limit_minimum(&self)->bool{
|
|
||||||
self.header&Self::LIMIT_MINIMUM!=0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum JumpSettingsError{
|
pub enum JumpSettingsError{
|
||||||
@ -289,30 +286,29 @@ pub enum JumpSettingsError{
|
|||||||
impl TryInto<strafesnet_common::gameplay_style::JumpSettings> for JumpSettings{
|
impl TryInto<strafesnet_common::gameplay_style::JumpSettings> for JumpSettings{
|
||||||
type Error=JumpSettingsError;
|
type Error=JumpSettingsError;
|
||||||
fn try_into(self)->Result<strafesnet_common::gameplay_style::JumpSettings,Self::Error>{
|
fn try_into(self)->Result<strafesnet_common::gameplay_style::JumpSettings,Self::Error>{
|
||||||
Ok(strafesnet_common::gameplay_style::JumpSettings{
|
Ok(strafesnet_common::gameplay_style::JumpSettings::new(
|
||||||
impulse:self.impulse().ok_or(JumpSettingsError::InvalidImpulseDiscriminant)?,
|
self.impulse().ok_or(JumpSettingsError::InvalidImpulseDiscriminant)?,
|
||||||
calculation:self.calculation().ok_or(JumpSettingsError::InvalidCalculationDiscriminant)?,
|
self.calculation().ok_or(JumpSettingsError::InvalidCalculationDiscriminant)?,
|
||||||
limit_minimum:self.limit_minimum(),
|
))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<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{
|
fn from(value:strafesnet_common::gameplay_style::JumpSettings)->Self{
|
||||||
let (impulse,impulse_header)=match value.impulse{
|
let (impulse_enum,calculation)=value.into_inner();
|
||||||
strafesnet_common::gameplay_style::JumpImpulse::Time(impulse)=>(impulse.get(),0),
|
let (impulse,impulse_header)=match impulse_enum{
|
||||||
strafesnet_common::gameplay_style::JumpImpulse::Height(impulse)=>(impulse.to_raw(),1),
|
strafesnet_common::gameplay_style::JumpImpulse::FromTime(impulse)=>(impulse.get(),0),
|
||||||
strafesnet_common::gameplay_style::JumpImpulse::Linear(impulse)=>(impulse.to_raw(),2),
|
strafesnet_common::gameplay_style::JumpImpulse::FromHeight(impulse)=>(impulse.get(),1),
|
||||||
strafesnet_common::gameplay_style::JumpImpulse::Energy(impulse)=>(impulse.to_raw(),3),
|
strafesnet_common::gameplay_style::JumpImpulse::FromDeltaV(impulse)=>(impulse.get(),2),
|
||||||
|
strafesnet_common::gameplay_style::JumpImpulse::FromEnergy(impulse)=>(impulse.get(),3),
|
||||||
};
|
};
|
||||||
let calculation_header=match value.calculation{
|
let calculation_header=match calculation{
|
||||||
strafesnet_common::gameplay_style::JumpCalculation::Max=>0,
|
strafesnet_common::gameplay_style::JumpCalculation::Capped=>0,
|
||||||
strafesnet_common::gameplay_style::JumpCalculation::JumpThenBoost=>1,
|
strafesnet_common::gameplay_style::JumpCalculation::Energy=>1,
|
||||||
strafesnet_common::gameplay_style::JumpCalculation::BoostThenJump=>2,
|
strafesnet_common::gameplay_style::JumpCalculation::Linear=>2,
|
||||||
};
|
};
|
||||||
let header=
|
let header=
|
||||||
impulse_header
|
impulse_header
|
||||||
|(calculation_header<<2)
|
|(calculation_header<<2);
|
||||||
|((value.limit_minimum as u8)<<4);
|
|
||||||
Self{
|
Self{
|
||||||
header,
|
header,
|
||||||
impulse,
|
impulse,
|
||||||
@ -328,17 +324,17 @@ pub struct AccelerateSettings{
|
|||||||
}
|
}
|
||||||
impl Into<strafesnet_common::gameplay_style::AccelerateSettings> for AccelerateSettings{
|
impl Into<strafesnet_common::gameplay_style::AccelerateSettings> for AccelerateSettings{
|
||||||
fn into(self)->strafesnet_common::gameplay_style::AccelerateSettings{
|
fn into(self)->strafesnet_common::gameplay_style::AccelerateSettings{
|
||||||
strafesnet_common::gameplay_style::AccelerateSettings{
|
strafesnet_common::gameplay_style::AccelerateSettings::new(
|
||||||
accel:strafesnet_common::integer::Planar64::raw(self.accel),
|
strafesnet_common::integer::Planar64::raw(self.accel),
|
||||||
topspeed:strafesnet_common::integer::Planar64::raw(self.topspeed),
|
strafesnet_common::integer::Planar64::raw(self.topspeed),
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<strafesnet_common::gameplay_style::AccelerateSettings> for AccelerateSettings{
|
impl From<strafesnet_common::gameplay_style::AccelerateSettings> for AccelerateSettings{
|
||||||
fn from(value:strafesnet_common::gameplay_style::AccelerateSettings)->Self{
|
fn from(value:strafesnet_common::gameplay_style::AccelerateSettings)->Self{
|
||||||
Self{
|
Self{
|
||||||
accel:value.accel.to_raw(),
|
accel:value.accel().get(),
|
||||||
topspeed:value.topspeed.to_raw(),
|
topspeed:value.topspeed().get(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,21 +349,22 @@ pub struct WalkSettings{
|
|||||||
}
|
}
|
||||||
impl Into<strafesnet_common::gameplay_style::WalkSettings> for WalkSettings{
|
impl Into<strafesnet_common::gameplay_style::WalkSettings> for WalkSettings{
|
||||||
fn into(self)->strafesnet_common::gameplay_style::WalkSettings{
|
fn into(self)->strafesnet_common::gameplay_style::WalkSettings{
|
||||||
strafesnet_common::gameplay_style::WalkSettings{
|
strafesnet_common::gameplay_style::WalkSettings::new(
|
||||||
accelerate:self.accelerate.into(),
|
self.accelerate.into(),
|
||||||
static_friction:strafesnet_common::integer::Planar64::raw(self.static_friction),
|
strafesnet_common::integer::Planar64::raw(self.static_friction),
|
||||||
kinetic_friction:strafesnet_common::integer::Planar64::raw(self.kinetic_friction),
|
strafesnet_common::integer::Planar64::raw(self.kinetic_friction),
|
||||||
surf_dot:strafesnet_common::integer::Planar64::raw(self.surf_dot),
|
strafesnet_common::integer::Planar64::raw(self.surf_dot),
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<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{
|
fn from(value:strafesnet_common::gameplay_style::WalkSettings)->Self{
|
||||||
|
let (accelerate,static_friction,kinetic_friction,surf_dot)=value.into_inner();
|
||||||
Self{
|
Self{
|
||||||
accelerate:value.accelerate.into(),
|
accelerate:accelerate.into(),
|
||||||
static_friction:value.static_friction.to_raw(),
|
static_friction:static_friction.get(),
|
||||||
kinetic_friction:value.kinetic_friction.to_raw(),
|
kinetic_friction:kinetic_friction.get(),
|
||||||
surf_dot:value.surf_dot.to_raw(),
|
surf_dot:surf_dot.get(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,17 +377,18 @@ pub struct LadderSettings{
|
|||||||
}
|
}
|
||||||
impl Into<strafesnet_common::gameplay_style::LadderSettings> for LadderSettings{
|
impl Into<strafesnet_common::gameplay_style::LadderSettings> for LadderSettings{
|
||||||
fn into(self)->strafesnet_common::gameplay_style::LadderSettings{
|
fn into(self)->strafesnet_common::gameplay_style::LadderSettings{
|
||||||
strafesnet_common::gameplay_style::LadderSettings{
|
strafesnet_common::gameplay_style::LadderSettings::new(
|
||||||
accelerate:self.accelerate.into(),
|
self.accelerate.into(),
|
||||||
dot:strafesnet_common::integer::Planar64::raw(self.dot),
|
strafesnet_common::integer::Planar64::raw(self.dot),
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<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{
|
fn from(value:strafesnet_common::gameplay_style::LadderSettings)->Self{
|
||||||
|
let (accelerate,dot)=value.into_inner();
|
||||||
Self{
|
Self{
|
||||||
accelerate:value.accelerate.into(),
|
accelerate:accelerate.into(),
|
||||||
dot:value.dot.to_raw(),
|
dot:dot.get(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,7 +425,7 @@ pub struct Hitbox{
|
|||||||
impl Into<strafesnet_common::gameplay_style::Hitbox> for Hitbox{
|
impl Into<strafesnet_common::gameplay_style::Hitbox> for Hitbox{
|
||||||
fn into(self)->strafesnet_common::gameplay_style::Hitbox{
|
fn into(self)->strafesnet_common::gameplay_style::Hitbox{
|
||||||
strafesnet_common::gameplay_style::Hitbox{
|
strafesnet_common::gameplay_style::Hitbox{
|
||||||
halfsize:strafesnet_common::integer::vec3::raw_array(self.halfsize),
|
halfsize:strafesnet_common::integer::Planar64Vec3::raw_array(self.halfsize),
|
||||||
mesh:self.mesh.into(),
|
mesh:self.mesh.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -435,7 +433,7 @@ impl Into<strafesnet_common::gameplay_style::Hitbox> for Hitbox{
|
|||||||
impl From<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{
|
fn from(value:strafesnet_common::gameplay_style::Hitbox)->Self{
|
||||||
Self{
|
Self{
|
||||||
halfsize:value.halfsize.map(|t|t.to_raw()).to_array(),
|
halfsize:value.halfsize.get().to_array(),
|
||||||
mesh:value.mesh.into(),
|
mesh:value.mesh.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
src/newtypes/instruction.rs
Normal file
27
src/newtypes/instruction.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
use super::integer::Time;
|
||||||
|
|
||||||
|
#[binrw::binrw]
|
||||||
|
#[brw(little)]
|
||||||
|
pub struct TimedPhysicsInstruction{
|
||||||
|
pub time:Time,
|
||||||
|
pub instruction:super::physics::PhysicsInputInstruction,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryInto<strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>> for TimedPhysicsInstruction{
|
||||||
|
type Error=super::integer::RatioError;
|
||||||
|
fn try_into(self)->Result<strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>,Self::Error>{
|
||||||
|
Ok(strafesnet_common::instruction::TimedInstruction{
|
||||||
|
time:strafesnet_common::integer::Time::raw(self.time),
|
||||||
|
instruction:self.instruction.try_into()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl TryFrom<strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>> for TimedPhysicsInstruction{
|
||||||
|
type Error=super::physics::PhysicsInputInstructionError;
|
||||||
|
fn try_from(value:strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>)->Result<Self,Self::Error>{
|
||||||
|
Ok(Self{
|
||||||
|
time:value.time.get(),
|
||||||
|
instruction:value.instruction.try_into()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,23 @@ pub struct Ratio64Vec2{
|
|||||||
pub x:Ratio64,
|
pub x:Ratio64,
|
||||||
pub y:Ratio64,
|
pub y:Ratio64,
|
||||||
}
|
}
|
||||||
|
impl TryInto<strafesnet_common::integer::Ratio64Vec2> for Ratio64Vec2{
|
||||||
|
type Error=RatioError;
|
||||||
|
fn try_into(self)->Result<strafesnet_common::integer::Ratio64Vec2,Self::Error>{
|
||||||
|
Ok(strafesnet_common::integer::Ratio64Vec2{
|
||||||
|
x:self.x.try_into()?,
|
||||||
|
y:self.y.try_into()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<strafesnet_common::integer::Ratio64Vec2> for Ratio64Vec2{
|
||||||
|
fn from(value:strafesnet_common::integer::Ratio64Vec2)->Self{
|
||||||
|
Self{
|
||||||
|
x:value.x.into(),
|
||||||
|
y:value.y.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type Angle32=i32;
|
pub type Angle32=i32;
|
||||||
pub type Planar64=i64;
|
pub type Planar64=i64;
|
||||||
|
@ -153,8 +153,8 @@ pub struct Mesh{
|
|||||||
impl Into<strafesnet_common::model::Mesh> for Mesh{
|
impl Into<strafesnet_common::model::Mesh> for Mesh{
|
||||||
fn into(self)->strafesnet_common::model::Mesh{
|
fn into(self)->strafesnet_common::model::Mesh{
|
||||||
strafesnet_common::model::Mesh{
|
strafesnet_common::model::Mesh{
|
||||||
unique_pos:self.unique_pos.into_iter().map(strafesnet_common::integer::vec3::raw_array).collect(),
|
unique_pos:self.unique_pos.into_iter().map(strafesnet_common::integer::Planar64Vec3::raw_array).collect(),
|
||||||
unique_normal:self.unique_normal.into_iter().map(strafesnet_common::integer::vec3::raw_array).collect(),
|
unique_normal:self.unique_normal.into_iter().map(strafesnet_common::integer::Planar64Vec3::raw_array).collect(),
|
||||||
unique_tex:self.unique_tex.into_iter().map(strafesnet_common::model::TextureCoordinate::from_array).collect(),
|
unique_tex:self.unique_tex.into_iter().map(strafesnet_common::model::TextureCoordinate::from_array).collect(),
|
||||||
unique_color:self.unique_color.into_iter().map(strafesnet_common::model::Color4::from_array).collect(),
|
unique_color:self.unique_color.into_iter().map(strafesnet_common::model::Color4::from_array).collect(),
|
||||||
unique_vertices:self.unique_vertices.into_iter().map(|vert|strafesnet_common::model::IndexedVertex{
|
unique_vertices:self.unique_vertices.into_iter().map(|vert|strafesnet_common::model::IndexedVertex{
|
||||||
@ -200,10 +200,10 @@ impl From<strafesnet_common::model::Mesh> for Mesh{
|
|||||||
physics_groups:value.physics_groups.len() as u32,
|
physics_groups:value.physics_groups.len() as u32,
|
||||||
},
|
},
|
||||||
unique_pos:value.unique_pos.into_iter()
|
unique_pos:value.unique_pos.into_iter()
|
||||||
.map(|pos|pos.map(|t|t.to_raw()).to_array())
|
.map(|pos|pos.get().to_array())
|
||||||
.collect(),
|
.collect(),
|
||||||
unique_normal:value.unique_normal.into_iter()
|
unique_normal:value.unique_normal.into_iter()
|
||||||
.map(|normal|normal.map(|t|t.to_raw()).to_array())
|
.map(|normal|normal.get().to_array())
|
||||||
.collect(),
|
.collect(),
|
||||||
unique_tex:value.unique_tex.into_iter()
|
unique_tex:value.unique_tex.into_iter()
|
||||||
.map(|tex|tex.to_array())
|
.map(|tex|tex.to_array())
|
||||||
@ -243,12 +243,12 @@ impl Into<strafesnet_common::model::Model> for Model{
|
|||||||
attributes:strafesnet_common::gameplay_attributes::CollisionAttributesId::new(self.attributes),
|
attributes:strafesnet_common::gameplay_attributes::CollisionAttributesId::new(self.attributes),
|
||||||
color:strafesnet_common::model::Color4::from_array(self.color),
|
color:strafesnet_common::model::Color4::from_array(self.color),
|
||||||
transform:strafesnet_common::integer::Planar64Affine3::new(
|
transform:strafesnet_common::integer::Planar64Affine3::new(
|
||||||
strafesnet_common::integer::Planar64Mat3::from_cols([
|
strafesnet_common::integer::Planar64Mat3::from_cols(
|
||||||
strafesnet_common::integer::vec3::raw_xyz(_0,_1,_2),
|
strafesnet_common::integer::Planar64Vec3::raw_xyz(_0,_1,_2),
|
||||||
strafesnet_common::integer::vec3::raw_xyz(_3,_4,_5),
|
strafesnet_common::integer::Planar64Vec3::raw_xyz(_3,_4,_5),
|
||||||
strafesnet_common::integer::vec3::raw_xyz(_6,_7,_8)
|
strafesnet_common::integer::Planar64Vec3::raw_xyz(_6,_7,_8)
|
||||||
]),
|
),
|
||||||
strafesnet_common::integer::vec3::raw_xyz(_9,_a,_b)
|
strafesnet_common::integer::Planar64Vec3::raw_xyz(_9,_a,_b)
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,10 +261,10 @@ impl From<strafesnet_common::model::Model> for Model{
|
|||||||
[_6,_7,_8],
|
[_6,_7,_8],
|
||||||
[_9,_a,_b]
|
[_9,_a,_b]
|
||||||
)=(
|
)=(
|
||||||
value.transform.matrix3.x_axis.map(|t|t.to_raw()).to_array(),
|
value.transform.matrix3.x_axis.get().to_array(),
|
||||||
value.transform.matrix3.y_axis.map(|t|t.to_raw()).to_array(),
|
value.transform.matrix3.y_axis.get().to_array(),
|
||||||
value.transform.matrix3.z_axis.map(|t|t.to_raw()).to_array(),
|
value.transform.matrix3.z_axis.get().to_array(),
|
||||||
value.transform.translation.map(|t|t.to_raw()).to_array()
|
value.transform.translation.get().to_array()
|
||||||
);
|
);
|
||||||
Self{
|
Self{
|
||||||
mesh:value.mesh.get(),
|
mesh:value.mesh.get(),
|
||||||
|
37
src/newtypes/mouse.rs
Normal file
37
src/newtypes/mouse.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use super::integer::Time;
|
||||||
|
|
||||||
|
#[binrw::binrw]
|
||||||
|
#[brw(little)]
|
||||||
|
pub enum EncodedMouseDelta{
|
||||||
|
//X did not move Y has 1 byte, time has 2 bytes
|
||||||
|
X0Y1T2{
|
||||||
|
y:i8,
|
||||||
|
t:u16,
|
||||||
|
},
|
||||||
|
X1Y1T2
|
||||||
|
}
|
||||||
|
///TODO: delta delta encoding lol
|
||||||
|
|
||||||
|
#[binrw::binrw]
|
||||||
|
#[brw(little)]
|
||||||
|
pub struct MouseState{
|
||||||
|
pub pos:[i32;2],
|
||||||
|
pub time:Time,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<strafesnet_common::mouse::MouseState> for MouseState{
|
||||||
|
fn into(self)->strafesnet_common::mouse::MouseState{
|
||||||
|
strafesnet_common::mouse::MouseState{
|
||||||
|
pos:self.pos.into(),
|
||||||
|
time:strafesnet_common::integer::Time::raw(self.time),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<strafesnet_common::mouse::MouseState> for MouseState{
|
||||||
|
fn from(value:strafesnet_common::mouse::MouseState)->Self{
|
||||||
|
Self{
|
||||||
|
pos:value.pos.to_array(),
|
||||||
|
time:value.time.get(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
98
src/newtypes/physics.rs
Normal file
98
src/newtypes/physics.rs
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
use super::common::Boolio;
|
||||||
|
|
||||||
|
#[binrw::binrw]
|
||||||
|
#[brw(little)]
|
||||||
|
pub enum PhysicsInputInstruction{
|
||||||
|
#[brw(magic=0u8)]
|
||||||
|
ReplaceMouse(super::mouse::MouseState,super::mouse::MouseState),
|
||||||
|
#[brw(magic=1u8)]
|
||||||
|
SetNextMouse(super::mouse::MouseState),
|
||||||
|
#[brw(magic=2u8)]
|
||||||
|
SetMoveRight(Boolio),
|
||||||
|
#[brw(magic=3u8)]
|
||||||
|
SetMoveUp(Boolio),
|
||||||
|
#[brw(magic=4u8)]
|
||||||
|
SetMoveBack(Boolio),
|
||||||
|
#[brw(magic=5u8)]
|
||||||
|
SetMoveLeft(Boolio),
|
||||||
|
#[brw(magic=6u8)]
|
||||||
|
SetMoveDown(Boolio),
|
||||||
|
#[brw(magic=7u8)]
|
||||||
|
SetMoveForward(Boolio),
|
||||||
|
#[brw(magic=8u8)]
|
||||||
|
SetJump(Boolio),
|
||||||
|
#[brw(magic=9u8)]
|
||||||
|
SetZoom(Boolio),
|
||||||
|
#[brw(magic=10u8)]
|
||||||
|
Reset,
|
||||||
|
#[brw(magic=11u8)]
|
||||||
|
Restart,
|
||||||
|
#[brw(magic=12u8)]
|
||||||
|
Spawn(super::gameplay_modes::ModeId,super::gameplay_modes::StageId),
|
||||||
|
#[brw(magic=13u8)]
|
||||||
|
PracticeFly,
|
||||||
|
#[brw(magic=14u8)]
|
||||||
|
SetSensitivity(super::integer::Ratio64Vec2),
|
||||||
|
}
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum PhysicsInputInstructionError{
|
||||||
|
/// This is an instruction that can be dropped when serializing
|
||||||
|
DropInstruction,
|
||||||
|
}
|
||||||
|
impl std::fmt::Display for PhysicsInputInstructionError{
|
||||||
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
|
write!(f,"{self:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::error::Error for PhysicsInputInstructionError{}
|
||||||
|
impl TryInto<strafesnet_common::physics::Instruction> for PhysicsInputInstruction{
|
||||||
|
type Error=super::integer::RatioError;
|
||||||
|
fn try_into(self)->Result<strafesnet_common::physics::Instruction,Self::Error>{
|
||||||
|
Ok(match self{
|
||||||
|
PhysicsInputInstruction::ReplaceMouse(m0,m1)=>strafesnet_common::physics::Instruction::ReplaceMouse(m0.into(),m1.into()),
|
||||||
|
PhysicsInputInstruction::SetNextMouse(m)=>strafesnet_common::physics::Instruction::SetNextMouse(m.into()),
|
||||||
|
PhysicsInputInstruction::SetMoveRight(state)=>strafesnet_common::physics::Instruction::SetMoveRight(state.into()),
|
||||||
|
PhysicsInputInstruction::SetMoveUp(state)=>strafesnet_common::physics::Instruction::SetMoveUp(state.into()),
|
||||||
|
PhysicsInputInstruction::SetMoveBack(state)=>strafesnet_common::physics::Instruction::SetMoveBack(state.into()),
|
||||||
|
PhysicsInputInstruction::SetMoveLeft(state)=>strafesnet_common::physics::Instruction::SetMoveLeft(state.into()),
|
||||||
|
PhysicsInputInstruction::SetMoveDown(state)=>strafesnet_common::physics::Instruction::SetMoveDown(state.into()),
|
||||||
|
PhysicsInputInstruction::SetMoveForward(state)=>strafesnet_common::physics::Instruction::SetMoveForward(state.into()),
|
||||||
|
PhysicsInputInstruction::SetJump(state)=>strafesnet_common::physics::Instruction::SetJump(state.into()),
|
||||||
|
PhysicsInputInstruction::SetZoom(state)=>strafesnet_common::physics::Instruction::SetZoom(state.into()),
|
||||||
|
PhysicsInputInstruction::Reset=>strafesnet_common::physics::Instruction::Reset,
|
||||||
|
PhysicsInputInstruction::Restart=>strafesnet_common::physics::Instruction::Restart,
|
||||||
|
PhysicsInputInstruction::Spawn(mode_id,stage_id)=>strafesnet_common::physics::Instruction::Spawn(
|
||||||
|
strafesnet_common::gameplay_modes::ModeId::new(mode_id),
|
||||||
|
strafesnet_common::gameplay_modes::StageId::new(stage_id),
|
||||||
|
),
|
||||||
|
PhysicsInputInstruction::PracticeFly=>strafesnet_common::physics::Instruction::PracticeFly,
|
||||||
|
PhysicsInputInstruction::SetSensitivity(sensitivity)=>strafesnet_common::physics::Instruction::SetSensitivity(sensitivity.try_into()?),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl TryFrom<strafesnet_common::physics::Instruction> for PhysicsInputInstruction{
|
||||||
|
type Error=PhysicsInputInstructionError;
|
||||||
|
fn try_from(value:strafesnet_common::physics::Instruction)->Result<Self,Self::Error>{
|
||||||
|
match value{
|
||||||
|
strafesnet_common::physics::Instruction::ReplaceMouse(m0,m1)=>Ok(PhysicsInputInstruction::ReplaceMouse(m0.into(),m1.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetNextMouse(m)=>Ok(PhysicsInputInstruction::SetNextMouse(m.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetMoveRight(state)=>Ok(PhysicsInputInstruction::SetMoveRight(state.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetMoveUp(state)=>Ok(PhysicsInputInstruction::SetMoveUp(state.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetMoveBack(state)=>Ok(PhysicsInputInstruction::SetMoveBack(state.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetMoveLeft(state)=>Ok(PhysicsInputInstruction::SetMoveLeft(state.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetMoveDown(state)=>Ok(PhysicsInputInstruction::SetMoveDown(state.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetMoveForward(state)=>Ok(PhysicsInputInstruction::SetMoveForward(state.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetJump(state)=>Ok(PhysicsInputInstruction::SetJump(state.into())),
|
||||||
|
strafesnet_common::physics::Instruction::SetZoom(state)=>Ok(PhysicsInputInstruction::SetZoom(state.into())),
|
||||||
|
strafesnet_common::physics::Instruction::Reset=>Ok(PhysicsInputInstruction::Reset),
|
||||||
|
strafesnet_common::physics::Instruction::Restart=>Ok(PhysicsInputInstruction::Restart),
|
||||||
|
strafesnet_common::physics::Instruction::Spawn(mode_id,stage_id)=>Ok(PhysicsInputInstruction::Spawn(
|
||||||
|
mode_id.get(),
|
||||||
|
stage_id.get(),
|
||||||
|
)),
|
||||||
|
strafesnet_common::physics::Instruction::PracticeFly=>Ok(PhysicsInputInstruction::PracticeFly),
|
||||||
|
strafesnet_common::physics::Instruction::SetSensitivity(sensitivity)=>Ok(PhysicsInputInstruction::SetSensitivity(sensitivity.into())),
|
||||||
|
strafesnet_common::physics::Instruction::Idle=>Err(PhysicsInputInstructionError::DropInstruction),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user