Skip to main content

Ctx

Struct Ctx 

Source
pub struct Ctx<'a> {
    pub entity: Entity,
    pub scene: &'a mut Scene,
    pub input: &'a Input,
    pub time: Time,
    /* private fields */
}
Expand description

What a script sees each call.

Fields§

§entity: Entity

Entity owning this script slot; it may become stale if a script despawns it.

§scene: &'a mut Scene

Mutable host scene. Register custom storages only in permanent host code.

§input: &'a Input

Frame snapshot and shared shell requests.

§time: Time

Scaled callback time.

Implementations§

Source§

impl Ctx<'_>

Source

pub fn ui(&self) -> &Canvas

The screen interface of this frame (see crate::canvas).

Source

pub fn ui_width(&self) -> f32

Width of the virtual interface screen (its height is always 720).

Source

pub fn storage(&self) -> Storage

The game’s data folder: saves, settings and files.

Source

pub fn save_game( &self, slot: &str, title: &str, data: &Value, ) -> Result<(), String>

Writes a save slot (title is shown in load menus; the scene is recorded too).

Source

pub fn load_game(&self, slot: &str) -> Option<Value>

Reads a save slot.

Source

pub fn save_slots(&self) -> Vec<SaveInfo>

Every save, newest first.

Source

pub fn has_save(&self, slot: &str) -> bool

Whether a slot exists.

Source

pub fn setting_f32(&self, key: &str, default: f32) -> f32

A persistent setting (kept across runs), or default.

Source

pub fn setting_bool(&self, key: &str, default: bool) -> bool

A persistent on/off setting, or default.

Source

pub fn setting_text(&self, key: &str, default: &str) -> String

A persistent text setting, or default.

Source

pub fn set_setting(&self, key: &str, value: Value)

Stores a persistent setting.

Source

pub fn active_camera(&self) -> Option<Entity>

The camera the game looks through.

Source

pub fn set_active_camera(&mut self, camera: Entity) -> bool

Looks through another camera from the next frame on (security monitors, cut-scenes…).

Source

pub fn set_active_camera_named(&mut self, name: &str) -> bool

Switches to the camera named name.

Source

pub fn add_camera_effect( &mut self, camera: Entity, shader: &str, params: [f32; 4], ) -> Option<usize>

Adds a camera shader (fn effect) to a camera; returns its index.

Source

pub fn set_camera_effect( &mut self, camera: Entity, index: usize, enabled: bool, params: [f32; 4], )

Changes the numbers of a camera shader (fade a VHS, pulse damage…).

Source

pub fn set_camera_fov(&mut self, camera: Entity, fov: f32)

Field of view of a camera in degrees (zoom, sprint effect).

Source

pub fn camera_position(&self) -> Option<Vec3>

World position of the active camera.

Source

pub fn camera_forward(&self) -> Option<Vec3>

Direction the active camera looks along.

Source

pub fn place_camera(&mut self, camera: Entity, position: Vec3, target: Vec3)

Places a camera and points it at a target (cut-scenes).

Source

pub fn set_reverb(&mut self, amount: f32, room_ms: f32)

Room echo for sounds started from now on: amount 0..1, room_ms first reflection delay (20 small room .. 120 hall). Call when the player enters a space.

Source

pub fn set_volumes(&mut self, master: f32, music: f32, effects: f32)

Volumes of the mix: everything, music, other sounds (0..1, kept up to 2).

Source

pub fn quit_game(&self)

Closes the game (in the editor it stops Play).

Source

pub fn set_fullscreen(&self, on: bool)

Switches the window to fullscreen or back.

Source§

impl Ctx<'_>

Source

pub fn dt(&self) -> f32

Callback delta in seconds; fixed callbacks receive the configured fixed interval.

Source

pub fn elapsed(&self) -> f32

Scaled gameplay seconds since runtime creation.

Source

pub fn frame(&self) -> u64

Frames simulated so far (a counter, handy for “every N frames”).

Source

pub fn fps(&self) -> f32

Frames per second implied by this callback’s dt (0 when dt is 0).

Source

pub fn every(&self, seconds: f32) -> bool

True once every seconds of game time (use inside update).

Source

pub fn time_of_day(&self) -> f32

Current in-game hour, 0..24.

Source

pub fn set_time_of_day(&mut self, hour: f32)

Jumps to an hour of the day (wraps into 0..24) and switches the procedural sky on.

