41 lines
1.2 KiB
C
41 lines
1.2 KiB
C
#pragma once
|
|
|
|
#include <Core/Container/Vector.h>
|
|
#include <Entity/entity_common.h>
|
|
|
|
typedef struct World World;
|
|
typedef struct EntityTemplate EntityTemplate;
|
|
typedef struct Entity Entity;
|
|
typedef struct Class Class;
|
|
typedef struct Archive Archive;
|
|
|
|
typedef struct typed_entity_array typed_entity_array;
|
|
struct typed_entity_array
|
|
{
|
|
Arena* arena;
|
|
EntityTemplate* array;
|
|
size_t count;
|
|
};
|
|
|
|
typedef struct EntityManager EntityManager;
|
|
struct EntityManager
|
|
{
|
|
uint64 next_local_counter;
|
|
|
|
// TODO: Should be a pool
|
|
VectorArena Entities;
|
|
|
|
typed_entity_array by_type[Entity_Type_Count];
|
|
};
|
|
|
|
extern EntityID g_entity_manager_id;
|
|
|
|
void InitEntityManager(World* world);
|
|
void ShutdownEntityManager(void);
|
|
EntityManager* GetEntityManager(void);
|
|
EntityTemplate* RegisterEntity(EntityManager* manager, Entity* base, DerivedType entity);
|
|
Entity* allocate_entity(EntityManager* manager, const Class* derived_type_class);
|
|
void UpdateEntityManager(EntityManager* manager);
|
|
Entity* deserialize_entity(Archive* archive, EntityManager* manager);
|
|
void update_local_counter(EntityManager* manager, EntityID entity_id);
|