Similar to previous change, but if cars are on the road(s) that get
removed
This commit is contained in:
@@ -77,7 +77,6 @@ delete_entity :: proc(self: ^Simulator, entity_index: u32, type: common.Entity)
|
||||
switch type {
|
||||
case .Node:
|
||||
// get cars that are on that node
|
||||
|
||||
for i in 0..<len(self.cars) {
|
||||
pos := self.cars[i].pos
|
||||
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])
|
||||
return index_change, true
|
||||
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)
|
||||
if !swap_made do return {}, false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user