49 lines
1.4 KiB
C
49 lines
1.4 KiB
C
#pragma once
|
|
|
|
#include <Engine/Class.h>
|
|
|
|
typedef void* DerivedType;
|
|
typedef uint64 EntityID;
|
|
|
|
#define kInvalid_user_id ((uint8)0U)
|
|
#define kInvalid_entity_id ((EntityID)0ULL)
|
|
#define kEntityID_user_id_shift ((EntityID)56ULL)
|
|
#define kEntityID_user_id_mask ((EntityID)0xFF00000000000000ULL)
|
|
|
|
// clang-format off
|
|
#define ENTITY_TYPE_LIST(X) X(Inert),
|
|
|
|
typedef uint8 Entity_Type;
|
|
#define AS_ENUM(name) Entity_Type_##name
|
|
enum
|
|
{
|
|
ENTITY_TYPE_LIST(AS_ENUM)
|
|
Entity_Type_Count
|
|
};
|
|
#undef AS_ENUM
|
|
|
|
extern const char* kEntity_type_names[];
|
|
extern const Class* kEntity_type_class_ptr[];
|
|
|
|
#define ENTITY(kind) ((uint8)Entity_Type_##kind)
|
|
// clang-format on
|
|
|
|
typedef struct Entity Entity;
|
|
|
|
#define DECLARE_ENTITY() Entity* base;
|
|
|
|
#define DEFINE_ENTITY_VERSIONED(entity, version_num) \
|
|
const Class class_kind_##entity = { \
|
|
.Name = ConstString(#entity), \
|
|
.kind = (uint8)Entity_Type_##entity, \
|
|
.version = (version_num), \
|
|
.base_class = &class_kind_Entity, \
|
|
.initialize_fct = init_##entity, \
|
|
.serialize_fct = serialize_##entity, \
|
|
.size_of = sizeof(entity), \
|
|
.alignment = AlignOf(entity) \
|
|
};
|
|
|
|
// Note: Needed by every entity class (see define above)
|
|
extern const Class class_kind_Entity;
|