Skip to main content

gizmo_physics_rigid/components/
breakable.rs

1#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
2pub struct Breakable {
3    pub max_pieces: u32,
4    pub threshold: f32, // Minimum impulse to deal damage
5    pub current_health: f32,
6    pub max_health: f32,
7    pub debris_lifetime: f32,
8    pub break_sound: Option<String>,
9    pub piece_prefab: Option<String>,
10    #[serde(skip)]
11    pub is_broken: bool,
12}
13
14impl Default for Breakable {
15    fn default() -> Self {
16        Self {
17            max_pieces: 10,
18            threshold: 100.0,
19            current_health: 100.0,
20            max_health: 100.0,
21            debris_lifetime: 5.0,
22            break_sound: None,
23            piece_prefab: None,
24            is_broken: false,
25        }
26    }
27}
28
29gizmo_core::impl_component!(Breakable);