-documentation

This commit is contained in:
Mergul 2018-10-01 19:40:24 +02:00
parent 288ad4c6cd
commit 437c672478
5 changed files with 154 additions and 4 deletions

View file

@ -2,21 +2,36 @@ module ecs.entity;
import ecs.manager;
/************************************************************************************************************************
*Entity ID structure.
*/
struct EntityID
{
///Index to entity in IDManager.
uint id;
///Counter required for reusing ID.
uint counter;
}
/************************************************************************************************************************
*Structure of Entity. It's have only ID, but have full konwlege to get to components memory (If pointer to it is proper).
*/
struct Entity
{
///Entity ID.
EntityID id;
/************************************************************************************************************************
*Update pointer to it in IDManager
*/
void updateID()
{
EntityManager.instance.id_manager.update(this);
}
/************************************************************************************************************************
*Get specified component. If component doesn't exist function retun null.
*/
T* getComponent(T)() const
{
EntityManager.EntitiesBlock* block = gEM.getMetaData(&this);
@ -32,11 +47,19 @@ struct Entity
}
}
/************************************************************************************************************************
*Entity template structure.
*/
export struct EntityTemplate
{
///Entity components data
ubyte[] entity_data;
///Pointer to entity type info.
EntityManager.EntityInfo* info;
/************************************************************************************************************************
*Get specified component. If component doesn't exist function return null.
*/
T* getComponent(T)()
{
if(T.component_id >= info.tmpl_deltas.length)return null;