Basic documentation for Entities, Components and Systems (#1578)
These are largely targeted at beginners, as `Entity`, `Component` and `System` are the most obvious terms to search when first getting introduced to Bevy.
This commit is contained in:
		
							parent
							
								
									32af4b7dc3
								
							
						
					
					
						commit
						03601db51c
					
				| @ -11,6 +11,19 @@ use std::{ | ||||
| }; | ||||
| use thiserror::Error; | ||||
| 
 | ||||
| /// A component is data associated with an `Entity`. Each entity can have multiple different types
 | ||||
| /// of components, but only one of them per type.
 | ||||
| ///
 | ||||
| /// Any type that is `Send + Sync + 'static` automatically implements `Component`.
 | ||||
| ///
 | ||||
| /// Components are added with new entities using [Commands::spawn](crate::system::Commands::spawn),
 | ||||
| /// or to existing entities with [Commands::insert](crate::system::Commands::insert),
 | ||||
| /// or their [World](crate::world::World) equivalents.
 | ||||
| ///
 | ||||
| /// Components can be accessed in systems by using a [Query](crate::system::Query)
 | ||||
| /// as one of the arguments.
 | ||||
| ///
 | ||||
| /// Components can be grouped together into a [Bundle](crate::bundle::Bundle).
 | ||||
| pub trait Component: Send + Sync + 'static {} | ||||
| impl<T: Send + Sync + 'static> Component for T {} | ||||
| 
 | ||||
|  | ||||
| @ -13,7 +13,11 @@ use std::{ | ||||
| 
 | ||||
| /// Lightweight unique ID of an entity
 | ||||
| ///
 | ||||
| /// Obtained from `World::spawn`. Can be stored to refer to an entity in the future.
 | ||||
| /// Obtained from [World::spawn](crate::world::World::spawn), typically via [Commands::spawn](crate::system::Commands::spawn). Can be stored to refer to an entity in the future.
 | ||||
| ///
 | ||||
| /// `Entity` can be a part of a query, e.g. `Query<(Entity, &MyComponent)>`.
 | ||||
| /// Components of a specific entity can be accessed using
 | ||||
| /// [Query::get](crate::system::Query::get) and related methods.
 | ||||
| #[derive(Clone, Copy, Hash, Eq, Ord, PartialEq, PartialOrd)] | ||||
| pub struct Entity { | ||||
|     pub(crate) generation: u32, | ||||
|  | ||||
| @ -17,6 +17,15 @@ impl SystemId { | ||||
| } | ||||
| 
 | ||||
| /// An ECS system that can be added to a [Schedule](crate::schedule::Schedule)
 | ||||
| ///
 | ||||
| /// Systems are functions with all arguments implementing [SystemParam].
 | ||||
| ///
 | ||||
| /// Systems are added to an application using `AppBuilder::add_system(my_system.system())`
 | ||||
| /// or similar methods, and will generally run once per pass of the main loop.
 | ||||
| ///
 | ||||
| /// Systems are executed in parallel, in opportunistic order; data access is managed automatically.
 | ||||
| /// It's possible to specify explicit execution order between specific systems,
 | ||||
| /// see [SystemDescriptor](crate::schedule::SystemDescriptor).
 | ||||
| pub trait System: Send + Sync + 'static { | ||||
|     type In; | ||||
|     type Out; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Alice Cecile
						Alice Cecile