Source

pub fn set_day_speed(&mut self, hours_per_second: f32)

Game hours that pass per real second (0 freezes the sun).

Source

pub fn sky(&mut self) -> &mut SkySettings

The whole sky configuration for fine control: clouds, stars, haze, aurora, moon.

Source

pub fn set_clouds(&mut self, amount: f32)

0 = clear sky, 1 = overcast.

Source

pub fn is_night(&self) -> bool

Whether it is night (sun below the horizon, roughly 20:00-05:00).

Source

pub fn post(&mut self) -> &mut PostSettings

Screen effects for fine control: ctx.post().bloom = 0.8; ctx.post().motion_blur = 0.5;.

Source

pub fn shadows(&mut self) -> &mut ShadowSettings

Sun shadow settings: ctx.shadows().softness = 2.0;.

Source

pub fn post_preset(&mut self, name: &str)

Applies a ready-made look: “cinematic”, “dreamy”, “crisp”, “retro” or anything else for none.

Source

pub fn set_exposure(&mut self, exposure: f32)

Exposure multiplier (brightness) of the picture.

Source

pub fn add_post_effect(&mut self, shader: &str) -> usize

Adds a custom full-screen shader to the camera (a WGSL file with fn effect(..)) and returns its index.

Source

pub fn set_post_effect_params(&mut self, index: usize, params: [f32; 4])

Sets the four numbers a custom effect receives as params.

Source

pub fn enable_post_effect(&mut self, index: usize, on: bool)

Switches a custom effect on or off.

Source

pub fn clear_post_effects(&mut self)

Removes every custom camera effect.

Source

pub fn play_sound(&mut self, clip: &str, volume: f32) -> SoundId

Plays a clip (path inside assets/) in 2D, e.g. ctx.play_sound("sounds/click.wav", 1.0).

Source

pub fn play_music(&mut self, clip: &str, volume: f32) -> SoundId

Plays a looping 2D clip (music). Keep the id to stop it with Self::stop_sound.

Source

pub fn play_sound_at( &mut self, clip: &str, volume: f32, position: Vec3, ) -> SoundId

Plays a clip at a world position (distance falloff and left/right stereo).

Source

pub fn play_sound_panned( &mut self, clip: &str, volume: f32, pan: f32, ) -> SoundId

Plays a clip with stereo position pan (-1 left .. 1 right).

Source

pub fn play_sound_pitched( &mut self, clip: &str, volume: f32, pitch: f32, ) -> SoundId

Plays a clip with a pitch / speed multiplier.

Source

pub fn stop_sound(&mut self, id: SoundId)

Stops a sound started earlier.

Source

pub fn set_sound_volume(&mut self, id: SoundId, volume: f32)

Changes the volume of a running sound.

Source

pub fn stop_all_sounds(&mut self)

Stops every sound.

Source

pub fn set_master_volume(&mut self, volume: f32)

Master volume for the whole game, 0..1.

Source

pub fn world(&mut self) -> &mut World

Mutable host world; its built-in component storages already exist.

Source

pub fn log(&mut self, msg: impl Into<String>)

Appends a message to the host log shown in the editor/player.

Source

pub fn get<T: EcsComponent>(&self) -> Option<&T>

Borrows this entity’s component; returns None when missing or despawned.

Source

pub fn get_mut<T: EcsComponent>(&mut self) -> Option<&mut T>

Mutably borrows this entity’s component, if present.

Source

pub fn get_of<T: EcsComponent>(&self, e: Entity) -> Option<&T>

Borrows another living entity’s component, if present.

Source

pub fn get_mut_of<T: EcsComponent>(&mut self, e: Entity) -> Option<&mut T>

Mutably borrows another living entity’s component, if present.

Source

pub fn transform(&self) -> &Transform

This entity’s transform (panics only if a script removed it; the editor does not allow that).

Source

pub fn transform_mut(&mut self) -> &mut Transform

Mutable local pose.

§Panics

Panics when this entity has no Transform, including after self-despawn.

Source

pub fn world_position(&self) -> Vec3

Current world position computed from the hierarchy, including pending local edits.

Source

pub fn set_color(&mut self, e: Entity, rgba: [f32; 4])

Sets the material colour of an entity (linear-ish sRGB, 0..1).

Source

pub fn set_texture(&mut self, e: Entity, texture: &str)

Sets a texture by asset path or by a procedural key (NoiseTexture::key()).

