dis_rs/common/fire/
model.rs1use crate::common::model::{DescriptorRecord, EntityId, EventId, Location, PduBody, VectorF32};
2use crate::common::{BodyInfo, Interaction};
3use crate::enumerations::PduType;
4use crate::fire::builder::FireBuilder;
5#[cfg(feature = "serde")]
6use serde::{Deserialize, Serialize};
7
8const FIRE_BODY_LENGTH: u16 = 84;
9
10#[derive(Clone, Debug, Default, PartialEq)]
14#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
15pub struct Fire {
16 pub firing_entity_id: EntityId,
17 pub target_entity_id: EntityId,
18 pub entity_id: EntityId,
19 pub event_id: EventId,
20 pub fire_mission_index: u32,
21 pub location_in_world: Location,
22 pub descriptor: DescriptorRecord,
23 pub velocity: VectorF32,
24 pub range: f32,
25}
26
27impl Fire {
28 #[must_use]
29 pub fn builder() -> FireBuilder {
30 FireBuilder::new()
31 }
32
33 #[must_use]
34 pub fn into_builder(self) -> FireBuilder {
35 FireBuilder::new_from_body(self)
36 }
37
38 #[must_use]
39 pub fn into_pdu_body(self) -> PduBody {
40 PduBody::Fire(self)
41 }
42}
43
44impl BodyInfo for Fire {
45 fn body_length(&self) -> u16 {
46 FIRE_BODY_LENGTH
47 }
48
49 fn body_type(&self) -> PduType {
50 PduType::Fire
51 }
52}
53
54impl Interaction for Fire {
55 fn originator(&self) -> Option<&EntityId> {
56 Some(&self.firing_entity_id)
57 }
58
59 fn receiver(&self) -> Option<&EntityId> {
60 Some(&self.target_entity_id)
61 }
62}