#ifndef PIXELDEFENSE_UNIT_ACTIONS_H #define PIXELDEFENSE_UNIT_ACTIONS_H #include #include 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 Action; typedef void (*ActionCb)(ecs_entity_t entity, Action *action, Game *game); typedef struct Action { ActionType type; union { ActionMoveTo moveTo; ActionCollectResource collectResource; ActionDepositResource depositResource; } as; f32 elapsed; bool finished; bool failed; ActionCb onBegin; ActionCb onFinish; 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); void prependAction(ecs_entity_t entity, Game *game, const Action *action); const char *actionTypeToPrettyStr(ActionType type); #endif //PIXELDEFENSE_UNIT_ACTIONS_H