dis_rs/common/entity_state_update/
builder.rs1use crate::entity_state::model::EntityAppearance;
2use crate::entity_state_update::model::EntityStateUpdate;
3use crate::model::{EntityId, Location, Orientation, VariableParameter, VectorF32};
4use alloc::vec::Vec;
5
6pub struct EntityStateUpdateBuilder(EntityStateUpdate);
7
8impl Default for EntityStateUpdateBuilder {
9 fn default() -> Self {
10 Self::new()
11 }
12}
13
14impl EntityStateUpdateBuilder {
15 #[must_use]
16 pub fn new() -> Self {
17 EntityStateUpdateBuilder(EntityStateUpdate::default())
18 }
19
20 #[must_use]
21 pub fn new_from_body(body: EntityStateUpdate) -> Self {
22 EntityStateUpdateBuilder(body)
23 }
24
25 #[must_use]
26 pub fn build(self) -> EntityStateUpdate {
27 self.0
28 }
29
30 #[must_use]
31 pub fn with_entity_id(mut self, entity_id: EntityId) -> Self {
32 self.0.entity_id = entity_id;
33 self
34 }
35
36 #[must_use]
37 pub fn with_velocity(mut self, velocity: VectorF32) -> Self {
38 self.0.entity_linear_velocity = velocity;
39 self
40 }
41
42 #[must_use]
43 pub fn with_location(mut self, location: Location) -> Self {
44 self.0.entity_location = location;
45 self
46 }
47
48 #[must_use]
49 pub fn with_orientation(mut self, orientation: Orientation) -> Self {
50 self.0.entity_orientation = orientation;
51 self
52 }
53
54 #[must_use]
55 pub fn with_appearance(mut self, appearance: EntityAppearance) -> Self {
56 self.0.entity_appearance = appearance;
57 self
58 }
59
60 #[must_use]
61 pub fn with_variable_parameter(mut self, parameter: VariableParameter) -> Self {
62 self.0.variable_parameters.push(parameter);
63 self
64 }
65
66 #[must_use]
67 pub fn with_variable_parameters(mut self, parameters: Vec<VariableParameter>) -> Self {
68 self.0.variable_parameters = parameters;
69 self
70 }
71}