Similar to previous change, but if cars are on the road(s) that get

removed
This commit is contained in:
2026-04-27 15:32:30 +02:00
parent da5c60d76b
commit 4ad3f3d098

View File

@@ -77,7 +77,6 @@ delete_entity :: proc(self: ^Simulator, entity_index: u32, type: common.Entity)
switch type { switch type {
case .Node: case .Node:
// get cars that are on that node // get cars that are on that node
for i in 0..<len(self.cars) { for i in 0..<len(self.cars) {
pos := self.cars[i].pos pos := self.cars[i].pos
if pos.type != .Node || pos.ref != entity_index do continue if pos.type != .Node || pos.ref != entity_index do continue
@@ -92,6 +91,14 @@ delete_entity :: proc(self: ^Simulator, entity_index: u32, type: common.Entity)
for &car in self.cars do v.car_update_node_reference(&car, index_change[0], index_change[1]) for &car in self.cars do v.car_update_node_reference(&car, index_change[0], index_change[1])
return index_change, true return index_change, true
case .Road: case .Road:
// get cars that are on that road
for i in 0..<len(self.cars) {
pos := self.cars[i].pos
if pos.type != .Road || pos.ref != entity_index do continue
delete_entity(self, u32(i), .Car)
}
unordered_remove(&self.roads, entity_index) unordered_remove(&self.roads, entity_index)
if !swap_made do return {}, false if !swap_made do return {}, false