Skip to main content

RuntimeWorldMut

Trait RuntimeWorldMut 

Source
pub trait RuntimeWorldMut: RuntimeWorld {
    // Required methods
    fn spawn_entity(&mut self) -> EntityId;
    fn despawn_entity(&mut self, entity_id: EntityId, env: &Env);
    fn get_component(
        &self,
        entity_id: EntityId,
        component_type: &Symbol,
    ) -> Option<Bytes>;
    fn add_component(
        &mut self,
        entity_id: EntityId,
        component_type: Symbol,
        data: Bytes,
        env: &Env,
    );
    fn remove_component(
        &mut self,
        entity_id: EntityId,
        component_type: &Symbol,
        env: &Env,
    ) -> bool;

    // Provided methods
    fn get_typed<T: ComponentTrait>(
        &self,
        env: &Env,
        entity_id: EntityId,
    ) -> Option<T> { ... }
    fn set_typed<T: ComponentTrait>(
        &mut self,
        env: &Env,
        entity_id: EntityId,
        component: &T,
    ) { ... }
    fn has_typed<T: ComponentTrait>(&self, entity_id: EntityId) -> bool { ... }
    fn remove_typed<T: ComponentTrait>(
        &mut self,
        env: &Env,
        entity_id: EntityId,
    ) -> bool { ... }
}
Expand description

Shared mutable runtime contract for Cougr’s Soroban-first world backends.

This trait represents the stable gameplay mutation surface common to SimpleWorld and ArchetypeWorld. It is intentionally narrower than the full implementation of either backend.

Required Methods§

Source

fn spawn_entity(&mut self) -> EntityId

Source

fn despawn_entity(&mut self, entity_id: EntityId, env: &Env)

Source

fn get_component( &self, entity_id: EntityId, component_type: &Symbol, ) -> Option<Bytes>

Source

fn add_component( &mut self, entity_id: EntityId, component_type: Symbol, data: Bytes, env: &Env, )

Source

fn remove_component( &mut self, entity_id: EntityId, component_type: &Symbol, env: &Env, ) -> bool

Provided Methods§

Source

fn get_typed<T: ComponentTrait>( &self, env: &Env, entity_id: EntityId, ) -> Option<T>

Source

fn set_typed<T: ComponentTrait>( &mut self, env: &Env, entity_id: EntityId, component: &T, )

Source

fn has_typed<T: ComponentTrait>(&self, entity_id: EntityId) -> bool

Source

fn remove_typed<T: ComponentTrait>( &mut self, env: &Env, entity_id: EntityId, ) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§