dis_rs/common/entity_state_update/
builder.rs

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