Skip to main content

cs2_gsi/model/
bomb.rs

1//! Bomb node — root-level bomb position / countdown info.
2
3use super::helpers::de_opt_num_or_str;
4use serde::{Deserialize, Serialize};
5
6/// Bomb status as a separate root key. More detailed than the per-round
7/// state in [`crate::model::round::BombRoundState`].
8#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)]
9pub struct Bomb {
10    /// Lifecycle state of the bomb.
11    #[serde(default)]
12    pub state: BombState,
13    /// World position, formatted by CS2 as `"x, y, z"`.
14    #[serde(default)]
15    pub position: String,
16    /// SteamID of the player carrying / defusing the bomb (if any).
17    #[serde(default)]
18    pub player: String,
19    /// Countdown until detonation / defuse, in seconds.
20    #[serde(default, deserialize_with = "de_opt_num_or_str")]
21    pub countdown: Option<f32>,
22}
23
24/// Lifecycle state of the bomb.
25#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq, Hash)]
26#[serde(rename_all = "lowercase")]
27pub enum BombState {
28    /// Bomb is held by a T player.
29    Carried,
30    /// Bomb is dropped on the ground.
31    Dropped,
32    /// Bomb is being planted (animation in progress).
33    Planting,
34    /// Bomb planted and counting down.
35    Planted,
36    /// Bomb is being defused.
37    Defusing,
38    /// Bomb defused.
39    Defused,
40    /// Bomb exploded.
41    Exploded,
42    /// Unrecognized / no bomb info.
43    #[serde(other)]
44    #[default]
45    Unknown,
46}