Add explicit stairs and measure elevator congestion with real actors
This commit is contained in:
@@ -3,6 +3,7 @@ extends Control
|
||||
|
||||
signal facility_selected(instance_id: StringName)
|
||||
signal construction_selected(job_id: StringName)
|
||||
signal legacy_stair_selected(stair_id: StringName)
|
||||
signal cell_clicked(cell: Vector3i)
|
||||
signal hovered_cell_changed(cell: Variant)
|
||||
signal build_preview_changed(report: Dictionary)
|
||||
@@ -320,6 +321,12 @@ func _gui_input(event: InputEvent) -> void:
|
||||
cell_clicked.emit(cell)
|
||||
accept_event()
|
||||
return
|
||||
var stair_id := legacy_stair_at_canvas(event.position)
|
||||
if not stair_id.is_empty():
|
||||
selected_entity_id = stair_id
|
||||
legacy_stair_selected.emit(stair_id)
|
||||
accept_event()
|
||||
return
|
||||
var world: Variant = _service(&"world_service")
|
||||
if world != null and world.has_method(&"get_occupant"):
|
||||
var occupant_id := StringName(world.call(&"get_occupant", cell))
|
||||
@@ -353,6 +360,7 @@ func _draw() -> void:
|
||||
if show_grid:
|
||||
_draw_congestion_overlay(bounds)
|
||||
_draw_world_entity_icons()
|
||||
_draw_legacy_stairs()
|
||||
_draw_elevators()
|
||||
_draw_construction_labels()
|
||||
_draw_facility_labels()
|
||||
@@ -537,6 +545,53 @@ func _draw_world_entity_icons() -> void:
|
||||
draw_rect(rect.grow(-p),Color("f5d582"),false,2*p)
|
||||
|
||||
|
||||
func get_legacy_stair_records() -> Array[Dictionary]:
|
||||
var result: Array[Dictionary] = []
|
||||
var service: Variant = _service(&"legacy_stairs")
|
||||
if service == null or not service.has_method(&"create_snapshot"):
|
||||
return result
|
||||
var snapshot: Variant = service.call(&"create_snapshot")
|
||||
if not snapshot is Dictionary:
|
||||
return result
|
||||
for row: Variant in snapshot.get(&"stairs", []):
|
||||
if row is Dictionary and row.get(&"from") is Vector3i and row.get(&"to") is Vector3i:
|
||||
var record: Dictionary = row.duplicate(true)
|
||||
var path: Variant = _service(&"path_service")
|
||||
var connector: Dictionary = path.call(&"get_connector", StringName(row[&"id"])) if path != null else {}
|
||||
record[&"access_id"] = connector.get(&"access_id", &"")
|
||||
result.append(record)
|
||||
return result
|
||||
|
||||
|
||||
func legacy_stair_at_canvas(canvas_position: Vector2) -> StringName:
|
||||
for stair: Dictionary in get_legacy_stair_records():
|
||||
var upper: Vector3i = stair[&"to"] if stair[&"to"].y > stair[&"from"].y else stair[&"from"]
|
||||
if upper.z == layer_mode and _legacy_stair_rect(upper).has_point(canvas_position):
|
||||
return StringName(stair[&"id"])
|
||||
return &""
|
||||
|
||||
|
||||
func _legacy_stair_rect(upper: Vector3i) -> Rect2:
|
||||
var rect := get_cell_rect(upper)
|
||||
# A small target leaves the rest of an existing room available for selection.
|
||||
return Rect2(rect.position+rect.size*Vector2(0.49,0.24), rect.size*Vector2(0.5,0.7))
|
||||
|
||||
|
||||
func _draw_legacy_stairs() -> void:
|
||||
for stair: Dictionary in get_legacy_stair_records():
|
||||
var upper: Vector3i = stair[&"to"] if stair[&"to"].y > stair[&"from"].y else stair[&"from"]
|
||||
if upper.z != layer_mode:
|
||||
continue
|
||||
var rect := _legacy_stair_rect(upper)
|
||||
if not rect.intersects(Rect2(Vector2.ZERO, size)):
|
||||
continue
|
||||
var p := rect.size.x/14.0
|
||||
draw_rect(rect, Color("3c4e40",0.5))
|
||||
PixelArt.stairs(self,rect,p,upper.z == LayerMode.BACK,true)
|
||||
if StringName(stair[&"id"]) == selected_entity_id:
|
||||
draw_rect(rect,Color("f5d582"),false,maxf(p,1))
|
||||
|
||||
|
||||
func _cell_bounds_rect(cells: Array[Vector3i]) -> Rect2:
|
||||
if cells.is_empty():
|
||||
return Rect2()
|
||||
@@ -605,7 +660,7 @@ func _draw_facility_labels() -> void:
|
||||
var selected := StringName(facility.get(&"instance_id",&""))==selected_entity_id
|
||||
if not hovered and not selected and rect.size.x<100:
|
||||
continue
|
||||
if id in [&"guest_corridor",&"service_corridor",&"staff_door"] and not hovered and not selected:
|
||||
if id in [&"guest_corridor",&"service_corridor",&"staff_door",&"guest_stairs",&"service_stairs"] and not hovered and not selected:
|
||||
continue
|
||||
var definition: Variant = registry.call(&"get_facility",id) if registry != null else null
|
||||
var label := String(definition.display_name) if definition != null else String(id)
|
||||
|
||||
Reference in New Issue
Block a user