dis_rs/common/collision_elastic/
builder.rs

1use crate::common::collision_elastic::model::CollisionElastic;
2use crate::common::model::{EntityId, EventId, VectorF32};
3
4pub struct CollisionElasticBuilder(CollisionElastic);
5
6impl Default for CollisionElasticBuilder {
7    fn default() -> Self {
8        Self::new()
9    }
10}
11
12impl CollisionElasticBuilder {
13    #[must_use]
14    pub fn new() -> Self {
15        CollisionElasticBuilder(CollisionElastic::default())
16    }
17
18    #[must_use]
19    pub fn new_from_body(body: CollisionElastic) -> Self {
20        CollisionElasticBuilder(body)
21    }
22
23    #[must_use]
24    pub fn build(self) -> CollisionElastic {
25        self.0
26    }
27
28    #[must_use]
29    pub fn with_issuing_entity_id(mut self, issuing_entity_id: EntityId) -> Self {
30        self.0.issuing_entity_id = issuing_entity_id;
31        self
32    }
33
34    #[must_use]
35    pub fn with_colliding_entity_id(mut self, colliding_entity_id: EntityId) -> Self {
36        self.0.colliding_entity_id = colliding_entity_id;
37        self
38    }
39
40    #[must_use]
41    pub fn with_event_id(mut self, event_id: EventId) -> Self {
42        self.0.event_id = event_id;
43        self
44    }
45
46    #[must_use]
47    pub fn with_velocity(mut self, velocity: VectorF32) -> Self {
48        self.0.velocity = velocity;
49        self
50    }
51
52    #[must_use]
53    pub fn with_mass(mut self, mass: f32) -> Self {
54        self.0.mass = mass;
55        self
56    }
57
58    #[must_use]
59    pub fn with_location(mut self, location: VectorF32) -> Self {
60        self.0.location = location;
61        self
62    }
63
64    #[must_use]
65    pub fn with_intermediate_result_xx(mut self, intermediate_result_xx: f32) -> Self {
66        self.0.intermediate_result_xx = intermediate_result_xx;
67        self
68    }
69
70    #[must_use]
71    pub fn with_intermediate_result_xy(mut self, intermediate_result_xy: f32) -> Self {
72        self.0.intermediate_result_xy = intermediate_result_xy;
73        self
74    }
75
76    #[must_use]
77    pub fn with_intermediate_result_xz(mut self, intermediate_result_xz: f32) -> Self {
78        self.0.intermediate_result_xz = intermediate_result_xz;
79        self
80    }
81
82    #[must_use]
83    pub fn with_intermediate_result_yy(mut self, intermediate_result_yy: f32) -> Self {
84        self.0.intermediate_result_yy = intermediate_result_yy;
85        self
86    }
87
88    #[must_use]
89    pub fn with_intermediate_result_yz(mut self, intermediate_result_yz: f32) -> Self {
90        self.0.intermediate_result_yz = intermediate_result_yz;
91        self
92    }
93
94    #[must_use]
95    pub fn with_intermediate_result_zz(mut self, intermediate_result_zz: f32) -> Self {
96        self.0.intermediate_result_zz = intermediate_result_zz;
97        self
98    }
99
100    #[must_use]
101    pub fn with_unit_surface_normal(mut self, unit_surface_normal: VectorF32) -> Self {
102        self.0.unit_surface_normal = unit_surface_normal;
103        self
104    }
105
106    #[must_use]
107    pub fn with_coefficient_of_restitution(mut self, coefficient_of_restitution: f32) -> Self {
108        self.0.coefficient_of_restitution = coefficient_of_restitution;
109        self
110    }
111}