reuse types from v0
This commit is contained in:
@@ -89,7 +89,7 @@ impl std::fmt::Display for GameControlsError{
|
||||
}
|
||||
impl std::error::Error for GameControlsError{}
|
||||
impl GameControls{
|
||||
fn try_from_bits(bits:u32)->Result<Self,GameControlsError>{
|
||||
pub fn try_from_bits(bits:u32)->Result<Self,GameControlsError>{
|
||||
Self::from_bits(bits).ok_or(GameControlsError)
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ impl std::fmt::Display for TickInfoError{
|
||||
}
|
||||
impl std::error::Error for TickInfoError{}
|
||||
impl TickInfo{
|
||||
fn try_from_bits(bits:u32)->Result<Self,TickInfoError>{
|
||||
pub fn try_from_bits(bits:u32)->Result<Self,TickInfoError>{
|
||||
Self::from_bits(bits).ok_or(TickInfoError)
|
||||
}
|
||||
}
|
||||
|
||||
165
src/v1.rs
165
src/v1.rs
@@ -4,6 +4,8 @@ use binrw::io::{TakeSeek,TakeSeekExt};
|
||||
use binrw::BinReaderExt;
|
||||
use crate::BinrwError;
|
||||
|
||||
pub use crate::v0::{FlagReason,GameControls,GameControlsError,ModeID,ModeSpec,SoundType,SoundEvent,Style,TickInfo,TickInfoError};
|
||||
|
||||
const EVENT_SIZE:[usize;8]=[
|
||||
4+4+2*4, // Input
|
||||
4+4+4*3*4, // Output
|
||||
@@ -67,42 +69,6 @@ pub struct Vector3{
|
||||
pub z:f32,
|
||||
}
|
||||
|
||||
bitflags::bitflags!{
|
||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||
pub struct GameControls:u32{
|
||||
const MoveForward=1<<0;
|
||||
const MoveLeft=1<<1;
|
||||
const MoveBack=1<<2;
|
||||
const MoveRight=1<<3;
|
||||
const MoveUp=1<<4;
|
||||
const MoveDown=1<<5;
|
||||
const LookUp=1<<6;
|
||||
const LookLeft=1<<7;
|
||||
const LookDown=1<<8;
|
||||
const LookRight=1<<9;
|
||||
const Jump=1<<10;
|
||||
const Crouch=1<<11;
|
||||
const Sprint=1<<12;
|
||||
const Zoom=1<<13;
|
||||
const Use=1<<14;
|
||||
const Action1=1<<15;
|
||||
const Action2=1<<16;
|
||||
}
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct GameControlsError;
|
||||
impl std::fmt::Display for GameControlsError{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
write!(f,"{self:?}")
|
||||
}
|
||||
}
|
||||
impl std::error::Error for GameControlsError{}
|
||||
impl GameControls{
|
||||
fn try_from_bits(bits:u32)->Result<Self,GameControlsError>{
|
||||
Self::from_bits(bits).ok_or(GameControlsError)
|
||||
}
|
||||
}
|
||||
|
||||
// generic timed event
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
@@ -151,28 +117,6 @@ pub struct InputEvent{
|
||||
}
|
||||
|
||||
// output
|
||||
bitflags::bitflags!{
|
||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||
pub struct TickInfo:u32{
|
||||
const TickEnd=1<<0;
|
||||
const Jump=1<<1;
|
||||
const Strafe=1<<2;
|
||||
const Touching=1<<3;
|
||||
}
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct TickInfoError;
|
||||
impl std::fmt::Display for TickInfoError{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
write!(f,"{self:?}")
|
||||
}
|
||||
}
|
||||
impl std::error::Error for TickInfoError{}
|
||||
impl TickInfo{
|
||||
fn try_from_bits(bits:u32)->Result<Self,TickInfoError>{
|
||||
Self::from_bits(bits).ok_or(TickInfoError)
|
||||
}
|
||||
}
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug,Clone)]
|
||||
@@ -186,37 +130,6 @@ pub struct OutputEvent{
|
||||
pub acceleration:Vector3,
|
||||
}
|
||||
|
||||
// sound
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||
pub enum SoundType{
|
||||
#[brw(magic=101u32)]
|
||||
TrackGround,
|
||||
#[brw(magic=102u32)]
|
||||
TrackLadder,
|
||||
#[brw(magic=103u32)]
|
||||
TrackWater,
|
||||
#[brw(magic=104u32)]
|
||||
TrackAir,
|
||||
#[brw(magic=201u32)]
|
||||
JumpGround,
|
||||
#[brw(magic=202u32)]
|
||||
JumpLadder,
|
||||
#[brw(magic=301u32)]
|
||||
SmashGround,
|
||||
#[brw(magic=302u32)]
|
||||
SmashWall,
|
||||
}
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug,Clone)]
|
||||
pub struct SoundEvent{
|
||||
pub sound_type:SoundType,
|
||||
/// Roblox enum
|
||||
pub material:u32,
|
||||
}
|
||||
|
||||
// world
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
@@ -281,80 +194,6 @@ pub struct GravityEvent{
|
||||
}
|
||||
|
||||
// run
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||
pub struct ModeID(pub u32);
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||
pub enum ModeSpec{
|
||||
Exactly(ModeID),
|
||||
#[brw(magic=-1i32)]
|
||||
All,
|
||||
#[brw(magic=-2i32)]
|
||||
Invalid,
|
||||
#[brw(magic=-3i32)]
|
||||
InProgress,
|
||||
}
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||
pub enum Style{
|
||||
#[brw(magic=1u32)]
|
||||
Autohop,
|
||||
#[brw(magic=2u32)]
|
||||
Scroll,
|
||||
#[brw(magic=3u32)]
|
||||
Sideways,
|
||||
#[brw(magic=4u32)]
|
||||
HalfSideways,
|
||||
#[brw(magic=5u32)]
|
||||
WOnly,
|
||||
#[brw(magic=6u32)]
|
||||
AOnly,
|
||||
#[brw(magic=7u32)]
|
||||
Backwards,
|
||||
#[brw(magic=8u32)]
|
||||
Faste,
|
||||
#[brw(magic=14u32)]
|
||||
LowGravity,
|
||||
#[brw(magic=501u32)]
|
||||
Fly,
|
||||
#[brw(magic=502u32)]
|
||||
FlySustain,
|
||||
#[brw(magic=503u32)]
|
||||
Rocket,
|
||||
#[brw(magic=504u32)]
|
||||
Style3DStrafe,
|
||||
#[brw(magic=505u32)]
|
||||
RocketStrafe,
|
||||
}
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||
pub enum FlagReason{
|
||||
#[brw(magic=0u32)]
|
||||
Anticheat,
|
||||
#[brw(magic=1u32)]
|
||||
StyleChange,
|
||||
#[brw(magic=2u32)]
|
||||
Clock,
|
||||
#[brw(magic=3u32)]
|
||||
Pause,
|
||||
#[brw(magic=4u32)]
|
||||
Flying,
|
||||
#[brw(magic=5u32)]
|
||||
Gravity,
|
||||
#[brw(magic=6u32)]
|
||||
Timescale,
|
||||
#[brw(magic=7u32)]
|
||||
Timetravel,
|
||||
#[brw(magic=8u32)]
|
||||
Teleport,
|
||||
#[brw(magic=9u32)]
|
||||
Practice,
|
||||
}
|
||||
/// Creates a new run when the player enters a start zone.
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
|
||||
Reference in New Issue
Block a user