1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 18:24:05 +02:00

live sentry rotation

This commit is contained in:
Robin Appelman 2025-07-05 15:49:25 +02:00
commit 33e40ca99b
2 changed files with 14 additions and 2 deletions

View file

@ -207,6 +207,7 @@ pub struct Sentry {
pub sapped: bool, pub sapped: bool,
pub team: Team, pub team: Team,
pub angle: f32, pub angle: f32,
pub yaw: f32,
pub player_controlled: bool, pub player_controlled: bool,
pub auto_aim_target: Handle, pub auto_aim_target: Handle,
pub shells: u16, pub shells: u16,

View file

@ -1,4 +1,6 @@
use crate::demo::data::game_state::{Building, BuildingClass, Dispenser, GameState, Handle, Sentry, Teleporter}; use crate::demo::data::game_state::{
Building, BuildingClass, Dispenser, GameState, Handle, Sentry, Teleporter,
};
use crate::demo::message::{EntityId, PacketEntity, UpdateType}; use crate::demo::message::{EntityId, PacketEntity, UpdateType};
use crate::demo::parser::analyser::{Team, UserId}; use crate::demo::parser::analyser::{Team, UserId};
use crate::demo::sendprop::{SendPropIdentifier, SendPropValue}; use crate::demo::sendprop::{SendPropIdentifier, SendPropValue};
@ -10,6 +12,8 @@ pub fn handle_sentry_entity(
entity: &PacketEntity, entity: &PacketEntity,
parser_state: &ParserState, parser_state: &ParserState,
) { ) {
const ROTATION: SendPropIdentifier =
SendPropIdentifier::new("DT_BaseEntity", "m_angRotation");
const ANGLE: SendPropIdentifier = const ANGLE: SendPropIdentifier =
SendPropIdentifier::new("DT_TFNonLocalPlayerExclusive", "m_angEyeAngles[1]"); SendPropIdentifier::new("DT_TFNonLocalPlayerExclusive", "m_angEyeAngles[1]");
const MINI: SendPropIdentifier = SendPropIdentifier::new("DT_BaseObject", "m_bMiniBuilding"); const MINI: SendPropIdentifier = SendPropIdentifier::new("DT_BaseObject", "m_bMiniBuilding");
@ -23,6 +27,9 @@ pub fn handle_sentry_entity(
SendPropIdentifier::new("DT_ObjectSentrygun", "m_iAmmoRockets"); SendPropIdentifier::new("DT_ObjectSentrygun", "m_iAmmoRockets");
const SHIELD: SendPropIdentifier = const SHIELD: SendPropIdentifier =
SendPropIdentifier::new("DT_ObjectSentrygun", "m_nShieldLevel"); SendPropIdentifier::new("DT_ObjectSentrygun", "m_nShieldLevel");
#[allow(dead_code)]
const POSE_PARAMETER_PITCH: SendPropIdentifier = SendPropIdentifier::new("m_flPoseParameter", "000");
const POSE_PARAMETER_YAW: SendPropIdentifier = SendPropIdentifier::new("m_flPoseParameter", "001");
if entity.update_type == UpdateType::Delete { if entity.update_type == UpdateType::Delete {
state.remove_building(entity.entity_index); state.remove_building(entity.entity_index);
@ -36,15 +43,19 @@ pub fn handle_sentry_entity(
if let Building::Sentry(sentry) = building { if let Building::Sentry(sentry) = building {
for prop in entity.props(parser_state) { for prop in entity.props(parser_state) {
match prop.identifier { match prop.identifier {
ROTATION => sentry.angle = Vector::try_from(&prop.value).unwrap_or_default().y,
ANGLE => sentry.angle = f32::try_from(&prop.value).unwrap_or_default(), ANGLE => sentry.angle = f32::try_from(&prop.value).unwrap_or_default(),
MINI => sentry.is_mini = i64::try_from(&prop.value).unwrap_or_default() > 0, MINI => sentry.is_mini = i64::try_from(&prop.value).unwrap_or_default() > 0,
CONTROLLED => { CONTROLLED => {
sentry.player_controlled = i64::try_from(&prop.value).unwrap_or_default() > 0 sentry.player_controlled = i64::try_from(&prop.value).unwrap_or_default() > 0
} }
TARGET => sentry.auto_aim_target = Handle::try_from(&prop.value).unwrap_or_default(), TARGET => {
sentry.auto_aim_target = Handle::try_from(&prop.value).unwrap_or_default()
}
SHELLS => sentry.shells = i64::try_from(&prop.value).unwrap_or_default() as u16, SHELLS => sentry.shells = i64::try_from(&prop.value).unwrap_or_default() as u16,
ROCKETS => sentry.rockets = i64::try_from(&prop.value).unwrap_or_default() as u16, ROCKETS => sentry.rockets = i64::try_from(&prop.value).unwrap_or_default() as u16,
SHIELD => sentry.shield = bool::try_from(&prop.value).unwrap_or_default(), SHIELD => sentry.shield = bool::try_from(&prop.value).unwrap_or_default(),
POSE_PARAMETER_YAW => sentry.yaw = f32::try_from(&prop.value).unwrap_or_default(),
_ => {} _ => {}
} }
} }