#ifndef PIXELDEFENSE_COMPONENTS_H #define PIXELDEFENSE_COMPONENTS_H #include #include #include "game_tileset.h" extern ECS_TAG_DECLARE(TextureTerrain); extern ECS_TAG_DECLARE(TextureBuildings); extern ECS_TAG_DECLARE(TextureEntities); typedef enum ResourceType { RES_IRON, RES_WOOD, RES_GOLD, RES_FOOD, RES_COUNT, } ResourceType; static const char *getResourceTypePrettyName(ResourceType type) { switch (type) { case RES_IRON: return "Iron"; case RES_WOOD: return "Wood"; case RES_GOLD: return "Gold"; case RES_FOOD: return "Food"; default: return "Invalid"; } } typedef struct Resource { ResourceType type; i32 amount; } Resource; extern ECS_COMPONENT_DECLARE(Resource); typedef struct TilePosition { BzTile x; BzTile y; } TilePosition; extern ECS_COMPONENT_DECLARE(TilePosition); typedef struct TileSize { BzTile sizeX; BzTile sizeY; } TileSize; extern ECS_COMPONENT_DECLARE(TileSize); typedef struct Owner { BuildingType playerID; } Owner; extern ECS_COMPONENT_DECLARE(Owner); /********************************************************** * Movement components *********************************************************/ typedef BzSpatialGridID SpatialGridID; extern ECS_COMPONENT_DECLARE(SpatialGridID); typedef Vector2 Position, Size, Velocity, TargetPosition, Steering; typedef f32 Rotation; extern ECS_COMPONENT_DECLARE(Position); extern ECS_COMPONENT_DECLARE(Size); extern ECS_COMPONENT_DECLARE(Velocity); extern ECS_COMPONENT_DECLARE(Rotation); extern ECS_COMPONENT_DECLARE(Steering); extern ECS_COMPONENT_DECLARE(TargetPosition); #define PATH_DATA_SIZE 8 typedef struct PathData { Position waypoints[PATH_DATA_SIZE]; size_t numWaypoints; struct PathData *next; } PathData; typedef struct Path { PathData *paths; i32 curWaypoint; } Path; extern ECS_COMPONENT_DECLARE(Path); /********************************************************** * Render components *********************************************************/ typedef struct TextureRegion { Texture2D texture; Rectangle rec; f32 rotation; bool flipX : 1; bool flipY : 1; } TextureRegion; extern ECS_COMPONENT_DECLARE(TextureRegion); /********************************************************** * Animation components *********************************************************/ typedef struct Animation { EntityType entityType; AnimType animType; AnimationFrame frame; AnimationSequence sequence; BzTileset *tileset; i32 curFrame; f32 elapsed; } Animation; extern ECS_COMPONENT_DECLARE(Animation); typedef struct EntityArms { ecs_entity_t left; ecs_entity_t right; } EntityArms; //extern ECS_COMPONENT_DECLARE(EntityArms); /********************************************************** * Gameplay components *********************************************************/ extern ECS_COMPONENT_DECLARE(UnitAction); extern ECS_COMPONENT_DECLARE(UnitAI); extern ECS_TAG_DECLARE(Selectable); extern ECS_TAG_DECLARE(Selected); // Unit can: // - Attack extern ECS_TAG_DECLARE(Unit); // Worker can: // - Harvest // - Build // - Work // - Attack (since it is also a unit) extern ECS_TAG_DECLARE(Worker); extern ECS_TAG_DECLARE(Harvestable); extern ECS_TAG_DECLARE(Buildable); extern ECS_TAG_DECLARE(Workable); extern ECS_TAG_DECLARE(Attackable); typedef struct Storage { int capacity[RES_COUNT]; int amount[RES_COUNT]; int reserved[RES_COUNT]; int pending[RES_COUNT]; } Storage; extern ECS_COMPONENT_DECLARE(Storage); void initComponentIDs(ecs_world_t *ecs); #endif //PIXELDEFENSE_COMPONENTS_H