Skip to main content

Module gameplay

Module gameplay 

Source
Expand description

Small built-in gameplay components usable from both the editor and native scripts.

Tags provides non-unique group labels, Lifetime removes temporary subtrees, and Visibility hides a rendered subtree while gameplay continues.

use kvas_engine::{scene::Scene, gameplay::{Tags, Lifetime}, runtime::Runtime};
let mut scene = Scene::default();
let effect = scene.spawn("temporary effect");
let mut tags = Tags::default();
assert!(tags.insert("effect"));
scene.world.insert(effect, tags);
scene.world.insert(effect, Lifetime::new(0.02).unwrap());
let mut runtime = Runtime::new(scene, None);
runtime.tick(0.03);
assert!(!runtime.scene.world.is_alive(effect));

Structs§

Lifetime
Remaining simulation lifetime of an entity and its complete subtree. Updated once per accepted runtime frame after scripts. Pausing/time scaling applies naturally. Zero or invalid remaining time expires on the next update.
Tags
Case-sensitive whitespace-separated entity group labels. Tags are non-unique across entities; tag strings cannot contain whitespace. Duplicate/extra whitespace entered in the Inspector is tolerated on reads.
Visibility
Rendering visibility inherited by descendants; it does not disable scripts or physics. An absent component behaves as visible. A hidden ancestor hides all descendants, including transient procedural meshes. Lights remain active independently.

Functions§

tagged
Snapshot of all entities containing an exact tag, in entity index order.
update_lifetimes
Advances remaining lifetimes and removes expired subtrees before physics. Non-positive/non-finite deltas are ignored; malformed lifetimes expire on a valid update.