Connect physical elevators and staff commutes to construction, saves, and cutaway UI

This commit is contained in:
Takeshi
2026-09-09 12:58:40 +09:00
parent 4d72de8973
commit 0f12c748e9
46 changed files with 3267 additions and 165 deletions
@@ -1,6 +1,6 @@
extends SceneTree
const RUNTIME_SNAPSHOT_VERSION := 7
const RUNTIME_SNAPSHOT_VERSION := 8
const INFRASTRUCTURE_SNAPSHOT_KEYS: Array[StringName] = [
&"excavation",
&"spatial_subslots",
@@ -59,7 +59,7 @@ func _run() -> void:
_test_completed_proxy_projection()
_test_proxy_completion_raw_signal_commit_order()
_test_proxy_completion_projection_failure_is_atomic()
_test_vertical_preflight_rejection()
_test_completed_elevator_topology()
_test_demolition_projection_atomicity()
_test_current_snapshot_strictness()
_test_v5_proxy_migration_determinism()
@@ -113,14 +113,14 @@ func _test_runtime_surface(fixture: Dictionary) -> bool:
var snapshot: Dictionary = runtime.create_snapshot()
var runtime_data: Dictionary = snapshot[&"systems"][&"runtime"]
var current_version := int(runtime_data.get(&"runtime_schema_version", -1)) == RUNTIME_SNAPSHOT_VERSION
_expect(current_version, "Runtime emits schema v7 with infrastructure state")
_expect(current_version, "Runtime emits schema v8 with infrastructure state")
ready = ready and current_version
for key: StringName in INFRASTRUCTURE_SNAPSHOT_KEYS:
var valid_dictionary := runtime_data.get(key, null) is Dictionary
_expect(valid_dictionary, "current Runtime stores strict %s state" % key)
ready = ready and valid_dictionary
if not ready:
print(" PENDING: Runtime v6 infrastructure surface is not connected yet; behavioral cases skipped.")
print(" PENDING: Runtime v8 infrastructure surface is not connected yet; behavioral cases skipped.")
return ready
@@ -593,45 +593,23 @@ func _test_proxy_completion_projection_failure_is_atomic() -> void:
_free_fixture(fixture)
func _test_vertical_preflight_rejection() -> void:
func _test_completed_elevator_topology() -> void:
var fixture := _new_fixture(81_040)
var runtime: Variant = fixture[&"runtime"]
_expect(_promote_rank_two(fixture, &"infra.vertical.rank"), "vertical fixture reaches Rank 2")
var before := _infrastructure_state(fixture)
var guest = _submit(
runtime,
&"build_facility",
{
&"definition_id": &"guest_elevator",
&"origin": Vector3i(-6, 1, PathType.FRONT),
&"rotation": 0,
},
&"infra.vertical.guest"
)
var service = _submit(
runtime,
&"build_facility",
{
&"definition_id": &"service_elevator",
&"origin": Vector3i(5, 1, PathType.BACK),
&"rotation": 0,
},
&"infra.vertical.service"
)
_expect(
not guest.is_success()
and guest.details.get(&"reason", &"") == &"UNSUPPORTED_VERTICAL_TOPOLOGY",
"guest elevator is rejected at build-command preflight"
)
_expect(
not service.is_success()
and service.details.get(&"reason", &"") == &"UNSUPPORTED_VERTICAL_TOPOLOGY",
"service elevator is rejected with the same stable reason"
)
_expect(
_infrastructure_state(fixture) == before,
"unsupported vertical preflight spends nothing and mutates no service"
)
var cash_before: int = runtime.economy_service.get_balance(&"PLAYER_CASH")
for request: Array in [[&"guest_elevator", Vector3i(-6, 0, PathType.FRONT)], [&"service_elevator", Vector3i(5, 0, PathType.BACK)]]:
var result = _submit(runtime, &"build_facility", {&"definition_id": request[0], &"origin": request[1], &"rotation": 0}, StringName("infra.vertical." + String(request[0])))
_expect(result.is_success(), "%s is accepted through paid build-command preflight" % request[0])
_expect(runtime.economy_service.get_balance(&"PLAYER_CASH") == cash_before - 3700, "accepted lift construction spends actual definition costs")
_expect(runtime.facility_infrastructure_projector.get_projection_ids().is_empty(), "unfinished lift construction does not create usable shaft topology")
fixture[&"clock"].advance_minutes(360)
_expect(runtime.facility_infrastructure_projector.get_projection_ids().size() == 2 and runtime.elevators.get_report()[&"shafts"].size() == 2, "completed guest and service modules project separate cabins")
for shaft: Dictionary in runtime.elevators.get_report()[&"shafts"]:
var result = _submit(runtime, &"set_elevator_operation", {&"shaft_id": shaft[&"shaft_id"], &"operator_open": false}, StringName("infra.vertical.stop." + String(shaft[&"shaft_id"])))
_expect(result.is_success(), "completed lift can be stopped through Runtime command")
_expect(runtime.path_service.find_path(shaft[&"stops"][0], shaft[&"stops"][1]).is_empty(), "stopped lift shaft never permits an ordinary vertical walk bypass")
_expect(runtime.facility_infrastructure_projector.validate_invariants()[&"ok"], "completed elevator ROUTE and owned shaft restrictions crosslink exactly")
_free_fixture(fixture)
@@ -750,10 +728,10 @@ func _test_current_snapshot_strictness() -> void:
_expect(built[&"ok"], "snapshot fixture stores one completed projection")
var snapshot: Dictionary = runtime.create_snapshot()
var expected_digest := SimulationDigest.compute(snapshot)
_expect(runtime.restore_snapshot(snapshot), "valid Runtime v7 snapshot restores")
_expect(runtime.restore_snapshot(snapshot), "valid Runtime v8 snapshot restores")
_expect(
runtime.create_snapshot() == snapshot and runtime.latest_digest == expected_digest,
"Runtime v7 round trip is exact"
"Runtime v8 round trip is exact"
)
_assert_runtime_restore_rejected(
@@ -761,7 +739,7 @@ func _test_current_snapshot_strictness() -> void:
snapshot,
func(candidate: Dictionary) -> void:
candidate[&"systems"][&"runtime"][&"unknown_infrastructure"] = {},
"unknown v7 Runtime field"
"unknown v8 Runtime field"
)
for key: StringName in INFRASTRUCTURE_SNAPSHOT_KEYS:
_assert_runtime_restore_rejected(
@@ -838,9 +816,13 @@ func _test_v5_proxy_migration_determinism() -> void:
var stripped_v6_events := _strip_v6_infrastructure_domain_history(legacy_runtime)
legacy_runtime[&"runtime_schema_version"] = 5
legacy_runtime.erase(&"kitchen_production")
legacy_runtime.erase(&"elevators")
legacy_runtime.erase(&"staff_commute")
for key: StringName in INFRASTRUCTURE_SNAPSHOT_KEYS:
legacy_runtime.erase(key)
legacy_runtime[&"path"] = baseline[&"runtime"].path_service.create_snapshot()
legacy_runtime[&"path"][&"schema_version"] = 3
legacy_runtime[&"path"].erase(&"vertical_walk_blockers")
_free_fixture(baseline)
_expect(
stripped_v6_events > 0 and _legacy_v5_infrastructure_shape_is_clean(legacy_runtime),
@@ -855,8 +837,8 @@ func _test_v5_proxy_migration_determinism() -> void:
_expect(first_runtime.restore_snapshot(legacy), "v5 proxy snapshot migrates through Runtime restore")
var first_migrated: Dictionary = first_runtime.create_snapshot()
_expect(
int(first_migrated[&"systems"][&"runtime"][&"runtime_schema_version"]) == 7,
"v5 migration is immediately re-emitted as v7"
int(first_migrated[&"systems"][&"runtime"][&"runtime_schema_version"]) == 8,
"v5 migration is immediately re-emitted as v8"
)
_expect(
first_runtime.facility_infrastructure_projector.has_projection(instance_id)
@@ -1057,7 +1039,7 @@ func _strip_v6_infrastructure_domain_history(runtime_data: Dictionary) -> int:
func _legacy_v5_infrastructure_shape_is_clean(runtime_data: Dictionary) -> bool:
if runtime_data.has(&"kitchen_production"):
if runtime_data.has(&"kitchen_production") or runtime_data.has(&"elevators") or runtime_data.has(&"staff_commute"):
return false
for key: StringName in INFRASTRUCTURE_SNAPSHOT_KEYS:
if runtime_data.has(key) or runtime_data.has(String(key)):