Source

pub fn set_shape(&mut self, e: Entity, shape: Shape)

Replaces the mesh with a parametric shape (the mesh is rebuilt when parameters change).

Source

pub fn children(&self, e: Entity) -> Vec<Entity>

Direct non-transient children in entity index order.

Source

pub fn find(&self, name: &str) -> Option<Entity>

First exact entity-name match; names are not unique identifiers.

Source

pub fn find_all(&self, name: &str) -> Vec<Entity>

Every entity with this exact name.

Source

pub fn find_with<T: EcsComponent>(&self) -> Vec<Entity>

Entities that have component T.

Source

pub fn var(&self, entity: Entity, script: &str, name: &str) -> Option<Value>

Reads a public variable (a field listed in the script’s fields()) of a script on any entity, e.g. ctx.var(door, "DoorLogic", "locked"). Returns JSON: numbers, bools, strings, arrays.

Source

pub fn set_var( &mut self, entity: Entity, script: &str, name: &str, value: Value, ) -> bool

Changes a public variable of a script on any entity; the script sees it before its next callback. Returns false when the entity has no such script.

Source

pub fn var_f32(&self, entity: Entity, script: &str, name: &str) -> Option<f32>

Number variable of another script, see Ctx::var.

Source

pub fn var_bool(&self, entity: Entity, script: &str, name: &str) -> Option<bool>

Boolean variable of another script, see Ctx::var.

Source

pub fn spawn(&mut self, name: &str) -> Entity

Creates a named entity with an identity local transform.

Source

pub fn spawn_primitive( &mut self, name: &str, primitive: &str, position: Vec3, ) -> Entity

Creates a visible primitive at a world-space position with no collider/body. Supported primitive names are listed in crate::mesh::PRIMITIVES.

Source

pub fn despawn(&mut self, e: Entity)

Destroys an entity and its subtree. Physics objects are removed on the next fixed step.

Source

pub fn add_impulse(&mut self, impulse: Vec3)

Accumulates a world-space impulse for this body to consume on the next physics step. Does nothing when no RigidBody is attached.

Source

pub fn set_velocity(&mut self, v: Vec3)

Requests a world-space linear velocity in metres/second for the next fixed step.

Source

pub fn set_angular_velocity_of(&mut self, e: Entity, w: Vec3)

Sets the spin of a rigid body (any entity); Vec3::ZERO stops it rotating.

Source

pub fn set_velocity_of(&mut self, e: Entity, v: Vec3)

Sets the linear velocity of any rigid body.

Source

pub fn velocity(&self) -> Vec3

Last simulated linear velocity, or zero when no body is attached.

Source

pub fn raycast( &self, origin: Vec3, dir: Vec3, max_distance: f32, ) -> Option<RayHit>

First solid collider hit by the ray; this entity’s own collider and triggers are ignored.

Source

pub fn raycast_filtered( &self, origin: Vec3, direction: Vec3, max_distance: f32, options: QueryOptions, ) -> Option<RayHit>

Ray query with layer/sensor filters; defaults to excluding this script’s body. An explicit options.exclude overrides that default owner exclusion.

Source

pub fn overlap_sphere_filtered( &self, center: Vec3, radius: f32, options: QueryOptions, ) -> Vec<Entity>

Sphere query under explicit layer/sensor/exclusion filters. No implicit owner exclusion.

Source

pub fn overlap_sphere(&self, center: Vec3, radius: f32) -> Vec<Entity>

Collider entities overlapping a world-space sphere in the last physics state. Includes triggers and this entity; results are sorted and deduplicated.

Source

pub fn touching(&self, entity: Entity) -> Vec<Entity>

Active solid contacts and sensor overlaps for a collider entity.

Source

pub fn is_alive(&self, entity: Entity) -> bool

Whether an entity handle still refers to a living object in this scene.

Source

pub fn world_matrix_of(&self, entity: Entity) -> Mat4

Current world matrix, evaluated directly from local transforms.

Source

pub fn set_parent(&mut self, entity: Entity, parent: Option<Entity>) -> bool

Reparents while preserving world pose when representable as TRS.

Source

pub fn set_parent_local( &mut self, entity: Entity, parent: Option<Entity>, ) -> bool

Reparents while preserving local pose; rejects stale handles and cycles.

Source

pub fn insert<T: EcsComponent>(&mut self, entity: Entity, component: T)

