@@ -33,7 +33,7 @@ impl ParticlesState {
3333 pub fn emit (
3434 self : & mut Self ,
3535 emitting_count : u32 ,
36- emitting_type : ParticleType ,
36+ emitting_type : & ParticleType ,
3737 pos_x : f32 ,
3838 pos_y : f32 ,
3939 ) {
@@ -117,6 +117,8 @@ pub struct ParticlesState {
117117 pool : Vec < Particle > ,
118118 emitting_index : usize ,
119119}
120+
121+ #[ derive( Clone ) ]
120122struct Particle {
121123 pos_x : f32 ,
122124 pos_y : f32 ,
@@ -152,13 +154,16 @@ impl Particle {
152154 }
153155}
154156
157+ #[ derive( Clone ) ]
155158pub struct ParticleType {
156159 effects : Vec < ParticleEffect > ,
157160 lifetime : f32 ,
158161 size_x : u32 ,
159162 size_y : u32 ,
160163 color : Color ,
161164}
165+
166+ #[ derive( Clone , Copy ) ]
162167pub enum ParticleEffect {
163168 ConstantRotation { angle : f32 } ,
164169 LinearMovement { velocity_x : f32 , velocity_y : f32 } ,
@@ -238,7 +243,7 @@ mod tests {
238243 let ptype = crate :: ParticleTypeBuilder :: new ( 16 , 16 , Duration :: from_secs ( 4 ) )
239244 . with_effect ( crate :: ParticleEffect :: LinearMovement { velocity_x : 5.0 , velocity_y : 4.0 } )
240245 . build ( ) ;
241- particles_state. emit ( 4 , ptype, 0.0 , 0.0 ) ;
246+ particles_state. emit ( 4 , & ptype, 0.0 , 0.0 ) ;
242247 particles_state. update ( Duration :: from_secs ( 2 ) ) ;
243248 let last = particles_state. pool . get_mut ( 3 ) . unwrap ( ) ;
244249 assert_eq ! ( last. pos_x, 10.0 ) ;
@@ -253,7 +258,7 @@ mod tests {
253258 let ptype = crate :: ParticleTypeBuilder :: new ( 16 , 16 , Duration :: from_secs ( 4 ) )
254259 . with_effect ( crate :: ParticleEffect :: FadeOut { delay : Duration :: from_secs_f32 ( 2.0 ) } )
255260 . build ( ) ;
256- particles_state. emit ( 4 , ptype, 0.0 , 0.0 ) ;
261+ particles_state. emit ( 4 , & ptype, 0.0 , 0.0 ) ;
257262 {
258263 let last = particles_state. pool . get_mut ( 3 ) . unwrap ( ) ;
259264 assert_eq ! ( last. alpha, 255.0 ) ;
0 commit comments