Files
PixelDefense/game/unit_actions.h
2023-12-17 09:06:14 +01:00

52 lines
1.1 KiB
C

#ifndef PIXELDEFENSE_UNIT_ACTIONS_H
#define PIXELDEFENSE_UNIT_ACTIONS_H
#include <breeze.h>
#include <flecs.h>
typedef struct Game Game;
typedef enum ActionType {
ACTION_NONE,
ACTION_MOVE_TO,
ACTION_COLLECT_RESOURCE,
ACTION_DEPOSIT_RESOURCE,
ACTION_COUNT,
} ActionType;
typedef struct ActionMoveTo {
Vector2 target;
f32 proximityThreshold;
} ActionMoveTo;
typedef struct ActionCollectResource {
} ActionCollectResource;
typedef struct ActionDepositResource {
} ActionDepositResource;
typedef struct Action {
ActionType type;
union {
ActionMoveTo moveTo;
ActionCollectResource collectResource;
ActionDepositResource depositResource;
} as;
f32 elapsed;
bool finished;
struct Action *next;
} Action;
typedef struct UnitAction {
Action *first;
Action *last;
} UnitAction;
void handleAction(ecs_entity_t entity, UnitAction *unitAction, Game *game);
void clearActions(ecs_entity_t entity, Game *game);
void addAction(ecs_entity_t entity, Game *game, const Action *action);
#endif //PIXELDEFENSE_UNIT_ACTIONS_H