Adds a component of a host-registered type to a living entity.

§Panics

Panics for unregistered or conflicting component types; scripts use built-ins only.

Source

pub fn remove<T: EcsComponent>(&mut self, entity: Entity) -> Option<T>

Removes a component, returning its former value if present.

Source

pub fn has<T: EcsComponent>(&self) -> bool

Whether this entity currently has a component.

Source

pub fn attach_script(&mut self, entity: Entity, name: &str) -> bool

Adds a named script slot. The runtime creates its instance at the next sync. Returns false for a stale entity; duplicate names in different slots are allowed.

Source

pub fn detach_script(&mut self, entity: Entity, name: &str) -> usize

Removes every slot with this script name. Returns the number removed.

Source

pub fn tagged(&self, tag: &str) -> Vec<Entity>

Snapshot of all living entities with an exact tag, in index order.

Source

pub fn has_tag(&self, entity: Entity, tag: &str) -> bool

Whether an entity contains this exact group label.

Source

pub fn add_tag(&mut self, entity: Entity, tag: &str) -> bool

Adds a group label, creating Tags if needed. Invalid/duplicate labels or stale entities return false.

Source

pub fn remove_tag(&mut self, entity: Entity, tag: &str) -> bool

Removes a label without removing other tags; returns whether it existed.

Source

pub fn despawn_after(&mut self, entity: Entity, seconds: f32) -> bool

Schedules/replaces subtree expiration after non-negative simulation seconds. Zero expires after update callbacks in the current/next accepted frame. Invalid durations or stale entities return false without changing components.

Source

pub fn set_visible(&mut self, entity: Entity, visible: bool) -> bool

Sets inherited mesh visibility without changing scripts, lights or physics. Returns false for a stale entity.

Source

pub fn is_visible(&self, entity: Entity) -> bool

Effective mesh visibility, including hidden ancestors.

Source

pub fn move_to( &mut self, entity: Entity, target: Vec3, seconds: f32, ease: Ease, ) -> bool

Starts/replaces a parent-local position tween from the current pose. Returns false for invalid targets/durations, stale entities or missing transforms.

Source

pub fn teleport_of( &mut self, entity: Entity, position: Vec3, reset_velocity: bool, ) -> bool

Moves an entity to a world-space point and queues physical teleportation. With reset_velocity, pending impulses and both velocities are cleared. For a dynamic body the final pose is integrated on the next fixed step; non-physical entities move immediately. Invalid/singular requests do nothing.

Source

pub fn teleport(&mut self, position: Vec3, reset_velocity: bool) -> bool

Teleports this script’s entity, optionally resetting its motion.

Source

pub fn emit( &mut self, channel: &str, payload: Value, ) -> Result<u64, SignalError>

Broadcasts JSON data on a channel for delivery before the next frame’s callbacks. Sending is bounded and returns an explicit error rather than silently dropping data.

Source

pub fn send_to( &mut self, target: Entity, channel: &str, payload: Value, ) -> Result<u64, SignalError>

Sends a directed message to a living entity for the next simulation frame.

Source

pub fn signals(&self, channel: &str) -> Vec<Signal>

Clones the current channel messages addressed to this entity or broadcast. Owned snapshots let callbacks mutate the scene while handling messages. Reading does not consume signals; use update for one-shot processing.

Source

pub fn key_down(&self, k: Key) -> bool

Whether the physical key is held this frame.

Source

pub fn key_pressed(&self, k: Key) -> bool

Whether the physical key went down in this frame snapshot.

Source

pub fn key_released(&self, key: Key) -> bool

Whether the physical key went up in this frame snapshot.

Source

pub fn mouse_down(&self, b: MouseButton) -> bool

Whether a physical pointer button is held.

Source

pub fn mouse_pressed(&self, button: MouseButton) -> bool

Whether a physical pointer button went down this frame.

Source

pub fn mouse_released(&self, button: MouseButton) -> bool

Whether a physical pointer button went up this frame.

Source

pub fn lock_cursor(&self, lock: bool)

Hides the cursor and keeps it centred while true; input.mouse_delta then is the look movement.

Source

pub fn load_scene(&self, path: &str)

Switches to another scene once this frame ends, e.g. ctx.load_scene("scenes/level2.scene.json"). Objects and scripts of the current scene go away; the new scene starts with fresh scripts.

Source

pub fn add_scene(&self, path: &str)

