Files
PixelDefense/game/components.h

102 lines
2.2 KiB
C

#ifndef PIXELDEFENSE_COMPONENTS_H
#define PIXELDEFENSE_COMPONENTS_H
#include <breeze.h>
#include <flecs.h>
#include "utils/building_types.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;
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);
typedef BzSpatialGridID SpatialGridID;
extern ECS_COMPONENT_DECLARE(SpatialGridID);
typedef Vector2 Position, Size, Velocity;
extern ECS_COMPONENT_DECLARE(Position);
extern ECS_COMPONENT_DECLARE(Size);
extern ECS_COMPONENT_DECLARE(Velocity);
typedef f32 Rotation, AngularVelocity;
extern ECS_COMPONENT_DECLARE(Rotation);
extern ECS_COMPONENT_DECLARE(AngularVelocity);
typedef struct SteeringOutput {
Vector2 linear;
f32 angular;
} SteeringOutput;
extern ECS_COMPONENT_DECLARE(SteeringOutput);
typedef struct TextureRegion {
Texture2D texture;
Rectangle rec;
bool flipX;
bool flipY;
} TextureRegion;
extern ECS_COMPONENT_DECLARE(TextureRegion);
typedef enum AnimationType {
ANIMATION_IDLE,
ANIMATION_WALK,
} AnimationType;
extern ECS_COMPONENT_DECLARE(AnimationType);
typedef struct Animation {
TextureRegion firstFrame;
AnimationType currAnimation;
i32 currFrame;
i32 frameCount;
f32 frameDuration;
f32 elapsed;
} Animation;
extern ECS_COMPONENT_DECLARE(Animation);
#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);
void initComponentIDs(ecs_world_t *ecs);
#endif //PIXELDEFENSE_COMPONENTS_H