Expand description
The ECS prelude.
This includes the most common types in this crate, re-exported for your convenience.
Macros§
- children
- Returns a
SpawnRelatedBundlethat will insert theChildrencomponent, spawn aSpawnableListof entities with given bundles that relate to theChildrenentity via theChildOfcomponent, and reserve space in theChildrenfor each spawned entity. - related
- Returns a
SpawnRelatedBundlethat will insert the givenRelationshipTarget, spawn aSpawnableListof entities with given bundles that relate to theRelationshipTargetentity via theRelationshipTarget::Relationshipcomponent, and reserve space in theRelationshipTargetfor 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_addfor 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
AnyOfquery parameter fetches entities with any of the component types included in T. - AppType
Registry - A
ResourcestoringTypeRegistryfor type registrations relevant to a whole app. - Apply
Deferred - A special
Systemthat instructs the executor to callSystem::apply_deferredon the systems that have run but not applied theirDeferredsystem parameters (likeCommands) or other system buffers. - Bevy
Error - The built in “universal” Bevy error type. This has a blanket
Fromimpl 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
Commandqueue to perform structural changes to theWorld. - Deferred
- A
SystemParamthat stores a buffer which gets applied to theWorldduringApplyDeferred. This is used internally byCommandsto deferWorldmutations. - Despawn
EntityEventemitted for each component on an entity when it is despawned. SeeComponentHooks::on_despawnfor 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
Entityand 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
Resources defined by the containedAccess. - Filtered
Resources Mut - Provides mutable access to a set of
Resources defined by the containedAccess. - Has
- Returns a bool that describes if an entity has the component
T. - If
- A
SystemParamthat wraps another parameter and causes its system to skip instead of failing when the parameter is invalid. - In
- A
SystemInputtype which denotes that aSystemreceives an input value of typeTfrom its caller. - InMut
- A
SystemInputtype which denotes that aSystemreceives a mutable reference to a value of typeTfrom its caller. - InRef
- A
SystemInputtype which denotes that aSystemreceives a read-only reference to a value of typeTfrom 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_insertfor more information. - Local
- A system local
SystemParam. - Message
Mutator - Mutably reads messages of type
Tkeeping 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
Messages of typeTin order and tracks which messages have already been read. - Message
Writer - Writes
Messages of typeT. - Messages
- A message collection that represents the messages that occurred within the last two
Messages::updatecalls. Messages can be written to using aMessageWriterand 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-
Sendresource. - NonSend
Mut - Unique borrow of a non-
Sendresource. - Observer
- An
Observersystem. Add thisComponentto anEntityto turn it into an “observer”. - On
- A system parameter used by an observer to process events. See
ObserverandEventfor examples. - Or
- A filter that tests if any of the given filters apply.
- Parallel
Commands - An alternative to
Commandsthat can be used in parallel contexts, such as those inQuery::par_iter. - Param
Set - A collection of potentially conflicting
SystemParams allowed by disjoint access. - Populated
- System parameter that works very much like
Queryexcept it always contains at least one matching entity. - Query
- A system parameter that provides selective access to the
Componentdata stored in aWorld. - Query
Builder - Builder struct to create
QueryStateinstances at runtime. - Query
State - Provides scoped access to a
Worldstate according to a givenQueryDataandQueryFilter. - Ref
- Shared borrow of an entity’s component with access to change detection.
Similar to
Mutbut is immutable and so doesn’t require unique access. - Reflect
Component - A struct used to operate on reflected
Componenttrait of a type. - Reflect
From World - A struct used to operate on the reflected
FromWorldtrait of a type. - Reflect
Resource - A struct used to operate on reflected
Resourceof 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_removefor more information. - Removed
Components - A
SystemParamthat yields entities that had theirTComponentremoved 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 toScheduleLabels 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
Bundleindicating that an entity should be spawned with thatBundle. This is intended to be used for hierarchical spawning via traits likeSpawnableListandSpawnRelated. - Spawn
Iter - A
SpawnableListthat spawns entities using an iterator of a givenBundle: - Spawn
With - A
SpawnableListthat spawns entities using aFnOncewith aRelatedSpawneras an argument: - With
- Filter that selects entities with a component
T. - With
OneRelated - A wrapper over an
Entityindicating that an entity should be added. This is intended to be used for hierarchical spawning via traits likeSpawnableListandSpawnRelated. - With
Related - A
SpawnableListthat 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
Bundletrait enables insertion and removal ofComponents from an entity. - Command
- A
Worldmutation. - 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
DetectChangesMuttypes 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
EntityEventis anEventthat is triggered for a specificEntityEvent::event_targetentity: - Entity
Mapper - An implementor of this trait knows how to map an
Entityinto anotherEntity. - Event
- An
Eventis 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 Systemtypes that do not modify theWorldwhen run. This is implemented for any systems whose parameters all implementReadOnlySystemParam.- Relationship
Target - A
Componentcontaining the collection of entities that relate to thisEntityvia the associatedRelationshiptype. See theRelationshipdocumentation for more information. - Resource
- A type that can be inserted into a
Worldas a singleton. - Spawn
Related RelationshipTargetmethods that create aBundlewith aDynamicBundle::Effectthat:- 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
Systems. - System
Param Builder - A builder that can create a
SystemParam. - System
Param Function - A trait implemented for all functions that can be used as
Systems. - 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 returnstrueif there are any entity with a component of the given type removed. - any_
match_ filter - A
SystemCondition-satisfying system that returnstrueif there are any entities that match the givenQueryFilter. - any_
with_ component - A
SystemCondition-satisfying system that returnstrueif there are any entities with the given component type. - condition_
changed - Generates a
SystemConditionthat returns true when the passed one changes. - condition_
changed_ to - Generates a
SystemConditionthat returns true when the result of the passed one went from false to true since the last time this was called. - not
- Generates a
SystemConditionthat inverses the result of passed one. - on_
event Deprecated - A
SystemCondition-satisfying system that returnstrueif there are any new events of the given type since it was last called. - on_
message - A
SystemCondition-satisfying system that returnstrueif there are any new messages of the given type since it was last called. - resource_
added - A
SystemCondition-satisfying system that returnstrueif the resource of the given type has been added since the condition was last checked. - resource_
changed - A
SystemCondition-satisfying system that returnstrueif 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 returnstrueif 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 returnstrueif the resource is equal tovalue. - resource_
exists - A
SystemCondition-satisfying system that returnstrueif the resource exists. - resource_
exists_ and_ changed - A
SystemCondition-satisfying system that returnstrueif 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 returnstrueif the resource exists and is equal tovalue. - resource_
removed - A
SystemCondition-satisfying system that returnstrueif the resource of the given type has been removed since the condition was last checked. - run_
once - A
SystemCondition-satisfying system that returnstrueon the first time the condition is run and false every time after.
Type Aliases§
- Child
Spawner - A type alias over
RelatedSpawnerused to spawn child entities containing aChildOfrelationship. - Child
Spawner Commands - A type alias over
RelatedSpawnerCommandsused to spawn child entities containing aChildOfrelationship. - 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::Infor aSystemas aSystemInput::Inner. - Trigger
Deprecated - Deprecated in favor of
On.
Derive Macros§
- Bundle
- Implement the
Bundletrait. - Component
- Cheat sheet for derive syntax,
see full explanation and examples on the
Componenttrait doc. - Entity
Event - Cheat sheet for derive syntax,
see full explanation on
EntityEventtrait docs. - Event
- Implement the
Eventtrait. - From
World - Implement the
FromWorldtrait. - Message
- Implement the
Messagetrait. - Resource
- Implement the
Resourcetrait. - System
Set - Derive macro generating an impl of the trait
SystemSet.