mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
add player flags (right now I've only done stuff for checking if player is on ground)
This commit is contained in:
parent
b500fe772a
commit
d461dbc7c1
2 changed files with 12 additions and 0 deletions
|
|
@ -86,6 +86,7 @@ pub struct Player {
|
||||||
pub bounds: Box,
|
pub bounds: Box,
|
||||||
pub weapons: [Handle; 3],
|
pub weapons: [Handle; 3],
|
||||||
pub handle: Handle,
|
pub handle: Handle,
|
||||||
|
pub flags: u16,
|
||||||
pub(crate) conditions: [u8; 20],
|
pub(crate) conditions: [u8; 20],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,6 +151,7 @@ pub const PLAYER_BOX_DEFAULT: Box = Box {
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Player {
|
impl Player {
|
||||||
|
pub const FL_ONGROUND: u16 = 1;
|
||||||
pub fn new(entity: EntityId) -> Player {
|
pub fn new(entity: EntityId) -> Player {
|
||||||
Player {
|
Player {
|
||||||
entity,
|
entity,
|
||||||
|
|
@ -158,6 +160,10 @@ impl Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_in_air(&self) -> bool {
|
||||||
|
self.flags & Player::FL_ONGROUND == 0
|
||||||
|
}
|
||||||
|
|
||||||
pub fn collides(&self, projectile: &Projectile, time_per_tick: f32) -> bool {
|
pub fn collides(&self, projectile: &Projectile, time_per_tick: f32) -> bool {
|
||||||
let current_position = projectile.position;
|
let current_position = projectile.position;
|
||||||
let next_position = projectile.position + (projectile.initial_speed * time_per_tick);
|
let next_position = projectile.position + (projectile.initial_speed * time_per_tick);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ pub fn handle_player_entity(
|
||||||
const OUTER: SendPropIdentifier = SendPropIdentifier::new("DT_AttributeContainer", "m_hOuter");
|
const OUTER: SendPropIdentifier = SendPropIdentifier::new("DT_AttributeContainer", "m_hOuter");
|
||||||
const OUTER2: SendPropIdentifier = SendPropIdentifier::new("DT_AttributeManager", "m_hOuter");
|
const OUTER2: SendPropIdentifier = SendPropIdentifier::new("DT_AttributeManager", "m_hOuter");
|
||||||
|
|
||||||
|
const FLAGS_PROP: SendPropIdentifier =
|
||||||
|
SendPropIdentifier::new("DT_BasePlayer", "m_fFlags");
|
||||||
|
|
||||||
const HEALTH_PROP: SendPropIdentifier = SendPropIdentifier::new("DT_BasePlayer", "m_iHealth");
|
const HEALTH_PROP: SendPropIdentifier = SendPropIdentifier::new("DT_BasePlayer", "m_iHealth");
|
||||||
const MAX_HEALTH_PROP: SendPropIdentifier =
|
const MAX_HEALTH_PROP: SendPropIdentifier =
|
||||||
SendPropIdentifier::new("DT_BasePlayer", "m_iMaxHealth");
|
SendPropIdentifier::new("DT_BasePlayer", "m_iMaxHealth");
|
||||||
|
|
@ -114,6 +117,9 @@ pub fn handle_player_entity(
|
||||||
let handle = Handle::try_from(&prop.value).unwrap_or_default();
|
let handle = Handle::try_from(&prop.value).unwrap_or_default();
|
||||||
player.weapons[2] = handle;
|
player.weapons[2] = handle;
|
||||||
}
|
}
|
||||||
|
FLAGS_PROP => {
|
||||||
|
player.flags = i64::try_from(&prop.value).unwrap_or_default() as u16;
|
||||||
|
}
|
||||||
PLAYER_COND | PLAYER_COND_BITS => {
|
PLAYER_COND | PLAYER_COND_BITS => {
|
||||||
player.conditions[0..4].copy_from_slice(
|
player.conditions[0..4].copy_from_slice(
|
||||||
&i64::try_from(&prop.value).unwrap_or_default().to_le_bytes()[0..4],
|
&i64::try_from(&prop.value).unwrap_or_default().to_le_bytes()[0..4],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue