code: fix ents on Vehicle UnSet

isolation_bkp/dynres
Dominik Madarász 2021-08-11 10:54:52 +02:00
parent 9b829074d4
commit ba345065bb
2 changed files with 14 additions and 0 deletions

View File

@ -116,4 +116,6 @@ void SystemsImport(ecs_world_t *ecs) {
ECS_SYSTEM(ecs, IntegratePositions, EcsOnValidate, components.Position, components.Velocity); ECS_SYSTEM(ecs, IntegratePositions, EcsOnValidate, components.Position, components.Velocity);
ECS_SYSTEM(ecs, UpdateTrackerPos, EcsPostUpdate, components.Position); ECS_SYSTEM(ecs, UpdateTrackerPos, EcsPostUpdate, components.Position);
ECS_SYSTEM(ecs, ClearVehicle, EcsUnSet, components.Vehicle);
} }

View File

@ -124,3 +124,15 @@ void VehicleHandling(ecs_iter_t *it) {
car->heading = zpl_arctan2(fr_y - bk_y, fr_x - bk_x); car->heading = zpl_arctan2(fr_y - bk_y, fr_x - bk_x);
} }
} }
void ClearVehicle(ecs_iter_t *it) {
Vehicle *veh = ecs_column(it, Vehicle, 1);
for (int i = 0; i < it->count; i++) {
for (int k = 0; k < 4; k++) {
if (veh[i].seats[k] != 0) {
ecs_remove(it->world, veh[i].seats[k], IsInVehicle);
}
}
}
}