pub struct SingletonManager;Expand description
Implementations§
Source§impl SingletonManager
impl SingletonManager
Sourcepub fn get_by_name(name: &str) -> Option<&'static mut MtObject>
pub fn get_by_name(name: &str) -> Option<&'static mut MtObject>
Looks up a singleton by class name, returning it as an MtObject.
Returns None if no singleton with that name is registered. See
get_by_name_typed to receive a concrete
subclass instead.
Sourcepub fn get_by_id(id: u32) -> Option<&'static mut MtObject>
pub fn get_by_id(id: u32) -> Option<&'static mut MtObject>
Looks up a singleton by its DTI id, returning it as an MtObject.
Returns None if no singleton with that id is registered. See
get_by_id_typed to receive a concrete
subclass instead.
Sourcepub fn get_by_name_typed<T: Object>(name: &str) -> Option<&'static mut T>
pub fn get_by_name_typed<T: Object>(name: &str) -> Option<&'static mut T>
Looks up a singleton by class name and returns it as the subclass T.
The downcast to T is unchecked; the caller must ensure the singleton
is actually a T. Returns None if name contains an interior NUL
byte or if no singleton with that name is registered.
Sourcepub fn get_by_id_typed<T: Object>(id: u32) -> Option<&'static mut T>
pub fn get_by_id_typed<T: Object>(id: u32) -> Option<&'static mut T>
Looks up a singleton by its DTI id and returns it as the subclass T.
The downcast to T is unchecked; the caller must ensure the singleton
is actually a T. Returns None if no singleton with that id is
registered.
Sourcepub fn get_all() -> Box<[&'static mut MtObject]>
pub fn get_all() -> Box<[&'static mut MtObject]>
Returns every registered singleton as a boxed slice of MtObject
references.
The count is queried first, then the instances are fetched into a buffer of that size. If the game reports a different count on the second call (e.g. singletons were registered or removed in between) the mismatch is logged and the actual number returned is used.