diff --git a/code/modules/modules/systems.c b/code/modules/modules/systems.c index 15d094f..4874cc0 100644 --- a/code/modules/modules/systems.c +++ b/code/modules/modules/systems.c @@ -116,4 +116,6 @@ void SystemsImport(ecs_world_t *ecs) { ECS_SYSTEM(ecs, IntegratePositions, EcsOnValidate, components.Position, components.Velocity); ECS_SYSTEM(ecs, UpdateTrackerPos, EcsPostUpdate, components.Position); + + ECS_SYSTEM(ecs, ClearVehicle, EcsUnSet, components.Vehicle); } diff --git a/code/modules/source/system_vehicle.c b/code/modules/source/system_vehicle.c index 0bc2da0..99ef4f5 100644 --- a/code/modules/source/system_vehicle.c +++ b/code/modules/source/system_vehicle.c @@ -124,3 +124,15 @@ void VehicleHandling(ecs_iter_t *it) { 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); + } + } + } +}