Trait bevy_proto_backend::proto::Prototypical
source · pub trait Prototypical: Asset + Sized {
type Id: Clone + Debug + Eq + Hash + Send + Sync + ToString;
type Child: PrototypicalChild<Self>;
// Required methods
fn id(&self) -> &Self::Id;
fn path(&self) -> &ProtoPath;
fn schematics(&self) -> &Schematics;
fn schematics_mut(&mut self) -> &mut Schematics;
fn templates(&self) -> Option<&Templates>;
fn templates_mut(&mut self) -> Option<&mut Templates>;
fn dependencies(&self) -> &Dependencies;
fn dependencies_mut(&mut self) -> &mut Dependencies;
fn children(&self) -> Option<&Children<Self>>;
fn children_mut(&mut self) -> Option<&mut Children<Self>>;
// Provided method
fn requires_entity(&self) -> bool { ... }
}
Expand description
The trait used to define a prototype.
Prototypes are containers for Schematics
that can be spawned in at runtime.
They may also inherit from other prototypes (where the inherited prototypes are known
as Templates
) and contain a hierarchy of Children
.
Required Associated Types§
sourcetype Id: Clone + Debug + Eq + Hash + Send + Sync + ToString
type Id: Clone + Debug + Eq + Hash + Send + Sync + ToString
The type used to identify this prototype.
This can be used to control how a prototype is accessed. For example, if we wanted to split prototypes into “packages”, then we could require a package identifier along with the prototype name in order to access the prototype:
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
struct MyProtoId {
package: String,
name: String,
}
impl Display for MyProtoId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}::{}", self.package, self.name)
}
}
sourcetype Child: PrototypicalChild<Self>
type Child: PrototypicalChild<Self>
The type of the child this prototype uses.
This is used to configure how a child is processed.
Required Methods§
sourcefn schematics(&self) -> &Schematics
fn schematics(&self) -> &Schematics
An immutable reference to the collection of Schematics
contained in this prototype.
sourcefn schematics_mut(&mut self) -> &mut Schematics
fn schematics_mut(&mut self) -> &mut Schematics
A mutable reference to the collection of Schematics
contained in this prototype.
sourcefn templates(&self) -> Option<&Templates>
fn templates(&self) -> Option<&Templates>
An immutable reference to the collection of Templates
inherited by this prototype, if any.
sourcefn templates_mut(&mut self) -> Option<&mut Templates>
fn templates_mut(&mut self) -> Option<&mut Templates>
A mutable reference to the collection of Templates
inherited by this prototype, if any.
sourcefn dependencies(&self) -> &Dependencies
fn dependencies(&self) -> &Dependencies
An immutable reference to the collection of Dependencies
used by this prototype.
sourcefn dependencies_mut(&mut self) -> &mut Dependencies
fn dependencies_mut(&mut self) -> &mut Dependencies
A mutable reference to the collection of Dependencies
used by this prototype.
sourcefn children(&self) -> Option<&Children<Self>>
fn children(&self) -> Option<&Children<Self>>
An immutable reference to the collection of Children
contained in this prototype, if any.
sourcefn children_mut(&mut self) -> Option<&mut Children<Self>>
fn children_mut(&mut self) -> Option<&mut Children<Self>>
A mutable reference to the collection of Children
contained in this prototype, if any.
Provided Methods§
sourcefn requires_entity(&self) -> bool
fn requires_entity(&self) -> bool
Whether or not this prototype requires an entity to be spawned.
Defaults to true
.