52 lines
1018 B
C
52 lines
1018 B
C
#ifndef PIXELDEFENSE_UNIT_AI_H
|
|
#define PIXELDEFENSE_UNIT_AI_H
|
|
|
|
#include <flecs.h>
|
|
|
|
#include "components.h"
|
|
#include "unit_actions.h"
|
|
|
|
typedef struct Game Game;
|
|
|
|
typedef enum AIType {
|
|
AI_NONE,
|
|
AI_WORKER_BUILD,
|
|
AI_WORKER_HARVEST,
|
|
AI_COUNT,
|
|
} AIType;
|
|
|
|
|
|
typedef struct AIWorkerHarvest {
|
|
ResourceType resource;
|
|
ecs_entity_t target;
|
|
Position targetPosition;
|
|
} AIWorkerHarvest;
|
|
|
|
typedef struct AIWorkerBuild {
|
|
ecs_entity_t buildTarget;
|
|
} AIWorkerBuild;
|
|
|
|
typedef struct UnitAI UnitAI;
|
|
|
|
typedef void (*UnitAIFunc)(ecs_entity_t entity, UnitAI *ai, Game *game);
|
|
|
|
typedef struct UnitAI {
|
|
AIType type;
|
|
union {
|
|
AIWorkerHarvest workerHarvest;
|
|
AIWorkerBuild workerBuild;
|
|
} as;
|
|
|
|
Action *action;
|
|
|
|
// vtable
|
|
UnitAIFunc onSet;
|
|
UnitAIFunc onRemove;
|
|
UnitAIFunc onUpdate;
|
|
} UnitAI;
|
|
|
|
void updateUnitAI(ecs_entity_t entity, UnitAI *unitAI, Game *game);
|
|
void setUnitAI(ecs_entity_t entity, Game *game, const UnitAI *unitAI);
|
|
|
|
#endif //PIXELDEFENSE_UNIT_AI_H
|