Adds every object of another scene to this one once this frame ends (a level piece, a shared menu…). Its scripts start on the next frame; the scene settings stay as they are.

Source

pub fn reload_scene(&self)

Starts the running scene again from its file once this frame ends (restart a level).

Source

pub fn scene_path(&self) -> String

Asset path of the running scene, e.g. scenes/main.scene.json (empty if unknown).

Source

pub fn hud_prompt(&self, text: &str)

Shows the interaction hint on screen for this frame (“Press E to open”).

Source

pub fn hud_message(&self, text: &str, seconds: f32)

Displays a transient message for finite non-negative simulation seconds.

Source

pub fn hud_objective(&self, text: &str)

Replaces persistent HUD objective text; empty clears it.

Source

pub fn hud_crosshair(&self, on: bool)

Requests that the hosting shell show/hide the crosshair.

Source

pub fn action_down(&self, name: &str) -> bool

Named input actions from Project Settings > Input.

Source

pub fn action_pressed(&self, name: &str) -> bool

Whether any bound input went down this frame; missing actions return false.

Source

pub fn action_released(&self, name: &str) -> bool

Whether the last held input bound to this action was released.

Source

pub fn action_vector( &self, left: &str, right: &str, down: &str, up: &str, ) -> Vec2

Unit-length two-dimensional movement from four named actions.

Source

pub fn action_axis(&self, negative: &str, positive: &str) -> f32

Digital axis: positive minus negative action, in [-1, 1].

Source

pub fn rebind(&self, name: &str, inputs: &[&str])

Changes an action’s bindings while the game runs, e.g. ctx.rebind("Jump", &["Space", "W"]).

Source§

impl Ctx<'_>

Source

pub fn position(&self) -> Vec3

World position of this entity (alias of Ctx::world_position).

Source

pub fn position_of(&self, entity: Entity) -> Option<Vec3>

World position of another entity, None when it is dead or has no Transform.

Source

pub fn set_position(&mut self, position: Vec3) -> bool

Moves this entity to a world position immediately (no physics teleport; see Ctx::teleport).

Source

pub fn translate(&mut self, delta: Vec3)

Adds delta to the local position (parent space axes).

Source

pub fn translate_local(&mut self, delta: Vec3)

Moves along the entity’s own axes: translate_local(Vec3::NEG_Z * 2.0) goes 2 m forward.

Source

pub fn rotate(&mut self, degrees: Vec3)

Adds Euler degrees (pitch, yaw, roll) to the local rotation.

Source

pub fn forward(&self) -> Vec3

Facing direction (local -Z in parent space).

Source

pub fn right(&self) -> Vec3

Right direction (local +X in parent space).

Source

pub fn up(&self) -> Vec3

Up direction (local +Y in parent space).

Source

pub fn distance_to(&self, entity: Entity) -> Option<f32>

Straight-line distance to another entity, None when it cannot be measured.

Source

pub fn direction_to(&self, target: Vec3) -> Vec3

Unit vector from this entity to a world point, zero when they coincide.

Source

pub fn look_at(&mut self, target: Vec3)

Turns the entity (yaw and pitch, no roll) so that its forward axis points at a world point. Assumes the parent is not rotated. Does nothing when the point is at the entity.

Source

pub fn look_at_flat(&mut self, target: Vec3)

Like Ctx::look_at but ignores height: only the yaw changes (characters, turrets).

Source

pub fn move_towards(&mut self, target: Vec3, speed: f32) -> bool

Walks towards a world point at speed metres per second (uses the callback dt). Returns true once the point is reached. Moves the transform directly, so use it for kinematic objects; dynamic bodies should use add_impulse or set_velocity.

Source

pub fn nearest_tagged(&self, tag: &str) -> Option<(Entity, f32)>

The closest entity carrying tag (other than this one) and its distance.

Source

pub fn despawn_self(&mut self)

Removes this entity (and its children) from the scene.

Source

pub fn random(&self) -> f32

A random number in 0.0..1.0. Every call advances a shared stream, so values differ per call. For a repeatable sequence keep a crate::random::Rng in your script instead.

Source

pub fn random_range(&self, min: f32, max: f32) -> f32

A random number in min..max.

Source

pub fn chance(&self, p: f32) -> bool

True with probability p (0..1) on each call.

Source§

impl Ctx<'_>

Hierarchy, tags and shared variables.

Source

pub fn parent(&self) -> Option<Entity>

