79 lines
1.6 KiB
C
79 lines
1.6 KiB
C
#ifndef PIXELDEFENSE_GAME_STATE_H
|
|
#define PIXELDEFENSE_GAME_STATE_H
|
|
|
|
#include <breeze.h>
|
|
#include <flecs.h>
|
|
|
|
typedef enum InputType {
|
|
INPUT_NONE,
|
|
INPUT_BUILDING,
|
|
INPUT_SELECTED_UNITS,
|
|
INPUT_SELECTED_OBJECT,
|
|
INPUT_SELECTED_BUILDING,
|
|
} InputType;
|
|
|
|
typedef struct InputState {
|
|
InputType state;
|
|
// Input mapping
|
|
MouseButton LMB;
|
|
MouseButton RMB;
|
|
MouseButton MMB;
|
|
KeyboardKey ESC;
|
|
f32 CLICK_LIMIT;
|
|
// Common
|
|
Vector2 mouseDown;
|
|
Vector2 mouseDownWorld;
|
|
f32 mouseDownElapsed;
|
|
// INPUT_BUILDING
|
|
int building;
|
|
bool buildingCanPlace;
|
|
TilePosition buildingPos;
|
|
TileSize buildingSize;
|
|
// SELECTED_UNITS
|
|
/*
|
|
* 1: Position
|
|
* 2: Size
|
|
* 3: UnitSelected
|
|
*/
|
|
ecs_query_t *unitSelectedQuery;
|
|
Position *unitPositions;
|
|
// SELECTED_OBJECT
|
|
// SELECTED_BUILDING
|
|
} InputState;
|
|
|
|
typedef struct Game {
|
|
Camera2D camera;
|
|
BzTileset terrainTileset;
|
|
BzTileset buildingsTileset;
|
|
BzTileset entitiesTileset;
|
|
BzTileMap map;
|
|
BzSpatialGrid *entityGrid;
|
|
f32 frameDuration;
|
|
ecs_entity_t entity;
|
|
struct {
|
|
i64 wood;
|
|
i64 iron;
|
|
i64 food;
|
|
i64 gold;
|
|
i64 pop;
|
|
} resources;
|
|
BzStackAlloc stackAlloc;
|
|
struct {
|
|
BzObjectPool *pathData;
|
|
} pools;
|
|
struct {
|
|
bool path;
|
|
bool entityColliders;
|
|
bool mapColliders;
|
|
bool spatialGrid;
|
|
} debugDraw;
|
|
f32 elapsed;
|
|
} Game;
|
|
|
|
extern ecs_world_t *ECS;
|
|
|
|
extern ECS_COMPONENT_DECLARE(Game);
|
|
extern ECS_COMPONENT_DECLARE(InputState);
|
|
|
|
#endif //PIXELDEFENSE_GAME_STATE_H
|