pub trait EntityCommandsSceneExt {
// Required methods
fn queue_spawn_related_scenes<T>(
&mut self,
scenes: impl SceneList,
) -> &mut Self
where T: RelationshipTarget;
fn apply_scene<S>(&mut self, scene: S) -> &mut Self
where S: Scene;
fn queue_apply_scene<S>(&mut self, scene: S) -> &mut Self
where S: Scene;
}Expand description
Adds scene functionality to EntityWorldMut.
Required Methods§
Spawns a SceneList, where each entity is related to the current entity using RelationshipTarget::Relationship.
This will evaluate the scene_list’s dependencies (via SceneList::register_dependencies) and queue it to be resolved
and spawned after all of the dependencies have been loaded. If a SpawnSceneError occurs, it will be logged as an error.
If the dependencies are already loaded (or there are no dependencies), then the scene list will be spawned this frame.
#[derive(Component, FromTemplate)]
enum Team {
#[default]
Red,
Blue,
}
commands.spawn_empty().queue_spawn_related_scenes::<Children>(bsn_list! {
(
#Player1
Team::Red
),
(
#Player2
Team::Blue
)
});Sourcefn apply_scene<S>(&mut self, scene: S) -> &mut Selfwhere
S: Scene,
fn apply_scene<S>(&mut self, scene: S) -> &mut Selfwhere
S: Scene,
Applies the given Scene to the current entity as soon as Commands are applied. This will resolve the Scene (using Scene::resolve). If that fails (for example, if there are dependencies that have not been
loaded yet), it will log a SpawnSceneError as an error. If resolving the Scene is successful, the scene will be spawned.
If resolving and spawning is successful, the entity will contain the full contents of the spawned scene.
This will write directly on top of any existing components on the entity. Scene is generally used as a spawning mechanism, so for most things, prefer using Commands::spawn_scene.
See Scene for the features of the scene system (and how to use it).
If your scene has a dependency that might not be loaded yet (for example, it includes a .bsn asset file), consider using Commands::spawn_scene.
Note that the .bsn file format is not yet released.
Sourcefn queue_apply_scene<S>(&mut self, scene: S) -> &mut Selfwhere
S: Scene,
fn queue_apply_scene<S>(&mut self, scene: S) -> &mut Selfwhere
S: Scene,
Queues the scene to be applied. This will evaluate the scene’s dependencies (via Scene::register_dependencies) and queue it to be resolved and spawned
after all of the dependencies have been loaded. If a SpawnSceneError occurs, it will be logged as an error.
If the dependencies are already loaded (or there are no dependencies), then the scene will be spawned this frame.
This will write directly on top of any existing components on the entity. Scene is generally used as a spawning mechanism, so for most things, prefer using Commands::queue_spawn_scene.
See Scene for the features of the scene system (and how to use it).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".