Module prelude

Source
Expand description

The ECS prelude.

This includes the most common types in this crate, re-exported for your convenience.

Macros§

children
Returns a SpawnRelatedBundle that will insert the Children component, spawn a SpawnableList of entities with given bundles that relate to the Children entity via the ChildOf component, and reserve space in the Children for each spawned entity.
related
Returns a SpawnRelatedBundle that will insert the given RelationshipTarget, spawn a SpawnableList of entities with given bundles that relate to the RelationshipTarget entity via the RelationshipTarget::Relationship component, and reserve space in the RelationshipTarget for each spawned entity.

Structs§

Add
Trigger emitted when a component is inserted onto an entity that does not already have that component. Runs before Insert. See ComponentHooks::on_add for more information.
Added
A filter on a component that only retains results the first time after they have been added.
Allow
Allows a query to contain entities with the component T, bypassing DefaultQueryFilters.
AnyOf
The AnyOf query parameter fetches entities with any of the component types included in T.
AppTypeRegistry
A Resource storing TypeRegistry for type registrations relevant to a whole app.
ApplyDeferred
A special System that instructs the executor to call System::apply_deferred on the systems that have run but not applied their Deferred system parameters (like Commands) or other system buffers.
BevyError
The built in “universal” Bevy error type. This has a blanket From impl for any type that implements Rust’s Error, meaning it can be used as a “catch all” error.
Changed
A filter on a component that only retains results the first time after they have been added or mutably dereferenced.
ChildOf
Stores the parent entity of this child entity with this component.
Children
Tracks which entities are children of this parent entity.
Commands
A Command queue to perform structural changes to the World.
Deferred
A SystemParam that stores a buffer which gets applied to the World during ApplyDeferred. This is used internally by Commands to defer World mutations.
Despawn
EntityEvent emitted for each component on an entity when it is despawned. See ComponentHooks::on_despawn for more information.
Entity
Lightweight identifier of an entity.
EntityCommands
A list of commands that will be run to modify an Entity.
EntityMut
Provides mutable access to a single entity and all of its components.
EntityRef
A read-only reference to a particular Entity and all of its components.
EntityWorldMut
A mutable reference to a particular Entity, and the entire world.
FilteredResources
Provides read-only access to a set of Resources defined by the contained Access.
FilteredResourcesMut
Provides mutable access to a set of Resources defined by the contained Access.
Has
Returns a bool that describes if an entity has the component T.
If
A SystemParam that wraps another parameter and causes its system to skip instead of failing when the parameter is invalid.
In
A SystemInput type which denotes that a System receives an input value of type T from its caller.
InMut
A SystemInput type which denotes that a System receives a mutable reference to a value of type T from its caller.
InRef
A SystemInput type which denotes that a System receives a read-only reference to a value of type T from its caller.
Insert
Trigger emitted when a component is inserted, regardless of whether or not the entity already had that component. Runs after Add, if it ran. See ComponentHooks::on_insert for more information.
Local
A system local SystemParam.
MessageMutator
Mutably reads messages of type T keeping track of which messages have already been read by each system allowing multiple systems to read the same messages. Ideal for chains of systems that all want to modify the same messages.
MessageReader
Reads Messages of type T in order and tracks which messages have already been read.
MessageWriter
Writes Messages of type T.
Messages
A message collection that represents the messages that occurred within the last two Messages::update calls. Messages can be written to using a MessageWriter and are typically cheaply read using a MessageReader.
Mut
Unique mutable borrow of an entity’s component or of a resource.
Name
Component used to identify an entity. Stores a hash for faster comparisons.
NameOrEntity
Convenient query for giving a human friendly name to an entity.
NonSend
Shared borrow of a non-Send resource.
NonSendMut
Unique borrow of a non-Send resource.
Observer
An Observer system. Add this Component to an Entity to turn it into an “observer”.
On
A system parameter used by an observer to process events. See Observer and Event for examples.
Or
A filter that tests if any of the given filters apply.
ParallelCommands
An alternative to Commands that can be used in parallel contexts, such as those in Query::par_iter.
ParamSet
A collection of potentially conflicting SystemParams allowed by disjoint access.
Populated
System parameter that works very much like Query except it always contains at least one matching entity.
Query
A system parameter that provides selective access to the Component data stored in a World.
QueryBuilder
Builder struct to create QueryState instances at runtime.
QueryState
Provides scoped access to a World state according to a given QueryData and QueryFilter.
Ref
Shared borrow of an entity’s component with access to change detection. Similar to Mut but is immutable and so doesn’t require unique access.
ReflectComponent
A struct used to operate on reflected Component trait of a type.
ReflectFromWorld
A struct used to operate on the reflected FromWorld trait of a type.
ReflectResource
A struct used to operate on reflected Resource of a type.
Remove
Trigger emitted when a component is removed from an entity, and runs before the component is removed, so you can still access the component data. See ComponentHooks::on_remove for more information.
RemovedComponents
A SystemParam that yields entities that had their T Component removed or have been despawned with it.
Replace
Trigger emitted when a component is removed from an entity, regardless of whether or not it is later replaced.
Res
Shared borrow of a Resource.
ResMut
Unique mutable borrow of a Resource.
Schedule
A collection of systems, and the metadata and executor needed to run them in a certain order under certain conditions.
Schedules
Resource that stores Schedules mapped to ScheduleLabels excluding the current running Schedule.
Single
System parameter that provides access to single entity’s components, much like Query::single/Query::single_mut.
Spawn
A wrapper over a Bundle indicating that an entity should be spawned with that Bundle. This is intended to be used for hierarchical spawning via traits like SpawnableList and SpawnRelated.
SpawnIter
A SpawnableList that spawns entities using an iterator of a given Bundle:
SpawnWith
A SpawnableList that spawns entities using a FnOnce with a RelatedSpawner as an argument:
With
Filter that selects entities with a component T.
WithOneRelated
A wrapper over an Entity indicating that an entity should be added. This is intended to be used for hierarchical spawning via traits like SpawnableList and SpawnRelated.
WithRelated
A SpawnableList that links already spawned entities to the root entity via relations of type I.
Without
Filter that selects entities without a component T.
World
Stores and exposes operations on entities, components, resources, and their associated metadata.

