pub trait ParticleSystem {
type ParticleType: Particle;
type EmitterType: ParticleEmitter<ParticleType = Self::ParticleType>;
// Required methods
fn iter_particles(&self) -> impl Iterator<Item = &Self::ParticleType>;
fn iter_particles_mut(
&mut self,
) -> impl Iterator<Item = &mut Self::ParticleType>;
fn iter_emitters(&self) -> impl Iterator<Item = &Self::EmitterType>;
fn iter_emitters_mut(
&mut self,
) -> impl Iterator<Item = &mut Self::EmitterType>;
fn add_particle(&mut self, particle: Self::ParticleType);
fn add_emitter(&mut self, emitter: Self::EmitterType);
fn clean_particles(&mut self);
fn clean_emitters(&mut self);
// Provided methods
fn update_particles(&mut self, dt: f64) { ... }
fn update_emitters(&mut self, dt: f64) -> Vec<Self::ParticleType> { ... }
fn update(&mut self, dt: f64) { ... }
}Expand description
A collection of particles and emitters
Required Associated Types§
Sourcetype ParticleType: Particle
type ParticleType: Particle
The type of particle that this system will contain
Sourcetype EmitterType: ParticleEmitter<ParticleType = Self::ParticleType>
type EmitterType: ParticleEmitter<ParticleType = Self::ParticleType>
The type of emitter that this system will contain
Required Methods§
Sourcefn iter_particles(&self) -> impl Iterator<Item = &Self::ParticleType>
fn iter_particles(&self) -> impl Iterator<Item = &Self::ParticleType>
Returns an iterator over all currently alive particles in the system
Sourcefn iter_particles_mut(
&mut self,
) -> impl Iterator<Item = &mut Self::ParticleType>
fn iter_particles_mut( &mut self, ) -> impl Iterator<Item = &mut Self::ParticleType>
Returns a mutable iterator over all currently alive particles in the system
Sourcefn iter_emitters(&self) -> impl Iterator<Item = &Self::EmitterType>
fn iter_emitters(&self) -> impl Iterator<Item = &Self::EmitterType>
Returns an iterator over all currently alive particle emitters in the system
Sourcefn iter_emitters_mut(&mut self) -> impl Iterator<Item = &mut Self::EmitterType>
fn iter_emitters_mut(&mut self) -> impl Iterator<Item = &mut Self::EmitterType>
Returns a mutable iterator over all currently alive particle emitters in the system
Sourcefn add_particle(&mut self, particle: Self::ParticleType)
fn add_particle(&mut self, particle: Self::ParticleType)
Adds a particle to the system
Sourcefn add_emitter(&mut self, emitter: Self::EmitterType)
fn add_emitter(&mut self, emitter: Self::EmitterType)
Adds an emitter to the system
Sourcefn clean_particles(&mut self)
fn clean_particles(&mut self)
Removes dead particles from the system
Sourcefn clean_emitters(&mut self)
fn clean_emitters(&mut self)
Removes dead emitters from the system
Provided Methods§
Sourcefn update_particles(&mut self, dt: f64)
fn update_particles(&mut self, dt: f64)
Iterates over all currently alive particles in the system and calls their update method
Sourcefn update_emitters(&mut self, dt: f64) -> Vec<Self::ParticleType>
fn update_emitters(&mut self, dt: f64) -> Vec<Self::ParticleType>
Iterates over all currently alive particle emitters in the system and calls their update method, returning the vector of new particles to add to the system
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".