dis_rs/common/aggregate_state/
builder.rs1use crate::aggregate_state::model::{
2 AggregateMarking, AggregateState, AggregateType, SilentAggregateSystem, SilentEntitySystem,
3};
4use crate::enumerations::{AggregateStateAggregateState, AggregateStateFormation, ForceId};
5use crate::model::{EntityId, Location, Orientation, VariableDatum, VectorF32};
6
7pub struct AggregateStateBuilder(AggregateState);
8
9impl Default for AggregateStateBuilder {
10 fn default() -> Self {
11 Self::new()
12 }
13}
14
15impl AggregateStateBuilder {
16 #[must_use]
17 pub fn new() -> Self {
18 AggregateStateBuilder(AggregateState::default())
19 }
20
21 #[must_use]
22 pub fn new_from_body(body: AggregateState) -> Self {
23 AggregateStateBuilder(body)
24 }
25
26 #[must_use]
27 pub fn build(self) -> AggregateState {
28 self.0
29 }
30
31 #[must_use]
32 pub fn with_aggregate_id(mut self, aggregate_id: EntityId) -> Self {
33 self.0.aggregate_id = aggregate_id;
34 self
35 }
36
37 #[must_use]
38 pub fn with_force_id(mut self, force_id: ForceId) -> Self {
39 self.0.force_id = force_id;
40 self
41 }
42
43 #[must_use]
44 pub fn with_aggregate_state(mut self, aggregate_state: AggregateStateAggregateState) -> Self {
45 self.0.aggregate_state = aggregate_state;
46 self
47 }
48
49 #[must_use]
50 pub fn with_aggregate_type(mut self, aggregate_type: AggregateType) -> Self {
51 self.0.aggregate_type = aggregate_type;
52 self
53 }
54
55 #[must_use]
56 pub fn with_formation(mut self, formation: AggregateStateFormation) -> Self {
57 self.0.formation = formation;
58 self
59 }
60
61 #[must_use]
62 pub fn with_aggregate_marking(mut self, aggregate_marking: AggregateMarking) -> Self {
63 self.0.aggregate_marking = aggregate_marking;
64 self
65 }
66
67 #[must_use]
68 pub fn with_dimensions(mut self, dimensions: VectorF32) -> Self {
69 self.0.dimensions = dimensions;
70 self
71 }
72
73 #[must_use]
74 pub fn with_orientation(mut self, orientation: Orientation) -> Self {
75 self.0.orientation = orientation;
76 self
77 }
78
79 #[must_use]
80 pub fn with_center_of_mass(mut self, center_of_mass: Location) -> Self {
81 self.0.center_of_mass = center_of_mass;
82 self
83 }
84
85 #[must_use]
86 pub fn with_velocity(mut self, velocity: VectorF32) -> Self {
87 self.0.velocity = velocity;
88 self
89 }
90
91 #[must_use]
92 pub fn with_aggregate(mut self, aggregate: EntityId) -> Self {
93 self.0.aggregates.push(aggregate);
94 self
95 }
96
97 #[must_use]
98 pub fn with_aggregates(mut self, aggregates: Vec<EntityId>) -> Self {
99 self.0.aggregates = aggregates;
100 self
101 }
102
103 #[must_use]
104 pub fn with_entity(mut self, entity: EntityId) -> Self {
105 self.0.entities.push(entity);
106 self
107 }
108
109 #[must_use]
110 pub fn with_entities(mut self, entities: Vec<EntityId>) -> Self {
111 self.0.entities = entities;
112 self
113 }
114
115 #[must_use]
116 pub fn with_silent_aggregate_system(
117 mut self,
118 silent_aggregate_system: SilentAggregateSystem,
119 ) -> Self {
120 self.0
121 .silent_aggregate_systems
122 .push(silent_aggregate_system);
123 self
124 }
125
126 #[must_use]
127 pub fn with_silent_aggregate_systems(
128 mut self,
129 silent_aggregate_systems: Vec<SilentAggregateSystem>,
130 ) -> Self {
131 self.0.silent_aggregate_systems = silent_aggregate_systems;
132 self
133 }
134
135 #[must_use]
136 pub fn with_silent_entity_system(mut self, silent_entity_system: SilentEntitySystem) -> Self {
137 self.0.silent_entity_systems.push(silent_entity_system);
138 self
139 }
140
141 #[must_use]
142 pub fn with_silent_entity_systems(
143 mut self,
144 silent_entity_systems: Vec<SilentEntitySystem>,
145 ) -> Self {
146 self.0.silent_entity_systems = silent_entity_systems;
147 self
148 }
149
150 #[must_use]
151 pub fn with_variable_datum(mut self, variable_datum: VariableDatum) -> Self {
152 self.0.variable_datums.push(variable_datum);
153 self
154 }
155
156 #[must_use]
157 pub fn with_variable_datums(mut self, variable_datums: Vec<VariableDatum>) -> Self {
158 self.0.variable_datums = variable_datums;
159 self
160 }
161}