This commit is contained in:
2025-06-08 14:38:22 -05:00
parent 8411c2981b
commit 0b6b33721b
69 changed files with 210 additions and 3384 deletions

34
src/rpg/entity/entity.c Normal file
View File

@@ -0,0 +1,34 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "assert/assert.h"
#include "util/memory.h"
#include "entity.h"
entity_t ENTITIES[ENTITY_COUNT];
entitycallbacks_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT] = {
[ENTITY_TYPE_NULL] = {
.init = NULL
},
[ENTITY_TYPE_PLAYER] = {
.init = playerInit
},
};
void entityInit(entity_t *entity, const entitytype_t type) {
assertNotNull(entity, "Entity is NULL");
assertTrue(type < ENTITY_TYPE_COUNT, "Invalid entity type");
assertNotNull(ENTITY_CALLBACKS[type].init, "Entity type has no init");
memoryZero(entity, sizeof(entity_t));
entity->type = type;
ENTITY_CALLBACKS[type].init(entity);
}