Trait bevy_proto::backend::schematics::Schematic
source · pub trait Schematic: Reflect + Typed {
type Input: FromReflect + GetTypeRegistration;
// Required methods
fn apply(input: &Self::Input, context: &mut SchematicContext<'_, '_>);
fn remove(input: &Self::Input, context: &mut SchematicContext<'_, '_>);
// Provided method
fn preload_dependencies(
input: &mut Self::Input,
dependencies: &mut DependenciesBuilder<'_, '_>
) { ... }
}
Expand description
Trait used to create a prototype schematic for modifying an entity (or the world in general).
This trait can either be manually implemented or derived.
See the module-level documentation for details.
Example
use bevy::prelude::{Component, Reflect};
use bevy_proto_backend::schematics::{Schematic, SchematicContext};
#[derive(Component, Reflect)]
struct PlayerId(usize);
impl Schematic for PlayerId {
type Input = Self;
fn apply(input: &Self::Input, context: &mut SchematicContext) {
entity.insert(Self(input.0));
}
fn remove(input: &Self::Input, context: &mut SchematicContext) {
entity.remove::<Self>();
}
}
Required Associated Types§
Required Methods§
sourcefn apply(input: &Self::Input, context: &mut SchematicContext<'_, '_>)
fn apply(input: &Self::Input, context: &mut SchematicContext<'_, '_>)
Controls how this schematic is applied to the given entity.
sourcefn remove(input: &Self::Input, context: &mut SchematicContext<'_, '_>)
fn remove(input: &Self::Input, context: &mut SchematicContext<'_, '_>)
Controls how this schematic is removed from the given entity.
Provided Methods§
sourcefn preload_dependencies(
input: &mut Self::Input,
dependencies: &mut DependenciesBuilder<'_, '_>
)
fn preload_dependencies( input: &mut Self::Input, dependencies: &mut DependenciesBuilder<'_, '_> )
Allows dependency assets to be loaded when this schematic is loaded.