40 lines
1.6 KiB
Markdown
40 lines
1.6 KiB
Markdown
*| [JavaECS](../../README.md) | [docs](../overview.md) | [entity](./dir.md) | Entity[]().md*
|
|
# Entity
|
|
|
|
### Contents
|
|
[About](#about)
|
|
|
|
[Usage](#usage)
|
|
|
|
[Notes](#notes)
|
|
|
|
## About
|
|
An 'entity' is a unique ID.
|
|
|
|
For most implementations, it makes sense to use a simple integer value to represent an entity. As each entity must have a unique
|
|
ID/number, we can use a First-In-First-Out (FIFO) data structure, such as a Queue, to efficiently retrieve the next unassigned ID.
|
|
|
|
<br>
|
|
|
|
**This ID represents a specific instance of a game object**
|
|
|
|
e.g. character, vehicle, effect etc.
|
|
|
|
___An entity contains no further data.___
|
|
|
|
In order to be useful, its identifier must be registered to one or more [components](../component/Component.md).
|
|
|
|
|
|
Entities are also initialised with a Java [BitSet](https://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html). Each bit represents the index of a component, to determine which component an entity is registered to.
|
|
|
|
## Usage
|
|
*some specific usage info here*
|
|
``` java
|
|
void todo();
|
|
```
|
|
|
|
## Notes
|
|
* The only requirement for a Entity is that it has a unique ID. A more advanced [entity manager](./EntityManager.md) could implement an ID system with ID regions, or using named IDs.
|
|
Another approach could be to use the first byte as a grouping, in a similar way to how Bethesda Softworks' Skyrim utilises the first byte as a mod index
|
|
* The maximum number of entities is limited by the size of the container used to store it. E.g., for a 32-bit unsigned integer, there are ~4.3 billion ID's available. But keep in mind that such a large amount of IDs will take significant time for each system to consider.
|