pub struct AmorphousEntity {Show 18 fields
pub name: String,
pub position: Vec3,
pub binding_field: ForceField,
pub glyph_ids: Vec<GlyphId>,
pub formation: Vec<Vec3>,
pub formation_chars: Vec<char>,
pub formation_colors: Vec<Vec4>,
pub hp: f32,
pub max_hp: f32,
pub entity_mass: f32,
pub entity_temperature: f32,
pub entity_entropy: f32,
pub cohesion: f32,
pub pulse_rate: f32,
pub pulse_depth: f32,
pub age: f32,
pub tags: Vec<String>,
pub despawn_requested: bool,
/* private fields */
}Expand description
An amorphous visual entity held together by binding forces.
Fields§
§name: String§position: Vec3§binding_field: ForceFieldThe core force holding the entity together. Usually Gravity.
glyph_ids: Vec<GlyphId>IDs of glyphs that compose this entity.
formation: Vec<Vec3>Target positions (relative to entity center) for each glyph.
formation_chars: Vec<char>Character assigned to each formation slot.
formation_colors: Vec<Vec4>Color assigned to each formation slot.
hp: f32§max_hp: f32§entity_mass: f32§entity_temperature: f32§entity_entropy: f32§cohesion: f320.0 = fully dispersed, 1.0 = tight formation. Driven by hp/max_hp: cohesion = (hp / max_hp).sqrt()
pulse_rate: f32The entity’s pulse function (breathing/heartbeat rhythm).
pulse_depth: f32§age: f32Arbitrary string tags for filtering/grouping.
despawn_requested: boolSet to true to remove the entity on the next GC pass.
Implementations§
Source§impl AmorphousEntity
impl AmorphousEntity
pub fn new(name: impl Into<String>, position: Vec3) -> Self
Sourcepub fn update_cohesion(&mut self)
pub fn update_cohesion(&mut self)
Update cohesion based on current HP.
Sourcepub fn tick(&mut self, dt: f32, _time: f32) -> bool
pub fn tick(&mut self, dt: f32, _time: f32) -> bool
Advance entity time. Returns true if the entity should be removed (hp <= 0).
This only advances the entity’s own state. Moving its glyphs is
crate::scene::SceneGraph::tick’s job, because that is where the
glyph pool lives.
Sourcepub fn rebuild_cohesion(&mut self)
pub fn rebuild_cohesion(&mut self)
Build the per-glyph spring system from the current formation.
Called lazily so an entity assembled field-by-field still gets physics.
Sourcepub fn step_glyph_physics(&mut self, dt: f32) -> Vec<Vec3>
pub fn step_glyph_physics(&mut self, dt: f32) -> Vec<Vec3>
Step the glyph springs and return where each glyph should now be.
The formation is the target; cohesion decides how hard the springs pull toward it. A damaged entity does not play a “hurt” animation — its binding weakens and the matter drifts, which is the whole premise of rendering things out of particles.
Sourcepub fn apply_impulse(&mut self, impulse: Vec3)
pub fn apply_impulse(&mut self, impulse: Vec3)
Knock the whole formation in a direction — a hit landing.
Sourcepub fn reform(&mut self, cohesion: f32)
pub fn reform(&mut self, cohesion: f32)
Pull a dissolved entity back together.
The counterpart to AmorphousEntity::dissolve. Matter that has been
scattered comes back under the springs and flies to whatever formation
is currently set, which is what lets an entity be taken apart and
rebuilt as something else rather than only ever dying.
Sourcepub fn reshape(&mut self, formation: &[Vec3])
pub fn reshape(&mut self, formation: &[Vec3])
Replace the formation, keeping the matter where it currently is.
The springs retarget, so the glyphs travel to the new shape instead of appearing in it. Slots are reused cyclically when the new shape has fewer of them than the entity has glyphs, so no matter is stranded.
Sourcepub fn set_bind(&mut self, stiffness_scale: f32, damping_scale: f32)
pub fn set_bind(&mut self, stiffness_scale: f32, damping_scale: f32)
Set how hard this entity’s springs pull, on top of cohesion.
Sourcepub fn set_bind_each(&mut self, springs: &[(f32, f32)])
pub fn set_bind_each(&mut self, springs: &[(f32, f32)])
Give each particle its own spring, by slot.
See cohesion::CohesionManager::set_bind_each. This is how a body
made of several materials behaves like several materials.
Sourcepub fn set_floor(&mut self, y: Option<f32>)
pub fn set_floor(&mut self, y: Option<f32>)
Put a floor under this entity’s matter.
See cohesion::CohesionManager::set_floor. This is what makes a
figure stand on the ground rather than hover at whatever height
something else decided it should be.
Sourcepub fn take_damage(&mut self, amount: f32)
pub fn take_damage(&mut self, amount: f32)
Apply damage to this entity.
Trait Implementations§
Source§impl Clone for AmorphousEntity
impl Clone for AmorphousEntity
Auto Trait Implementations§
impl Freeze for AmorphousEntity
impl RefUnwindSafe for AmorphousEntity
impl Send for AmorphousEntity
impl Sync for AmorphousEntity
impl Unpin for AmorphousEntity
impl UnsafeUnpin for AmorphousEntity
impl UnwindSafe for AmorphousEntity
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.