The parent of this entity, if it has a living one.

Source

pub fn parent_of(&self, entity: Entity) -> Option<Entity>

The parent of any entity.

Source

pub fn root(&self) -> Entity

The top-most ancestor (the entity itself when it has no parent).

Source

pub fn descendants(&self, entity: Entity) -> Vec<Entity>

Every entity below entity: children, grandchildren and so on.

Source

pub fn find_child(&self, name: &str) -> Option<Entity>

The first descendant of this entity with the given name.

Source

pub fn tagged_within(&self, tag: &str, center: Vec3, radius: f32) -> Vec<Entity>

Entities carrying tag within radius metres of a world point, nearest first.

Source

pub fn tags_of(&self, entity: Entity) -> Vec<String>

All tags of an entity.

Source

pub fn play_animation(&mut self, entity: Entity, clip: &str) -> bool

Plays an animation clip on an object (cross-fading from the current one); adds an crate::skeletal::Animator when the object has none. The model must have a skeleton: clips from its file, or the procedural humanoid ones (Idle, Walk, Run, Talk, Wave, Sit, Wipe, Look). Returns false for a stale entity.

Source

pub fn set_animation_speed(&mut self, entity: Entity, speed: f32)

Playback speed of an object’s animation (1 = as authored). Use it to match a walk cycle to the speed the object really moves at.

Source

pub fn ragdoll(&mut self, entity: Entity, impulse: Vec3) -> bool

Makes an animated humanoid go limp: its body becomes physics capsules joined at the joints, starting in the current pose and pushed by impulse (newton-seconds, world space). Adds a crate::ragdoll::Ragdoll when there is none. Returns false for a stale entity.

Source

pub fn stop_ragdoll(&mut self, entity: Entity)

Ends a ragdoll: the bodies are removed and the clip animates the character again.

Source

pub fn look_at_point(&mut self, entity: Entity, point: Option<Vec3>)

Turns an animated humanoid’s head (and chest) towards a world point, or lets go with None. Adds a crate::ik::CharacterIk when there is none.

Source

pub fn animation_clips(&self, entity: Entity) -> Vec<String>

The clips an animated object’s model offers (empty until its first frame was skinned).

Source

pub fn set_global(&mut self, key: &str, value: Value)

Stores a value that every script can read with Ctx::global. Lives until the game stops.

Source

pub fn global(&self, key: &str) -> Option<&Value>

A shared value, if it was set.

Source

pub fn global_f32(&self, key: &str, default: f32) -> f32

A shared number (integers are converted), or default.

Source

pub fn global_bool(&self, key: &str, default: bool) -> bool

A shared flag, or default.

Source

pub fn add_global(&mut self, key: &str, delta: f32) -> f32

Adds to a shared number (starting from 0) and returns the new value: ctx.add_global("score", 10.0).

Source§

impl Ctx<'_>

Vertex access and deformation (see crate::mesh_deform).

Source

pub fn make_editable(&mut self, entity: Entity) -> bool

Makes the entity’s built-in primitive mesh (primitive:sphere…) editable so its vertices can be changed from scripts. Returns true when the entity is editable afterwards.

Source

pub fn editable(&mut self, entity: Entity) -> Option<&mut EditableMesh>

The editable mesh of an entity, for deformation: ctx.editable(e)?.twist(Vec3::Y, 30.0).

Source§

impl Ctx<'_>

Logging for debugging: everything lands in the editor Console (warnings yellow, errors red).

Source

pub fn warn(&mut self, message: impl Into<String>)

A yellow warning line: ctx.warn("health is below zero").

Source

pub fn error(&mut self, message: impl Into<String>)

A red error line. The script keeps running; use it for conditions that should never happen.

Source

pub fn watch(&mut self, name: &str, value: impl Debug)

Logs name = value using Debug: ctx.watch("velocity", ctx.velocity()).

Source

pub fn watch_every(&mut self, seconds: f32, name: &str, value: impl Debug)

Like Ctx::watch but at most once per seconds, so it can sit in update without flooding the Console.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Ctx<'a>

§

impl<'a> !Send for Ctx<'a>

§

impl<'a> !Sync for Ctx<'a>

§

impl<'a> !UnwindSafe for Ctx<'a>

§

impl<'a> Freeze for Ctx<'a>

§

impl<'a> Unpin for Ctx<'a>

§

impl<'a> UnsafeUnpin for Ctx<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.