Implement warehouse and granary
This commit is contained in:
@@ -95,11 +95,14 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
|
||||
.hp = 100.0f,
|
||||
.lastChanged = -1.0f,
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
case BUILDING_KEEP:
|
||||
ecs_set(ECS, building, AddPopCapacity, {10});
|
||||
ecs_add_id(ECS, building, Storage);
|
||||
ecs_set(ECS, building, Storage, {
|
||||
.stores[RES_WOOD] = true,
|
||||
.stores[RES_GOLD] = true,
|
||||
.stores[RES_FOOD] = true,
|
||||
});
|
||||
ecs_set(ECS, building, BuildingRecruitInfo, {
|
||||
.numSlots = 1,
|
||||
.slots[0] = {
|
||||
@@ -112,6 +115,20 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
|
||||
health.startHP = 1000.0f;
|
||||
health.hp = health.startHP;
|
||||
break;
|
||||
case BUILDING_WAREHOUSE:
|
||||
ecs_set(ECS, building, Storage, {
|
||||
.stores[RES_WOOD] = true,
|
||||
.stores[RES_GOLD] = true,
|
||||
.stores[RES_FOOD] = false,
|
||||
});
|
||||
break;
|
||||
case BUILDING_GRANARY:
|
||||
ecs_set(ECS, building, Storage, {
|
||||
.stores[RES_WOOD] = false,
|
||||
.stores[RES_GOLD] = false,
|
||||
.stores[RES_FOOD] = true,
|
||||
});
|
||||
break;
|
||||
case BUILDING_BARRACKS:
|
||||
ecs_set(ECS, building, BuildingRecruitInfo, {
|
||||
.numSlots = 2,
|
||||
@@ -136,7 +153,6 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
|
||||
case BUILDING_HOUSE_05:
|
||||
case BUILDING_HOUSE_06:
|
||||
ecs_set(ECS, building, AddPopCapacity, {5});
|
||||
ecs_add_id(ECS, building, Storage);
|
||||
break;
|
||||
case BUILDING_WHEAT_0:
|
||||
case BUILDING_WHEAT_1:
|
||||
@@ -147,6 +163,7 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
|
||||
ecs_set(ECS, building, Resource, {RES_FOOD, INT32_MAX});
|
||||
health.startHP = 20.0f;
|
||||
health.hp = health.startHP;
|
||||
hasCollision = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -154,8 +171,10 @@ ecs_entity_t placeBuilding(Game *game, BuildingType type,
|
||||
|
||||
ecs_set_ptr(ECS, building, Health, &health);
|
||||
|
||||
if (hasCollision)
|
||||
if (hasCollision) {
|
||||
bzTileMapSetCollisions(&game->map, true, COLL_LAYER_BUILDINGS, posX, posY, sizeX, sizeY);
|
||||
}
|
||||
|
||||
|
||||
return building;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user