Add actions
This commit is contained in:
51
game/unit_actions.h
Normal file
51
game/unit_actions.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user