pub struct DensityEntity {Show 19 fields
pub particles: Vec<DensityParticle>,
pub shape_field: ShapeField,
pub position: Vec3,
pub hp_ratio: f32,
pub binding_strength: f32,
pub base_binding: f32,
pub max_particles: u32,
pub breath_phase: f32,
pub breath_rate: f32,
pub breath_amplitude: f32,
pub damping: f32,
pub jitter: f32,
pub base_color: Vec4,
pub alive: bool,
pub death_time: f32,
pub time: f32,
pub name: String,
pub id: u32,
pub center_of_mass: Vec2,
}Expand description
An entity composed of thousands of particles forming a shape through density.
Fields§
§particles: Vec<DensityParticle>All particles in the cloud.
shape_field: ShapeFieldShape definition (bones).
position: Vec3World position.
hp_ratio: f32HP ratio (1.0 = full, 0.0 = dead).
binding_strength: f32Global binding strength (spring constant toward target).
base_binding: f32Base binding strength (full HP value).
max_particles: u32Maximum particle count (decreases permanently on crits).
breath_phase: f32Breathing phase.
breath_rate: f32Breathing rate.
breath_amplitude: f32Breathing amplitude.
damping: f32Global damping.
jitter: f32Jitter strength (shimmer).
base_color: Vec4Base color for the entity.
alive: boolWhether the entity is alive.
death_time: f32Time since death.
time: f32Accumulated time.
name: StringEntity name.
id: u32Unique ID.
center_of_mass: Vec2Center of mass (computed).
Implementations§
Source§impl DensityEntity
impl DensityEntity
Sourcepub fn new(
name: &str,
position: Vec3,
shape: ShapeField,
particle_count: u32,
color: Vec4,
) -> Self
pub fn new( name: &str, position: Vec3, shape: ShapeField, particle_count: u32, color: Vec4, ) -> Self
Create a new density entity from a shape field and particle count.
Sourcepub fn compute_center_of_mass(&mut self)
pub fn compute_center_of_mass(&mut self)
Compute center of mass of alive particles.
Sourcepub fn alive_count(&self) -> u32
pub fn alive_count(&self) -> u32
Count alive particles.
Sourcepub fn apply_hit(&mut self, impact_pos: Vec2, damage: f32, radius: f32)
pub fn apply_hit(&mut self, impact_pos: Vec2, damage: f32, radius: f32)
Apply a hit: particles near impact receive impulse, binding temporarily reduced.
Sourcepub fn apply_crit(&mut self, impact_pos: Vec2, damage: f32)
pub fn apply_crit(&mut self, impact_pos: Vec2, damage: f32)
Crit hit: permanently kill some particles.
Sourcepub fn is_dissolved(&self) -> bool
pub fn is_dissolved(&self) -> bool
Whether the entity has fully dissolved (all emission faded).
Trait Implementations§
Source§impl Clone for DensityEntity
impl Clone for DensityEntity
Auto Trait Implementations§
impl Freeze for DensityEntity
impl RefUnwindSafe for DensityEntity
impl Send for DensityEntity
impl Sync for DensityEntity
impl Unpin for DensityEntity
impl UnsafeUnpin for DensityEntity
impl UnwindSafe for DensityEntity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.