pub struct ScriptComponentRegistry { /* private fields */ }Expand description
A registry of dynamically registered script components, events, exports and system sets
Implementations§
Source§impl ScriptComponentRegistry
impl ScriptComponentRegistry
Sourcepub fn register(&mut self, info: DynamicComponentInfo)
pub fn register(&mut self, info: DynamicComponentInfo)
Registers a dynamic script component, possibly overwriting an existing one
Sourcepub fn get(&self, path: &str) -> Option<&DynamicComponentInfo>
pub fn get(&self, path: &str) -> Option<&DynamicComponentInfo>
Gets a dynamic script component by its full path, i.e. script.game.Enemy
Sourcepub fn find(&self, path: &str) -> Option<&DynamicComponentInfo>
pub fn find(&self, path: &str) -> Option<&DynamicComponentInfo>
Gets a dynamic script component by its full path (i.e. script.game.Enemy).
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
A counter which changes whenever a component is registered.
Lookups of existing registrations do not change it.
Sourcepub fn iter_components(&self) -> impl Iterator<Item = &DynamicComponentInfo>
pub fn iter_components(&self) -> impl Iterator<Item = &DynamicComponentInfo>
Iterates over all registered script components
Sourcepub fn register_event(&mut self, registration: ScriptEventRegistration)
pub fn register_event(&mut self, registration: ScriptEventRegistration)
Registers a script event, possibly overwriting an existing one
Sourcepub fn get_event(&self, name: &str) -> Option<&ScriptEventRegistration>
pub fn get_event(&self, name: &str) -> Option<&ScriptEventRegistration>
Gets a script event by its full path
Sourcepub fn register_export(
&mut self,
export: ScriptExport,
) -> Result<(), InteropError>
pub fn register_export( &mut self, export: ScriptExport, ) -> Result<(), InteropError>
Registers a function exported by a script.
Exporting the same path again from the same script replaces the export (i.e. when a script runs again), exporting a path another script exported, or one used by a component or event, is an error.
Sourcepub fn remove_exports_of(&mut self, owner: &ScriptAttachment) -> usize
pub fn remove_exports_of(&mut self, owner: &ScriptAttachment) -> usize
Removes all exports of the given script, returns how many there were
Sourcepub fn get_export(&self, path: &str) -> Option<&ScriptExport>
pub fn get_export(&self, path: &str) -> Option<&ScriptExport>
Gets an export by its full path
Sourcepub fn iter_exports_in<'a>(
&'a self,
namespace: &'a str,
) -> impl Iterator<Item = &'a ScriptExport>
pub fn iter_exports_in<'a>( &'a self, namespace: &'a str, ) -> impl Iterator<Item = &'a ScriptExport>
Iterates over the exports of the given namespace
Sourcepub fn iter_events_in<'a>(
&'a self,
namespace: &'a str,
) -> impl Iterator<Item = (&'a str, &'a ScriptEventRegistration)>
pub fn iter_events_in<'a>( &'a self, namespace: &'a str, ) -> impl Iterator<Item = (&'a str, &'a ScriptEventRegistration)>
Iterates over the script events of the given namespace, with their names within it
Sourcepub fn export_and_event_namespaces(&self) -> impl Iterator<Item = &str>
pub fn export_and_event_namespaces(&self) -> impl Iterator<Item = &str>
The namespaces with at least one export, event or system set, in no particular order, possibly repeated
Sourcepub fn register_system_set(&mut self, path: String, owner: ScriptAttachment)
pub fn register_system_set(&mut self, path: String, owner: ScriptAttachment)
Registers a system set of a script by its full path, i.e. script.game.ai, possibly replacing its owner
Sourcepub fn get_system_set_owner(&self, path: &str) -> Option<&ScriptAttachment>
pub fn get_system_set_owner(&self, path: &str) -> Option<&ScriptAttachment>
The script which registered the system set with the given full path
Sourcepub fn remove_system_sets_of(&mut self, owner: &ScriptAttachment) -> usize
pub fn remove_system_sets_of(&mut self, owner: &ScriptAttachment) -> usize
Removes all system sets registered by the given script, returns how many there were.
The sets stay in the schedules, systems can still be in and ordered against them.
Trait Implementations§
Source§impl Default for ScriptComponentRegistry
impl Default for ScriptComponentRegistry
Source§fn default() -> ScriptComponentRegistry
fn default() -> ScriptComponentRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for ScriptComponentRegistry
impl !Unpin for ScriptComponentRegistry
impl !UnwindSafe for ScriptComponentRegistry
impl Forget for ScriptComponentRegistry
impl Freeze for ScriptComponentRegistry
impl Move for ScriptComponentRegistry
impl Send for ScriptComponentRegistry
impl Sync for ScriptComponentRegistry
impl UnsafeUnpin for ScriptComponentRegistry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
impl<T> Context for T
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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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