Traits§

Bundle
The Bundle trait enables insertion and removal of Components from an entity.
Command
A World mutation.
Component
A data type that can be used to store data for an entity.
ContainsEntity
A trait for types that contain an Entity.
DetectChanges
Types that can read change detection information. This change detection is controlled by DetectChangesMut types such as ResMut.
DetectChangesMut
Types that implement reliable change detection.
EntityCommand
A command which gets executed for a given Entity.
EntityEvent
An EntityEvent is an Event that is triggered for a specific EntityEvent::event_target entity:
EntityMapper
An implementor of this trait knows how to map an Entity into another Entity.
Event
An Event is something that “happens” at a given moment.
FromWorld
Creates an instance of the type this trait is implemented for using data from the supplied World.
IntoScheduleConfigs
Types that can convert into a ScheduleConfigs.
IntoSystem
Conversion trait to turn something into a System.
IntoSystemSet
Types that can be converted into a SystemSet.
Message
A buffered message for pull-based event handling.
ReadOnlySystem
System types that do not modify the World when run. This is implemented for any systems whose parameters all implement ReadOnlySystemParam.
RelationshipTarget
A Component containing the collection of entities that relate to this Entity via the associated Relationship type. See the Relationship documentation for more information.
Resource
A type that can be inserted into a World as a singleton.
SpawnRelated
RelationshipTarget methods that create a Bundle with a DynamicBundle::Effect that:
System
An ECS system that can be added to a Schedule
SystemCondition
A system that determines if one or more scheduled systems should run.
SystemInput
Trait for types that can be used as input to Systems.
SystemParamBuilder
A builder that can create a SystemParam.
SystemParamFunction
A trait implemented for all functions that can be used as Systems.
SystemSet
System sets are tag-like labels that can be used to group systems together.

Functions§

any_component_removed
A SystemCondition-satisfying system that returns true if there are any entity with a component of the given type removed.
any_match_filter
A SystemCondition-satisfying system that returns true if there are any entities that match the given QueryFilter.
any_with_component
A SystemCondition-satisfying system that returns true if there are any entities with the given component type.
condition_changed
Generates a SystemCondition that returns true when the passed one changes.
condition_changed_to
Generates a SystemCondition that returns true when the result of the passed one went from false to true since the last time this was called.
not
Generates a SystemCondition that inverses the result of passed one.
on_eventDeprecated
A SystemCondition-satisfying system that returns true if there are any new events of the given type since it was last called.
on_message
A SystemCondition-satisfying system that returns true if there are any new messages of the given type since it was last called.
resource_added
A SystemCondition-satisfying system that returns true if the resource of the given type has been added since the condition was last checked.
resource_changed
A SystemCondition-satisfying system that returns true if the resource of the given type has been added or mutably dereferenced since the condition was last checked.
resource_changed_or_removed
A SystemCondition-satisfying system that returns true if the resource of the given type has been added, removed or mutably dereferenced since the condition was last checked.
resource_equals
Generates a SystemCondition-satisfying closure that returns true if the resource is equal to value.
resource_exists
A SystemCondition-satisfying system that returns true if the resource exists.
resource_exists_and_changed
A SystemCondition-satisfying system that returns true if the resource of the given type has been added or mutably dereferenced since the condition was last checked.
resource_exists_and_equals
Generates a SystemCondition-satisfying closure that returns true if the resource exists and is equal to value.
resource_removed
A SystemCondition-satisfying system that returns true if the resource of the given type has been removed since the condition was last checked.
run_once
A SystemCondition-satisfying system that returns true on the first time the condition is run and false every time after.

Type Aliases§

ChildSpawner
A type alias over RelatedSpawner used to spawn child entities containing a ChildOf relationship.
ChildSpawnerCommands
A type alias over RelatedSpawnerCommands used to spawn child entities containing a ChildOf relationship.
EventReaderDeprecated
This is deprecated. See MessageReader
EventWriterDeprecated
This is deprecated. See MessageWriter
EventsDeprecated
This is deprecated. See Messages
OnAddDeprecated
Deprecated in favor of Add.
OnDespawnDeprecated
Deprecated in favor of Despawn.
OnInsertDeprecated
Deprecated in favor of Insert.
OnRemoveDeprecated
Deprecated in favor of Remove.
OnReplaceDeprecated
Deprecated in favor of Replace.
Result
A result type for use in fallible systems, commands and observers.
SystemIn
Shorthand way to get the System::In for a System as a SystemInput::Inner.
TriggerDeprecated
Deprecated in favor of On.

Derive Macros§

Bundle
Implement the Bundle trait.
Component
Cheat sheet for derive syntax, see full explanation and examples on the Component trait doc.
EntityEvent
Cheat sheet for derive syntax, see full explanation on EntityEvent trait docs.
Event
Implement the Event trait.
FromWorld
Implement the FromWorld trait.
Message
Implement the Message trait.
Resource
Implement the Resource trait.
SystemSet
Derive macro generating an impl of the trait SystemSet.