Add entity map
This commit is contained in:
60
game/entity_map.h
Normal file
60
game/entity_map.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef PIXELDEFENSE_ENTITY_MAP_H
|
||||
#define PIXELDEFENSE_ENTITY_MAP_H
|
||||
|
||||
#include <breeze.h>
|
||||
#include <flecs.h>
|
||||
|
||||
#include "components.h"
|
||||
|
||||
typedef struct EntityMapIndex {
|
||||
i32 minX, minY;
|
||||
i32 maxX, maxY;
|
||||
} EntityMapIndex;
|
||||
|
||||
typedef struct EntityMapEntry {
|
||||
ecs_entity_t entity;
|
||||
i32 queryIdx;
|
||||
i32 entryID;
|
||||
EntityMapIndex index;
|
||||
} EntityMapEntry;
|
||||
|
||||
typedef i32 EntityMapCell;
|
||||
|
||||
typedef struct EntityMap {
|
||||
EntityMapEntry *entities;
|
||||
EntityMapCell *cells;
|
||||
i32 width;
|
||||
i32 height;
|
||||
i32 cellResolution;
|
||||
i32 cellDepth;
|
||||
} EntityMap;
|
||||
|
||||
typedef struct EntityMapDesc {
|
||||
i32 maxWidth;
|
||||
i32 maxHeight;
|
||||
i32 cellResolution;
|
||||
i32 cellDepth;
|
||||
} EntityMapDesc;
|
||||
|
||||
typedef struct EntityMapIter {
|
||||
EntityMap *entityMap;
|
||||
EntityMapEntry entry;
|
||||
EntityMapIndex index;
|
||||
i32 x;
|
||||
i32 y;
|
||||
i32 cellIdx;
|
||||
} EntityMapIter;
|
||||
|
||||
EntityMap entityMapCreate(const EntityMapDesc *desc);
|
||||
void entityMapDestroy(EntityMap *entityMap);
|
||||
|
||||
EntityMapEntry entityMapInsert(EntityMap *entityMap, ecs_entity_t entity, Position pos, Size size);
|
||||
void entityMapRemove(EntityMap *entityMap, EntityMapEntry entry);
|
||||
void entityMapRemoveID(EntityMap *entityMap, i32 entryID);
|
||||
|
||||
EntityMapIter entityMapQueryIter(EntityMap *entityMap, Position pos, Size size);
|
||||
bool entityMapQueryNext(EntityMapIter *it);
|
||||
|
||||
|
||||
|
||||
#endif //PIXELDEFENSE_ENTITY_MAP_H
|
||||
Reference in New Issue
Block a user