Add health

This commit is contained in:
2024-02-07 16:12:45 +01:00
parent eb768fa968
commit d6466b8f55
7 changed files with 72 additions and 1 deletions

View File

@@ -90,6 +90,12 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
bool hasCollision = true;
Health health = {
.startHP = 100.0f,
.hp = 100.0f,
.lastChanged = -1.0f,
};
switch (type) {
case BUILDING_KEEP:
ecs_set(ECS, building, AddPopCapacity, {10});
@@ -103,6 +109,8 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
.elapsed = 0.0f,
}
});
health.startHP = 1000.0f;
health.hp = health.startHP;
break;
case BUILDING_BARRACKS:
ecs_set(ECS, building, BuildingRecruitInfo, {
@@ -137,11 +145,15 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
.harvestLimit = 1
});
ecs_set(ECS, building, Resource, {RES_FOOD, INT32_MAX});
health.startHP = 20.0f;
health.hp = health.startHP;
break;
default:
break;
}
ecs_set_ptr(ECS, building, Health, &health);
if (hasCollision)
bzTileMapSetCollisions(&game->map, true, COLL_LAYER_BUILDINGS, posX, posY, sizeX, sizeY);