Files
PixelDefense/game/unit_actions.h

56 lines
1.2 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 {
ecs_entity_t entity;
} ActionCollectResource;
typedef struct ActionDepositResource {
ecs_entity_t entity;
} ActionDepositResource;
typedef struct Action {
ActionType type;
union {
ActionMoveTo moveTo;
ActionCollectResource collectResource;
ActionDepositResource depositResource;
} as;
f32 elapsed;
bool finished;
bool failed;
struct Action *next;
} Action;
typedef struct UnitAction {
Action *first;
Action *last;
} UnitAction;
void handleAction(ecs_entity_t entity, UnitAction *unitAction, Game *game);
void updateAction(UnitAction *unitAction, Game *game);
void clearActions(ecs_entity_t entity, Game *game);
void addAction(ecs_entity_t entity, Game *game, const Action *action);
const char *actionTypeToPrettyStr(ActionType type);
#endif //PIXELDEFENSE_UNIT_ACTIONS_H