P08-03-RTPREVIEW: P08-03を閉じるための共有配置プレビュー判定
This commit is contained in:
@@ -3,26 +3,47 @@ extends SceneTree
|
||||
var _checks := 0
|
||||
var _failures := 0
|
||||
var _serial := 0
|
||||
var _runtime: GatedRuntime
|
||||
var _runtime: Variant
|
||||
var _clock: Variant
|
||||
var _state: Variant
|
||||
|
||||
# Seed diagnostic switches isolate precedence; the operations gate itself is real.
|
||||
class GatedRuntime extends SimulationRuntimeService:
|
||||
var block_operations := false
|
||||
var block_vertical := false
|
||||
func _operations_total_arrears() -> int:
|
||||
return 1 if block_operations else super._operations_total_arrears()
|
||||
func _facility_definition_is_unsupported_vertical_proxy(definition: Variant) -> bool:
|
||||
return block_vertical or super._facility_definition_is_unsupported_vertical_proxy(definition)
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
func _run() -> void:
|
||||
_runtime = GatedRuntime.new()
|
||||
_clock = load("res://autoload/game_clock.gd").new()
|
||||
_state = load("res://autoload/game_state.gd").new()
|
||||
var base_script: Variant = load("res://autoload/simulation_runtime.gd")
|
||||
if base_script == null or not base_script.can_instantiate():
|
||||
push_error("Runtime preview base script could not be loaded.")
|
||||
quit(1)
|
||||
return
|
||||
# Seed diagnostic switches isolate precedence; the operations gate itself is real.
|
||||
var diagnostic_script := GDScript.new()
|
||||
diagnostic_script.source_code = """extends "res://autoload/simulation_runtime.gd"
|
||||
var block_operations := false
|
||||
var block_vertical := false
|
||||
func _operations_total_arrears() -> int:
|
||||
return 1 if block_operations else super._operations_total_arrears()
|
||||
func _facility_definition_is_unsupported_vertical_proxy(definition: Variant) -> bool:
|
||||
return block_vertical or super._facility_definition_is_unsupported_vertical_proxy(definition)
|
||||
"""
|
||||
var reload_error := diagnostic_script.reload()
|
||||
if reload_error != OK:
|
||||
push_error("Runtime preview diagnostic script reload failed: %s" % reload_error)
|
||||
quit(1)
|
||||
return
|
||||
_runtime = diagnostic_script.new()
|
||||
if _runtime == null:
|
||||
push_error("Runtime preview diagnostic instance is null.")
|
||||
quit(1)
|
||||
return
|
||||
for method: StringName in [&"initialize", &"create_snapshot", &"enable_production_operations"]:
|
||||
if not _runtime.has_method(method):
|
||||
push_error("Runtime preview diagnostic instance lacks method: %s" % method)
|
||||
quit(1)
|
||||
return
|
||||
var infrastructure_projector: Variant = load("res://scripts/world/facility_infrastructure_projector.gd")
|
||||
_reset()
|
||||
var cell := Vector3i(-8, 2, 0)
|
||||
_failure_case(&"unknown.preview.definition", cell, 0, "NOT_FOUND", "Facility definition was not found.")
|
||||
@@ -32,7 +53,7 @@ func _run() -> void:
|
||||
_failure_case(&"unknown.preview.definition", cell, 999, "UNPAID_EXPENSES", "Operations currently block construction and investment.")
|
||||
_failure_case(&"guest_stairs", cell, 999, "UNPAID_EXPENSES", "Operations currently block construction and investment.")
|
||||
_runtime.block_operations = false
|
||||
_failure_case(&"guest_stairs", cell, 999, String(FacilityInfrastructureProjector.REASON_UNSUPPORTED_VERTICAL_TOPOLOGY), "Vertical infrastructure topology is not supported.")
|
||||
_failure_case(&"guest_stairs", cell, 999, String(infrastructure_projector.REASON_UNSUPPORTED_VERTICAL_TOPOLOGY), "Vertical infrastructure topology is not supported.")
|
||||
_reset()
|
||||
_failure_case(&"guest_stairs", cell, 999, "STAIR_LANDING_MISSING", "先に階段の一つ下の階に通路を作ってください。")
|
||||
_failure_case(&"guest_corridor", cell, 999, "INVALID_PAYLOAD", "The selected rotation is not allowed.")
|
||||
@@ -42,7 +63,7 @@ func _run() -> void:
|
||||
walkable.append(Vector3i(-8, 1, 0))
|
||||
check(_runtime.path_service.rebuild_graph(walkable), "diagnostic landing path")
|
||||
var report := _pure_preview(&"guest_stairs", cell, 0)
|
||||
var accepted := _command(&"guest_stairs", cell, 0)
|
||||
var accepted: Variant = _command(&"guest_stairs", cell, 0)
|
||||
check(report[&"can_build"] and accepted.is_success(), "positive landing preview and command agree")
|
||||
_reset()
|
||||
check(_command(&"guest_elevator", Vector3i.ZERO, 0).is_success(), "build real elevator")
|
||||
@@ -71,10 +92,10 @@ func _pure_preview(id: StringName, cell: Vector3i, rotation: int) -> Dictionary:
|
||||
var before := var_to_bytes(_runtime.create_snapshot())
|
||||
# CommandQueue contains the accepted command log and processed receipts.
|
||||
var log_before := var_to_bytes(_runtime.command_queue.create_snapshot())
|
||||
var commands_before := _runtime.command_queue.get_accepted_command_metadata().size()
|
||||
var processed_before := _runtime.command_queue.processed_count()
|
||||
var events_before := _runtime.domain_events.recent_events().size()
|
||||
var report := _runtime.preview_build_facility(id, cell, rotation)
|
||||
var commands_before: int = _runtime.command_queue.get_accepted_command_metadata().size()
|
||||
var processed_before: int = _runtime.command_queue.processed_count()
|
||||
var events_before: int = _runtime.domain_events.recent_events().size()
|
||||
var report: Dictionary = _runtime.preview_build_facility(id, cell, rotation)
|
||||
check(before == var_to_bytes(_runtime.create_snapshot()), "preview preserves typed snapshot bytes")
|
||||
check(log_before == var_to_bytes(_runtime.command_queue.create_snapshot()), "preview preserves command log bytes")
|
||||
check(commands_before == _runtime.command_queue.get_accepted_command_metadata().size() and processed_before == _runtime.command_queue.processed_count(), "preview preserves command counts")
|
||||
@@ -102,3 +123,4 @@ func check(ok: bool, message: String) -> void:
|
||||
if not ok:
|
||||
_failures += 1
|
||||
push_error(message)
|
||||
quit(1)
|
||||
|
||||
Reference in New Issue
Block a user