pub struct GameApp { /* private fields */ }Expand description
Soroban-first application builder and runtime.
GameApp is the recommended entrypoint for new Cougr projects:
it owns the SimpleWorld, the validated SimpleScheduler, and hook
registration in one place.
§Example
let env = Env::default();
let mut app = GameApp::new(&env);
app.add_plugin(PhysicsPlugin);
app.add_plugin(ScoringPlugin);
app.run(&env).unwrap();
let world = app.into_world();
assert_eq!(world.version(), 0);Implementations§
Source§impl GameApp
impl GameApp
pub fn new(env: &Env) -> Self
pub fn with_world(world: SimpleWorld) -> Self
pub fn add_plugin<P: Plugin>(&mut self, plugin: P) -> &mut Self
pub fn add_plugins<G: PluginGroup>(&mut self, group: G) -> &mut Self
Sourcepub fn add_system<F>(&mut self, name: &'static str, system: F) -> &mut Self
pub fn add_system<F>(&mut self, name: &'static str, system: F) -> &mut Self
Add a world/env system to the default Update stage.
Sourcepub fn add_system_with_config<F>(
&mut self,
name: &'static str,
system: F,
config: SystemConfig,
) -> &mut Self
pub fn add_system_with_config<F>( &mut self, name: &'static str, system: F, config: SystemConfig, ) -> &mut Self
Add a world/env system with explicit scheduling rules.
Sourcepub fn add_system_in_stage<F>(
&mut self,
stage: ScheduleStage,
name: &'static str,
system: F,
) -> &mut Self
pub fn add_system_in_stage<F>( &mut self, stage: ScheduleStage, name: &'static str, system: F, ) -> &mut Self
Add a world/env system directly to a specific stage.
Sourcepub fn add_context_system<F>(
&mut self,
name: &'static str,
system: F,
) -> &mut Selfwhere
F: for<'w, 'e, 'c> FnMut(&mut SystemContext<'w, 'e, 'c>) + 'static,
pub fn add_context_system<F>(
&mut self,
name: &'static str,
system: F,
) -> &mut Selfwhere
F: for<'w, 'e, 'c> FnMut(&mut SystemContext<'w, 'e, 'c>) + 'static,
Add a context-aware system to the default Update stage.
Sourcepub fn add_context_system_with_config<F>(
&mut self,
name: &'static str,
system: F,
config: SystemConfig,
) -> &mut Selfwhere
F: for<'w, 'e, 'c> FnMut(&mut SystemContext<'w, 'e, 'c>) + 'static,
pub fn add_context_system_with_config<F>(
&mut self,
name: &'static str,
system: F,
config: SystemConfig,
) -> &mut Selfwhere
F: for<'w, 'e, 'c> FnMut(&mut SystemContext<'w, 'e, 'c>) + 'static,
Add a context-aware system with explicit scheduling rules.
Sourcepub fn add_context_system_in_stage<F>(
&mut self,
stage: ScheduleStage,
name: &'static str,
system: F,
) -> &mut Selfwhere
F: for<'w, 'e, 'c> FnMut(&mut SystemContext<'w, 'e, 'c>) + 'static,
pub fn add_context_system_in_stage<F>(
&mut self,
stage: ScheduleStage,
name: &'static str,
system: F,
) -> &mut Selfwhere
F: for<'w, 'e, 'c> FnMut(&mut SystemContext<'w, 'e, 'c>) + 'static,
Add a context-aware system directly to a specific stage.
Sourcepub fn add_simple_system<S>(
&mut self,
name: &'static str,
system: S,
) -> &mut Selfwhere
S: AppSystem + 'static,
pub fn add_simple_system<S>(
&mut self,
name: &'static str,
system: S,
) -> &mut Selfwhere
S: AppSystem + 'static,
Add any pre-built runtime system to the default Update stage.
Sourcepub fn add_simple_system_with_config<S>(
&mut self,
name: &'static str,
system: S,
config: SystemConfig,
) -> &mut Selfwhere
S: AppSystem + 'static,
pub fn add_simple_system_with_config<S>(
&mut self,
name: &'static str,
system: S,
config: SystemConfig,
) -> &mut Selfwhere
S: AppSystem + 'static,
Add any pre-built runtime system with explicit scheduling rules.
Sourcepub fn add_simple_system_in_stage<S>(
&mut self,
stage: ScheduleStage,
name: &'static str,
system: S,
) -> &mut Selfwhere
S: AppSystem + 'static,
pub fn add_simple_system_in_stage<S>(
&mut self,
stage: ScheduleStage,
name: &'static str,
system: S,
) -> &mut Selfwhere
S: AppSystem + 'static,
Add any pre-built runtime system directly to a specific stage.
Sourcepub fn add_systems<G>(&mut self, systems: G) -> &mut Selfwhere
G: SystemGroup,
pub fn add_systems<G>(&mut self, systems: G) -> &mut Selfwhere
G: SystemGroup,
Add one or more runtime systems using declarative specs.
Sourcepub fn add_systems_in_stage<G>(
&mut self,
stage: ScheduleStage,
systems: G,
) -> &mut Selfwhere
G: SystemGroup,
pub fn add_systems_in_stage<G>(
&mut self,
stage: ScheduleStage,
systems: G,
) -> &mut Selfwhere
G: SystemGroup,
Add one or more runtime systems while forcing them into a stage.
Sourcepub fn add_startup_system<F>(
&mut self,
name: &'static str,
system: F,
) -> &mut Self
pub fn add_startup_system<F>( &mut self, name: &'static str, system: F, ) -> &mut Self
Convenience wrapper to register a startup-only system.
pub fn add_hook_on_add( &mut self, component_type: Symbol, hook: fn(entity_id: EntityId, component_type: &Symbol, data: &Bytes), ) -> &mut Self
pub fn add_hook_on_remove( &mut self, component_type: Symbol, hook: fn(entity_id: EntityId, component_type: &Symbol), ) -> &mut Self
pub fn insert_resource<R: ResourceTrait>( &mut self, env: &Env, resource: &R, ) -> &mut Self
pub fn get_resource<R: ResourceTrait>(&self, env: &Env) -> Option<R>
pub fn remove_resource<R: ResourceTrait>(&mut self) -> Option<Resource>
pub fn world(&self) -> &SimpleWorld
pub fn world_mut(&mut self) -> &mut SimpleWorld
pub fn scheduler(&self) -> &SimpleScheduler
pub fn hooks(&self) -> &HookRegistry
pub fn resources(&self) -> &Vec<Resource>
pub fn run_startup(&mut self, env: &Env) -> Result<(), ScheduleError>
pub fn run_stage( &mut self, stage: ScheduleStage, env: &Env, ) -> Result<(), ScheduleError>
pub fn configure_system( &mut self, name: &str, config: SystemConfig, ) -> Result<&mut Self, ScheduleError>
pub fn into_world(self) -> SimpleWorld
pub fn plugin_count(&self) -> usize
pub fn has_plugin(&self, name: &str) -> bool
pub fn system_count(&self) -> usize
Auto Trait Implementations§
impl Freeze for GameApp
impl !RefUnwindSafe for GameApp
impl !Send for GameApp
impl !Sync for GameApp
impl Unpin for GameApp
impl UnsafeUnpin for GameApp
impl !UnwindSafe for GameApp
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
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
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.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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