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 theChildren
component, spawn aSpawnableList
of entities with given bundles that relate to theChildren
entity via theChildOf
component, and reserve space in theChildren
for each spawned entity. - related
- Returns a
SpawnRelatedBundle
that will insert the givenRelationshipTarget
, spawn aSpawnableList
of entities with given bundles that relate to theRelationshipTarget
entity via theRelationshipTarget::Relationship
component, and reserve space in theRelationshipTarget
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
. SeeComponentHooks::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
, bypassingDefaultQueryFilters
. - AnyOf
- The
AnyOf
query parameter fetches entities with any of the component types included in T. - AppType
Registry - A
Resource
storingTypeRegistry
for type registrations relevant to a whole app. - Apply
Deferred - A special
System
that instructs the executor to callSystem::apply_deferred
on the systems that have run but not applied theirDeferred
system parameters (likeCommands
) or other system buffers. - Bevy
Error - The built in “universal” Bevy error type. This has a blanket
From
impl for any type that implements Rust’sError
, 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 theWorld
. - Deferred
- A
SystemParam
that stores a buffer which gets applied to theWorld
duringApplyDeferred
. This is used internally byCommands
to deferWorld
mutations. - Despawn
EntityEvent
emitted for each component on an entity when it is despawned. SeeComponentHooks::on_despawn
for more information.- Entity
- Lightweight identifier of an entity.
- Entity
Commands - A list of commands that will be run to modify an
Entity
. - Entity
Mut - Provides mutable access to a single entity and all of its components.
- Entity
Ref - A read-only reference to a particular
Entity
and all of its components. - Entity
World Mut - A mutable reference to a particular
Entity
, and the entire world. - Filtered
Resources - Provides read-only access to a set of
Resource
s defined by the containedAccess
. - Filtered
Resources Mut - Provides mutable access to a set of
Resource
s defined by the containedAccess
. - 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 aSystem
receives an input value of typeT
from its caller. - InMut
- A
SystemInput
type which denotes that aSystem
receives a mutable reference to a value of typeT
from its caller. - InRef
- A
SystemInput
type which denotes that aSystem
receives a read-only reference to a value of typeT
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. SeeComponentHooks::on_insert
for more information. - Local
- A system local
SystemParam
. - Message
Mutator - 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. - Message
Reader - Reads
Message
s of typeT
in order and tracks which messages have already been read. - Message
Writer - Writes
Message
s of typeT
. - Messages
- A message collection that represents the messages that occurred within the last two
Messages::update
calls. Messages can be written to using aMessageWriter
and are typically cheaply read using aMessageReader
. - 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.
- Name
OrEntity - Convenient query for giving a human friendly name to an entity.
- NonSend
- Shared borrow of a non-
Send
resource. - NonSend
Mut - Unique borrow of a non-
Send
resource. - Observer
- An
Observer
system. Add thisComponent
to anEntity
to turn it into an “observer”. - On
- A system parameter used by an observer to process events. See
Observer
andEvent
for examples. - Or
- A filter that tests if any of the given filters apply.
- Parallel
Commands - An alternative to
Commands
that can be used in parallel contexts, such as those inQuery::par_iter
. - Param
Set - A collection of potentially conflicting
SystemParam
s 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 aWorld
. - Query
Builder - Builder struct to create
QueryState
instances at runtime. - Query
State - Provides scoped access to a
World
state according to a givenQueryData
andQueryFilter
. - 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. - Reflect
Component - A struct used to operate on reflected
Component
trait of a type. - Reflect
From World - A struct used to operate on the reflected
FromWorld
trait of a type. - Reflect
Resource - 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. - Removed
Components - A
SystemParam
that yields entities that had theirT
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
Schedule
s mapped toScheduleLabel
s excluding the current runningSchedule
. - 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 thatBundle
. This is intended to be used for hierarchical spawning via traits likeSpawnableList
andSpawnRelated
. - Spawn
Iter - A
SpawnableList
that spawns entities using an iterator of a givenBundle
: - Spawn
With - A
SpawnableList
that spawns entities using aFnOnce
with aRelatedSpawner
as an argument: - With
- Filter that selects entities with a component
T
. - With
OneRelated - A wrapper over an
Entity
indicating that an entity should be added. This is intended to be used for hierarchical spawning via traits likeSpawnableList
andSpawnRelated
. - With
Related - A
SpawnableList
that links already spawned entities to the root entity via relations of typeI
. - 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 ofComponent
s from an entity. - Command
- A
World
mutation. - Component
- A data type that can be used to store data for an entity.
- Contains
Entity - A trait for types that contain an
Entity
. - Detect
Changes - Types that can read change detection information.
This change detection is controlled by
DetectChangesMut
types such asResMut
. - Detect
Changes Mut - Types that implement reliable change detection.
- Entity
Command - A command which gets executed for a given
Entity
. - Entity
Event - An
EntityEvent
is anEvent
that is triggered for a specificEntityEvent::event_target
entity: - Entity
Mapper - An implementor of this trait knows how to map an
Entity
into anotherEntity
. - Event
- An
Event
is something that “happens” at a given moment. - From
World - Creates an instance of the type this trait is implemented for
using data from the supplied
World
. - Into
Schedule Configs - Types that can convert into a
ScheduleConfigs
. - Into
System - Conversion trait to turn something into a
System
. - Into
System Set - Types that can be converted into a
SystemSet
. - Message
- A buffered message for pull-based event handling.
- Read
Only System System
types that do not modify theWorld
when run. This is implemented for any systems whose parameters all implementReadOnlySystemParam
.- Relationship
Target - A
Component
containing the collection of entities that relate to thisEntity
via the associatedRelationship
type. See theRelationship
documentation for more information. - Resource
- A type that can be inserted into a
World
as a singleton. - Spawn
Related RelationshipTarget
methods that create aBundle
with aDynamicBundle::Effect
that:- System
- An ECS system that can be added to a
Schedule
- System
Condition - A system that determines if one or more scheduled systems should run.
- System
Input - Trait for types that can be used as input to
System
s. - System
Param Builder - A builder that can create a
SystemParam
. - System
Param Function - A trait implemented for all functions that can be used as
System
s. - System
Set - System sets are tag-like labels that can be used to group systems together.
Functions§
- any_
component_ removed - A
SystemCondition
-satisfying system that returnstrue
if there are any entity with a component of the given type removed. - any_
match_ filter - A
SystemCondition
-satisfying system that returnstrue
if there are any entities that match the givenQueryFilter
. - any_
with_ component - A
SystemCondition
-satisfying system that returnstrue
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_
event Deprecated - A
SystemCondition
-satisfying system that returnstrue
if there are any new events of the given type since it was last called. - on_
message - A
SystemCondition
-satisfying system that returnstrue
if there are any new messages of the given type since it was last called. - resource_
added - A
SystemCondition
-satisfying system that returnstrue
if the resource of the given type has been added since the condition was last checked. - resource_
changed - A
SystemCondition
-satisfying system that returnstrue
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 returnstrue
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 returnstrue
if the resource is equal tovalue
. - resource_
exists - A
SystemCondition
-satisfying system that returnstrue
if the resource exists. - resource_
exists_ and_ changed - A
SystemCondition
-satisfying system that returnstrue
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 returnstrue
if the resource exists and is equal tovalue
. - resource_
removed - A
SystemCondition
-satisfying system that returnstrue
if the resource of the given type has been removed since the condition was last checked. - run_
once - A
SystemCondition
-satisfying system that returnstrue
on the first time the condition is run and false every time after.
Type Aliases§
- Child
Spawner - A type alias over
RelatedSpawner
used to spawn child entities containing aChildOf
relationship. - Child
Spawner Commands - A type alias over
RelatedSpawnerCommands
used to spawn child entities containing aChildOf
relationship. - Event
Reader Deprecated - This is deprecated. See
MessageReader
- Event
Writer Deprecated - This is deprecated. See
MessageWriter
- Events
Deprecated - This is deprecated. See
Messages
- OnAdd
Deprecated - Deprecated in favor of
Add
. - OnDespawn
Deprecated - Deprecated in favor of
Despawn
. - OnInsert
Deprecated - Deprecated in favor of
Insert
. - OnRemove
Deprecated - Deprecated in favor of
Remove
. - OnReplace
Deprecated - Deprecated in favor of
Replace
. - Result
- A result type for use in fallible systems, commands and observers.
- System
In - Shorthand way to get the
System::In
for aSystem
as aSystemInput::Inner
. - Trigger
Deprecated - 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. - Entity
Event - Cheat sheet for derive syntax,
see full explanation on
EntityEvent
trait docs. - Event
- Implement the
Event
trait. - From
World - Implement the
FromWorld
trait. - Message
- Implement the
Message
trait. - Resource
- Implement the
Resource
trait. - System
Set - Derive macro generating an impl of the trait
SystemSet
.