P13-02-CODE1: P13-02 背面対象参照・占有・保存の非描写機構(全原成果の一部、加算なし)

This commit is contained in:
Agent Control Runner
2026-10-17 17:03:48 +09:00
parent 1e8d4ea888
commit e930a1dedf
12 changed files with 1015 additions and 0 deletions
+48
View File
@@ -20,6 +20,7 @@ const OPERATING_EXPENSE_ACCOUNT := &"OPERATING_EXPENSE"
const AUTHORITY_FINE_ACCOUNT := &"AUTHORITY_FINE_EXPENSE"
const WAGE_EXPENSE_ACCOUNT := &"WAGE_EXPENSE"
const RUNTIME_SNAPSHOT_VERSION := 14
const PeepingRooms := preload("res://scripts/special/peeping_room_service.gd")
const AUTO_PURCHASE_RUNTIME_SNAPSHOT_VERSION := 14
const EVENT_THREAT_RUNTIME_SNAPSHOT_VERSION := 13
const MIMI_PURCHASE_RUNTIME_SNAPSHOT_VERSION := 15
@@ -97,6 +98,7 @@ const DEFENSE_COMMAND_TYPES: Array[StringName] = [
var definition_registry := DefinitionRegistry.new()
var command_queue := CommandQueue.new()
var id_generator := StableIdGenerator.new()
var peeping_room_service := PeepingRooms.new()
var domain_events := DomainEventStream.new()
var world_service := WorldService.new()
var path_service := PathService.new()
@@ -233,6 +235,7 @@ func initialize(clock: SimulationKernel, state: Variant, seed := DEFAULT_WORLD_S
_hired_staff_candidate_ids.clear()
command_queue = CommandQueue.new()
id_generator = StableIdGenerator.new()
peeping_room_service = PeepingRooms.new()
domain_events = DomainEventStream.new()
world_service = WorldService.new()
path_service = PathService.new()
@@ -253,6 +256,7 @@ func initialize(clock: SimulationKernel, state: Variant, seed := DEFAULT_WORLD_S
_initialize_s5_defense()
construction_service = ConstructionService.new(world_service, construction_resource_state)
construction_service.current_minute = _clock.absolute_minute
peeping_room_service.configure(world_service, facility_service, construction_service, path_service, id_generator)
_connect_construction_signals()
var initial_infrastructure_ok := _initialize_infrastructure_services()
_next_command_id = 1
@@ -298,6 +302,8 @@ func initialize(clock: SimulationKernel, state: Variant, seed := DEFAULT_WORLD_S
register_command_executor(&"build_facility", Callable(self, "_execute_build_facility"))
register_command_executor(&"cancel_construction", Callable(self, "_execute_cancel_construction"))
register_command_executor(&"demolish_facility", Callable(self, "_execute_demolish_facility"))
for command_type: StringName in [&"peeping_room_validate", &"peeping_room_place", &"peeping_room_relink", &"peeping_room_record_evidence"]:
register_command_executor(command_type, Callable(self, "_execute_peeping_room"))
register_command_executor(&"set_elevator_operation", Callable(self, "_execute_set_elevator_operation"))
register_command_executor(&"start_excavation", Callable(self, "_execute_start_excavation"))
register_command_executor(&"pause_excavation", Callable(self, "_execute_pause_excavation"))
@@ -565,6 +571,8 @@ func create_snapshot() -> Dictionary:
}
if PurchaseQuoteV2.has_history(owned_systems[&"runtime"]):
owned_systems[&"runtime"][&"runtime_schema_version"] = MIMI_PURCHASE_RUNTIME_SNAPSHOT_VERSION
if not peeping_room_service.is_empty():
owned_systems[&"runtime"][&"special_peeping_rooms"] = peeping_room_service.create_snapshot()
# Every component above returns detached containers. Transfer this fresh
# tree into the envelope instead of deep-copying all component snapshots a
# second time. Keep generic capture's caller-owned-extra contract unchanged.
@@ -666,6 +674,8 @@ func _restore_snapshot_internal(snapshot: Dictionary, recovery_mode: bool) -> bo
runtime_current_keys.append(&"facility_cleanliness")
if runtime_schema_version >= AUTO_PURCHASE_RUNTIME_SNAPSHOT_VERSION:
runtime_current_keys.append(&"auto_purchase_plans")
if runtime_data.has(&"special_peeping_rooms"):
runtime_current_keys.append(&"special_peeping_rooms")
if not _dictionary_has_exact_canonical_keys(runtime_data, runtime_current_keys) \
or typeof(runtime_data.get(&"runtime_schema_version", null)) != TYPE_INT \
or typeof(runtime_data.get(&"world_seed", null)) != TYPE_INT \
@@ -1290,6 +1300,16 @@ func _restore_snapshot_internal(snapshot: Dictionary, recovery_mode: bool) -> bo
var restored_next_id := int(runtime_data.get(&"next_command_id", 0))
if restored_next_id <= 0:
return false
var restored_peeping_rooms := PeepingRooms.new()
restored_peeping_rooms.configure(restored_world, restored_facilities, restored_construction, restored_path, restored_id_generator)
if runtime_data.has(&"special_peeping_rooms"):
if not runtime_data[&"special_peeping_rooms"] is Dictionary:
return false
for raw_key: Variant in runtime_data:
if raw_key == &"special_peeping_rooms" and typeof(raw_key) != TYPE_STRING_NAME:
return false
if not restored_peeping_rooms.restore_section(runtime_data.get(&"special_peeping_rooms", null), restored_minute):
return false
if not SimulationSnapshot.restore(snapshot, _clock, _state):
return false
world_seed = restored_world_seed
@@ -1297,6 +1317,7 @@ func _restore_snapshot_internal(snapshot: Dictionary, recovery_mode: bool) -> bo
_staffing_projection_enabled = restored_staffing_projection
command_queue = restored_queue
id_generator = restored_id_generator
peeping_room_service = restored_peeping_rooms
domain_events = restored_domain_events
_rng_streams = restored_streams
world_service = restored_world
@@ -5546,6 +5567,7 @@ func _connect_facility_signals() -> void:
return
facility_service.instance_registered.connect(Callable(self, "_on_cleanliness_facility_registered"))
facility_service.instance_unregistered.connect(Callable(self, "_on_cleanliness_facility_unregistered"))
facility_service.instance_unregistered.connect(Callable(self, "_on_peeping_target_removed"))
facility_service.facility_state_changed.connect(Callable(self, "_on_facility_state_changed"))
facility_service.service_started.connect(Callable(self, "_on_service_started"))
facility_service.service_interrupted.connect(Callable(self, "_on_service_interrupted"))
@@ -10817,6 +10839,7 @@ func _on_excavation_completed(report: Dictionary) -> void:
))
func _on_facility_demolished(instance_id: StringName, refund: Dictionary) -> void:
peeping_room_service.target_removed(instance_id)
if not mana_network_service.get_node(instance_id).is_empty():
mana_network_service.unregister_node(instance_id)
if facility_service.has_instance(instance_id):
@@ -10831,6 +10854,31 @@ func _on_facility_demolished(instance_id: StringName, refund: Dictionary) -> voi
0
))
func _on_peeping_target_removed(instance_id: StringName) -> void:
peeping_room_service.target_removed(instance_id)
func _execute_peeping_room(command: SimulationCommand) -> CommandResult:
var payload := command.payload
var report: Dictionary
if command.command_type == &"peeping_room_place":
report = PeepingRooms.result(&"BUILD_DEFINITION_PENDING_D04")
elif command.command_type == &"peeping_room_validate":
if typeof(payload.get(&"origin")) != TYPE_VECTOR3I or typeof(payload.get(&"footprint", Vector2i(2, 1))) != TYPE_VECTOR2I or typeof(payload.get(&"target_instance_id", &"")) not in [TYPE_STRING, TYPE_STRING_NAME]:
report = PeepingRooms.result(&"INVALID_PAYLOAD")
else:
report = peeping_room_service.validate_placement(payload[&"origin"], payload.get(&"footprint", Vector2i(2, 1)), StringName(payload.get(&"target_instance_id", &"")))
else:
var key: StringName = &"target_instance_id" if command.command_type == &"peeping_room_relink" else &"source_event_key"
if typeof(payload.get(&"room_id")) not in [TYPE_STRING, TYPE_STRING_NAME] or typeof(payload.get(key, &"")) not in [TYPE_STRING, TYPE_STRING_NAME]:
report = PeepingRooms.result(&"INVALID_PAYLOAD")
elif command.command_type == &"peeping_room_relink":
report = peeping_room_service.relink(StringName(payload[&"room_id"]), StringName(payload.get(key, &"")))
else:
report = peeping_room_service.record_evidence(StringName(payload[&"room_id"]), StringName(payload.get(key, &"")), _runtime_event_minute())
if report[&"ok"]:
return CommandResult.succeeded(command.command_id, report)
return CommandResult.failed(CommandResult.Code.VALIDATION_FAILED, command.command_id, String(report[&"reason"]), report)
func _on_ledger_transaction_posted(transaction_id: StringName, _entries: Array) -> void:
if _operations_flushing_economy_notifications.has(transaction_id):
return