pub trait SystemContext: WorldHandle {
// Required methods
fn spawn(&mut self) -> EntityId;
fn despawn(&mut self, entity: EntityId);
fn set_component(
&mut self,
entity: EntityId,
type_id: TypeId,
component: Box<dyn Any + Send + Sync>,
);
fn entities_with(&self, type_id: TypeId) -> Vec<EntityId> ⓘ;
fn get_component(
&self,
entity: EntityId,
type_id: TypeId,
) -> Option<&dyn Any>;
fn get_component_mut(
&mut self,
entity: EntityId,
type_id: TypeId,
) -> Option<&mut dyn Any>;
fn budget(&self) -> &TickBudget;
}Expand description
Abstract interface for system runners.
Extends WorldHandle with
ECS storage methods (spawn, despawn, component access). System
closures receive this trait object instead of a raw &mut Ecs,
keeping the ECS as an implementation detail.
Pure world ops (get_block, set_block, check_overlap, …)
come from WorldHandle and are not redeclared here. ECS methods
use TypeId + dyn Any internally; typed access is provided via
SystemContextExt.
Required Methods§
Sourcefn set_component(
&mut self,
entity: EntityId,
type_id: TypeId,
component: Box<dyn Any + Send + Sync>,
)
fn set_component( &mut self, entity: EntityId, type_id: TypeId, component: Box<dyn Any + Send + Sync>, )
Sets a component value for an entity (type-erased).
Sourcefn entities_with(&self, type_id: TypeId) -> Vec<EntityId> ⓘ
fn entities_with(&self, type_id: TypeId) -> Vec<EntityId> ⓘ
Returns all entity IDs that have a component of the given type.
Sourcefn get_component(&self, entity: EntityId, type_id: TypeId) -> Option<&dyn Any>
fn get_component(&self, entity: EntityId, type_id: TypeId) -> Option<&dyn Any>
Returns a reference to a component as dyn Any.
Sourcefn get_component_mut(
&mut self,
entity: EntityId,
type_id: TypeId,
) -> Option<&mut dyn Any>
fn get_component_mut( &mut self, entity: EntityId, type_id: TypeId, ) -> Option<&mut dyn Any>
Returns a mutable reference to a component as dyn Any.
Sourcefn budget(&self) -> &TickBudget
fn budget(&self) -> &TickBudget
Returns the CPU budget for the current system invocation.
Budget-aware systems call this to check remaining time and yield early when expired. Systems that ignore the budget run to completion.