Connect physical elevators and staff commutes to construction, saves, and cutaway UI
This commit is contained in:
@@ -403,7 +403,7 @@ func _access_path(start: Vector3i, facility: FacilityInstance) -> Dictionary:
|
||||
return {&"reachable": false}
|
||||
var cells: Dictionary = {}
|
||||
for cell: Vector3i in facility.occupied_cells:
|
||||
for delta: Vector3i in [Vector3i.ZERO, Vector3i.LEFT, Vector3i.RIGHT, Vector3i.UP, Vector3i.DOWN]:
|
||||
for delta: Vector3i in [Vector3i.ZERO, Vector3i.LEFT, Vector3i.RIGHT]:
|
||||
if _runtime.path_service.has_cell(cell + delta):
|
||||
cells[cell + delta] = true
|
||||
if cells.is_empty() and _runtime.path_service.has_cell(facility.origin):
|
||||
@@ -414,10 +414,13 @@ func _access_path(start: Vector3i, facility: FacilityInstance) -> Dictionary:
|
||||
if a.y != b.y: return a.y < b.y
|
||||
return a.x < b.x)
|
||||
var best: Array[Vector3i] = []
|
||||
var best_cost := 9223372036854775807
|
||||
for cell: Vector3i in ordered:
|
||||
var path: Array[Vector3i] = _runtime.path_service.find_path(start, cell, [WorldService.LAYER_FRONT, WorldService.LAYER_BACK], [&"staff"])
|
||||
if not path.is_empty() and (best.is_empty() or path.size() < best.size()):
|
||||
var cost: int = _runtime.path_service.calculate_path_cost(path, [&"staff"]) if not path.is_empty() else -1
|
||||
if cost >= 0 and (best.is_empty() or cost < best_cost):
|
||||
best = path
|
||||
best_cost = cost
|
||||
return {&"reachable": not best.is_empty(), &"cell": best[-1] if not best.is_empty() else facility.origin, &"steps": maxi(0, best.size() - 1)}
|
||||
|
||||
|
||||
@@ -557,6 +560,6 @@ static func validate_crosslinks(requests: Dictionary, staff: StaffService, inven
|
||||
|
||||
static func _cell_touches_facility(cell: Vector3i, facility: FacilityInstance) -> bool:
|
||||
for occupied: Vector3i in facility.occupied_cells:
|
||||
if cell.z == occupied.z and absi(cell.x - occupied.x) + absi(cell.y - occupied.y) <= 1:
|
||||
if cell.z == occupied.z and cell.y == occupied.y and absi(cell.x - occupied.x) <= 1:
|
||||
return true
|
||||
return cell == facility.origin
|
||||
|
||||
Reference in New Issue
Block a user