pub struct SceneManager { /* private fields */ }Expand description
Manages multiple isolated ECS worlds (scenes).
On construction a “default” scene is created and set as the sole active scene. The default scene cannot be destroyed.
§Entity Isolation
Entities spawned in one scene are completely invisible to other scenes.
Each scene owns its own World with independent entity allocators,
component storage, and archetypes.
Implementations§
Source§impl SceneManager
impl SceneManager
Sourcepub fn new() -> SceneManager
pub fn new() -> SceneManager
Creates a new SceneManager with a “default” scene already created
and marked active.
Sourcepub fn create_scene(&mut self, name: &str) -> Result<u32, GoudError>
pub fn create_scene(&mut self, name: &str) -> Result<u32, GoudError>
Creates a new scene with the given name.
Returns the SceneId on success. Returns an error if a scene with
the same name already exists.
Sourcepub fn destroy_scene(&mut self, id: u32) -> Result<(), GoudError>
pub fn destroy_scene(&mut self, id: u32) -> Result<(), GoudError>
Destroys a scene and frees its resources.
Returns an error if the scene does not exist or if attempting to destroy the default scene.
Sourcepub fn get_scene(&self, id: u32) -> Option<&World>
pub fn get_scene(&self, id: u32) -> Option<&World>
Returns a reference to the World for the given scene.
Sourcepub fn get_scene_mut(&mut self, id: u32) -> Option<&mut World>
pub fn get_scene_mut(&mut self, id: u32) -> Option<&mut World>
Returns a mutable reference to the World for the given scene.
Sourcepub fn get_scene_by_name(&self, name: &str) -> Option<u32>
pub fn get_scene_by_name(&self, name: &str) -> Option<u32>
Looks up a scene by name, returning its ID if found.
Sourcepub fn get_scene_name(&self, id: u32) -> Option<&str>
pub fn get_scene_name(&self, id: u32) -> Option<&str>
Returns the name of the scene with the given ID, if it exists.
Sourcepub fn set_active(&mut self, id: u32, active: bool) -> Result<(), GoudError>
pub fn set_active(&mut self, id: u32, active: bool) -> Result<(), GoudError>
Sets whether a scene is active.
Active scenes are the ones that participate in the game loop (update, render, etc.). Returns an error if the scene does not exist.
Sourcepub fn active_scenes(&self) -> &[u32]
pub fn active_scenes(&self) -> &[u32]
Returns a slice of all currently active scene IDs.
Sourcepub fn scene_count(&self) -> usize
pub fn scene_count(&self) -> usize
Returns the number of occupied scenes (including the default).
Sourcepub fn default_scene(&self) -> u32
pub fn default_scene(&self) -> u32
Returns the ID of the default scene.
Trait Implementations§
Source§impl Debug for SceneManager
impl Debug for SceneManager
Source§impl Default for SceneManager
impl Default for SceneManager
Source§fn default() -> SceneManager
fn default() -> SceneManager
Auto Trait Implementations§
impl Freeze for SceneManager
impl !RefUnwindSafe for SceneManager
impl !Send for SceneManager
impl !Sync for SceneManager
impl Unpin for SceneManager
impl UnsafeUnpin for SceneManager
impl !UnwindSafe for SceneManager
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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> 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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().