Properly set building owner + apply building pop capacity

This commit is contained in:
2024-01-23 18:39:53 +01:00
parent 547a1ca583
commit 2d11bb4675
14 changed files with 195 additions and 105 deletions

View File

@@ -57,6 +57,26 @@ void updateTextureOwnerTile(ecs_iter_t *it) {
tex[i].rec.y += offset.y;
}
}
void buildingAddPopCapacity(ecs_iter_t *it) {
Game *game = ecs_singleton_get_mut(ECS, Game);
AddPopCapacity *addPop = ecs_field(it, AddPopCapacity, 1);
Owner *owner = ecs_field(it, Owner, 2);
for (i32 i = 0; i < it->count; i++) {
PlayerResources *res = &game->playerResources[owner[i].player];
res->popCapacity += addPop[i].amount;
}
}
void buildingRemovePopCapacity(ecs_iter_t *it) {
Game *game = ecs_singleton_get_mut(ECS, Game);
AddPopCapacity *addPop = ecs_field(it, AddPopCapacity, 1);
Owner *owner = ecs_field(it, Owner, 2);
for (i32 i = 0; i < it->count; i++) {
PlayerResources *res = &game->playerResources[owner->player];
res->popCapacity -= addPop[i].amount;
}
}
void entityUpdateSpatialID(ecs_iter_t *it) {
Game *game = ecs_singleton_get_mut(ECS, Game);