Glossary - reeseschultz/godex GitHub Wiki
This page is a collection of keywords used in Godex.
- Entity
- Component
- Tag
- Databag
- World
- WorldECS
- System
- Query
- DynamicQuery
- Storage
- BatchStorage
- Batch Component
- Batch
- Event
An Entity
is just a container of components, differently from an Object
it doesn't have any behaviour or meaning; it can be anything, and its behaviour is driven by the assigned components.
Under the hood, the entity is just an ID.
Example
You could represent the mushrooms power-ups in Mario with the following set of components:
-
PhysicsBody
: Used to specify thisEntity
has a RigidBody. -
Position
: Used to specify that thisEntity
has a position. -
GrowPowerup
: Used to specify the type of the power-up.
Or the character (Mario) could be done with the following set of components:
-
PhysicsBody
: Used to specify thisEntity
has a RigidBody. -
Position
: Used to specify that thisEntity
has a position. -
Character
: Used to specify this entity is the character.
The Component
is a piece of data that can be attached to an Entity
. It can describe a characteristic, a state, an event of an Entity
. Usually, taken alone, the components doesn't do much: but the combination of them allow building complex mechanisms easily and easy to maintain.
Example
Example of some components:
-
TransformComponent
: Describes the 3D world location. -
MeshComponent
: Describes the associated mesh. -
Visible
: Describes the visibility state. -
Hit
: Event that notify thisEntity
got hit.
Called tag or TagComponent it's a Component
but without data. It's used to mark and differentiate the Entities
:
Example
BlueTeam
RedTeam
Character
Enemy
💡 Note that the tag component is not a special component type. The keyword exists just to give more flavour.
The Databag
is a global piece of data, and it's used to store global utility information.
Example
List of some Databag
s:
-
FrameTime
: Databag where the framedelta
and thephysics_delta
is stored. -
OsDatabag
: Where it's stored some info about the OS (timestamp, platform, date). -
EngineDatabag
: Where the engine details are stored.
The World
contains all the Entities
, all the Component
s, all the Databag
s. Think about the World
, like the container of all the data.
The WorldECS
is a Node
that wraps the World
, so you can easily add it to your main scene. It's a lot similar to the Environment
node. It allow to set the Pipelines
, configure the Component
storage, provides some utilities to easily access the Databag
s, Component
s; It allows to easily create new Entities
, etc...
So this Node
is the main entry point for the ECS.
The System
is just a function that perform some operations on the World
data. It manipulates (transform) the Entities
, Component
s, Databag
s data. The System
is defined by the user, and represent a piece of game logic.
Example
List of System
s:
-
TimerSystem
: Advances the timers clock till it expire. -
MoveSystem
: Moves theEntity
locations.
The Query
is used by the System
s to fetch the Component
s from the world; it returns the Entities
that fulfills the request.
void timer_system(Query<TimerSystem> &p_query){}
void move_system(Query<Velocity, TransformComponent> &p_query){}
void heal_system(Query<Health, Heal, Maybe<ExtraHealPowerup>> &p_query){}
void damage_system(Query<Health, Damage, Without<Immunity>> &p_query){}
The DynamicQuery
is exactly like the Query
, with the difference that can be used when you code a script; while the Query
can be used when you use C++.
You can read more about those two: https://github.com/GodotECS/godex/wiki/Query
The Storage
is the memory class used to store the components. There are different type of storage, each with a different set of features.
Exactly like the Storage
but allow to store more entries of the same Compnent
per Entity
. For example, you can have an Entity
with more Damage
component.
The Batch Component is a component that is using a BatchStorage
, so each system can have more entries of those components.
The Batch
is a filter that can be used with the Query
to give access to the Component
s stored in batches.
The Event
is a struct that contains some data, and usually it's emitted by one system and received by many systems. Here the full documentation.