33 lines
776 B
C
33 lines
776 B
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "map.h"
|
|
#include "util/memory.h"
|
|
#include "assert/assert.h"
|
|
|
|
void mapInit(map_t *map) {
|
|
assertNotNull(map, "Map cannot be NULL");
|
|
memoryZero(map, sizeof(map_t));
|
|
}
|
|
|
|
void mapUpdate(map_t *map) {
|
|
assertNotNull(map, "Map cannot be NULL");
|
|
|
|
entity_t *start = &map->entities[0];
|
|
entity_t *end = &map->entities[map->entityCount];
|
|
while(start < end) {
|
|
entityUpdate(start++);
|
|
}
|
|
}
|
|
|
|
entity_t * mapEntityAdd(map_t *map) {
|
|
assertNotNull(map, "Map cannot be NULL");
|
|
assertTrue(map->entityCount < MAP_ENTITY_COUNT_MAX, "Map entities full");
|
|
|
|
entity_t *entity = &map->entities[map->entityCount++];
|
|
return entity;
|
|
} |