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

building construction progress

This commit is contained in:
Robin Appelman 2025-06-28 20:09:35 +02:00
commit 4b88c33bf2
2 changed files with 20 additions and 1 deletions

View file

@ -209,6 +209,7 @@ pub struct Sentry {
pub shells: u16, pub shells: u16,
pub rockets: u16, pub rockets: u16,
pub is_mini: bool, pub is_mini: bool,
pub construction_progress: f32,
} }
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
@ -226,6 +227,7 @@ pub struct Dispenser {
pub angle: f32, pub angle: f32,
pub healing: Vec<UserId>, pub healing: Vec<UserId>,
pub metal: u16, pub metal: u16,
pub construction_progress: f32,
} }
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
@ -247,6 +249,7 @@ pub struct Teleporter {
pub recharge_duration: f32, pub recharge_duration: f32,
pub times_used: u16, pub times_used: u16,
pub yaw_to_exit: f32, pub yaw_to_exit: f32,
pub construction_progress: f32,
} }
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@ -354,6 +357,14 @@ impl Building {
Building::Teleporter(_) => BuildingClass::Teleporter, Building::Teleporter(_) => BuildingClass::Teleporter,
} }
} }
pub fn construction_progress(&self) -> f32 {
match self {
Building::Sentry(Sentry { construction_progress, .. })
| Building::Dispenser(Dispenser { construction_progress, .. })
| Building::Teleporter(Teleporter { construction_progress, .. }) => *construction_progress,
}
}
} }
#[non_exhaustive] #[non_exhaustive]

View file

@ -578,6 +578,8 @@ impl GameStateAnalyser {
const MAX_HEALTH: SendPropIdentifier = const MAX_HEALTH: SendPropIdentifier =
SendPropIdentifier::new("DT_BaseObject", "m_iMaxHealth"); SendPropIdentifier::new("DT_BaseObject", "m_iMaxHealth");
const HEALTH: SendPropIdentifier = SendPropIdentifier::new("DT_BaseObject", "m_iHealth"); const HEALTH: SendPropIdentifier = SendPropIdentifier::new("DT_BaseObject", "m_iHealth");
const PROGRESS: SendPropIdentifier =
SendPropIdentifier::new("DT_BaseObject", "m_flPercentageConstructed");
match building { match building {
Building::Sentry(Sentry { Building::Sentry(Sentry {
@ -590,6 +592,7 @@ impl GameStateAnalyser {
building, building,
max_health, max_health,
health, health,
construction_progress,
.. ..
}) })
| Building::Dispenser(Dispenser { | Building::Dispenser(Dispenser {
@ -602,6 +605,7 @@ impl GameStateAnalyser {
building, building,
max_health, max_health,
health, health,
construction_progress,
.. ..
}) })
| Building::Teleporter(Teleporter { | Building::Teleporter(Teleporter {
@ -614,9 +618,10 @@ impl GameStateAnalyser {
building, building,
max_health, max_health,
health, health,
construction_progress,
.. ..
}) => { }) => {
for prop in entity.props(parser_state) { for prop in &entity.props {
match prop.identifier { match prop.identifier {
LOCAL_ORIGIN => { LOCAL_ORIGIN => {
*position = Vector::try_from(&prop.value).unwrap_or_default() *position = Vector::try_from(&prop.value).unwrap_or_default()
@ -634,6 +639,9 @@ impl GameStateAnalyser {
*max_health = i64::try_from(&prop.value).unwrap_or_default() as u16 *max_health = i64::try_from(&prop.value).unwrap_or_default() as u16
} }
HEALTH => *health = i64::try_from(&prop.value).unwrap_or_default() as u16, HEALTH => *health = i64::try_from(&prop.value).unwrap_or_default() as u16,
PROGRESS => {
*construction_progress = f32::try_from(&prop.value).unwrap_or_default()
}
_ => {} _ => {}
} }
} }