dis_rs/common/entity_state/
builder.rs1use crate::entity_state::model::{DrParameters, EntityAppearance, EntityMarking, EntityState};
2use crate::enumerations::{EntityCapabilities, ForceId};
3use crate::model::{EntityId, EntityType, Location, Orientation, VariableParameter, VectorF32};
4
5pub struct EntityStateBuilder(EntityState);
6
7impl Default for EntityStateBuilder {
8 fn default() -> Self {
9 Self::new()
10 }
11}
12
13impl EntityStateBuilder {
14 #[must_use]
15 pub fn new() -> Self {
16 EntityStateBuilder(EntityState::default())
17 }
18
19 #[must_use]
20 pub fn new_from_body(body: EntityState) -> Self {
21 EntityStateBuilder(body)
22 }
23
24 #[must_use]
25 pub fn build(self) -> EntityState {
26 self.0
27 }
28
29 #[must_use]
30 pub fn with_entity_id(mut self, entity_id: EntityId) -> Self {
31 self.0.entity_id = entity_id;
32 self
33 }
34
35 #[must_use]
36 pub fn with_entity_type(mut self, entity_type: EntityType) -> Self {
37 self.0.entity_type = entity_type;
38 self
39 }
40
41 #[must_use]
42 pub fn with_force_id(mut self, force_id: ForceId) -> Self {
43 self.0.force_id = force_id;
44 self
45 }
46
47 #[must_use]
48 pub fn with_alternative_entity_type(mut self, entity_type: EntityType) -> Self {
49 self.0.alternative_entity_type = entity_type;
50 self
51 }
52
53 #[must_use]
54 pub fn with_velocity(mut self, velocity: VectorF32) -> Self {
55 self.0.entity_linear_velocity = velocity;
56 self
57 }
58
59 #[must_use]
60 pub fn with_location(mut self, location: Location) -> Self {
61 self.0.entity_location = location;
62 self
63 }
64
65 #[must_use]
66 pub fn with_orientation(mut self, orientation: Orientation) -> Self {
67 self.0.entity_orientation = orientation;
68 self
69 }
70
71 #[must_use]
72 pub fn with_appearance(mut self, appearance: EntityAppearance) -> Self {
73 self.0.entity_appearance = appearance;
74 self
75 }
76
77 #[must_use]
78 pub fn with_dead_reckoning_parameters(mut self, parameters: DrParameters) -> Self {
79 self.0.dead_reckoning_parameters = parameters;
80 self
81 }
82
83 #[must_use]
84 pub fn with_marking(mut self, marking: EntityMarking) -> Self {
85 self.0.entity_marking = marking;
86 self
87 }
88
89 #[must_use]
90 pub fn with_capabilities(mut self, capabilities: EntityCapabilities) -> Self {
91 self.0.entity_capabilities = capabilities;
92 self
93 }
94
95 #[must_use]
96 #[allow(clippy::fn_params_excessive_bools)]
97 pub fn with_capabilities_flags(
98 mut self,
99 ammunition_supply: bool,
100 fuel_supply: bool,
101 recovery: bool,
102 repair: bool,
103 ) -> Self {
104 use crate::v6::entity_state::model::EntityCapabilities as CapabilitiesV6;
105 let v6_capabilities = CapabilitiesV6 {
106 ammunition_supply,
107 fuel_supply,
108 recovery,
109 repair,
110 };
111 self.0.entity_capabilities = EntityCapabilities::from(v6_capabilities);
112 self
113 }
114
115 #[must_use]
116 pub fn with_variable_parameter(mut self, parameter: VariableParameter) -> Self {
117 self.0.variable_parameters.push(parameter);
118 self
119 }
120
121 #[must_use]
122 pub fn with_variable_parameters(mut self, parameters: Vec<VariableParameter>) -> Self {
123 self.0.variable_parameters = parameters;
124 self
125 }
126}