P08-03-RTPREVIEW: P08-03を閉じるための共有配置プレビュー判定
This commit is contained in:
@@ -7573,18 +7573,38 @@ func _execute_leave_facility_queue(command: SimulationCommand) -> CommandResult:
|
||||
return CommandResult.failed(CommandResult.Code.TRANSACTION_APPLY_FAILED, command.command_id, failure_message)
|
||||
return CommandResult.succeeded(command.command_id, {&"request_id": request_id, &"reason": &"GUEST_LEFT"})
|
||||
|
||||
func _execute_build_facility(command: SimulationCommand) -> CommandResult:
|
||||
var operations_gate := _operations_construction_investment_gate(command.command_id)
|
||||
func preview_build_facility(definition_id: StringName, origin: Vector3i, rotation: int) -> Dictionary:
|
||||
var definition := definition_registry.get_facility(definition_id)
|
||||
var failure := _build_facility_precheck(0, {&"definition_id": definition_id, &"origin": origin, &"rotation": rotation})
|
||||
if failure != null and definition == null:
|
||||
var code := String(failure.details.get(&"reason", CommandResult.Code.keys()[failure.code]))
|
||||
return {&"can_build": false, &"error_codes": [code],
|
||||
&"reasons": [{&"code": code, &"message": failure.message, &"cells": [], &"details": failure.details.duplicate(true)}],
|
||||
&"cells": []}
|
||||
var report: Dictionary = construction_service.validate_placement(definition, origin, rotation).to_dictionary()
|
||||
if failure != null:
|
||||
report[&"can_build"] = false
|
||||
var code := String(failure.details.get(&"reason", CommandResult.Code.keys()[failure.code]))
|
||||
var codes: Array = Array(report.get(&"error_codes", []))
|
||||
var reasons: Array = Array(report.get(&"reasons", []))
|
||||
codes.push_front(code)
|
||||
reasons.push_front({&"code": code, &"message": failure.message, &"cells": [], &"details": failure.details.duplicate(true)})
|
||||
report[&"error_codes"] = codes
|
||||
report[&"reasons"] = reasons
|
||||
return report
|
||||
|
||||
func _build_facility_precheck(command_id: int, payload: Dictionary) -> CommandResult:
|
||||
var operations_gate := _operations_construction_investment_gate(command_id)
|
||||
if operations_gate != null:
|
||||
return operations_gate
|
||||
var definition_id := StringName(command.payload.get(&"definition_id", command.payload.get("definition_id", "")))
|
||||
var definition_id := StringName(payload.get(&"definition_id", payload.get("definition_id", "")))
|
||||
var definition := definition_registry.get_facility(definition_id)
|
||||
if definition == null:
|
||||
return CommandResult.failed(CommandResult.Code.NOT_FOUND, command.command_id, "Facility definition was not found.")
|
||||
return CommandResult.failed(CommandResult.Code.NOT_FOUND, command_id, "Facility definition was not found.")
|
||||
if _facility_definition_is_unsupported_vertical_proxy(definition):
|
||||
return CommandResult.failed(
|
||||
CommandResult.Code.VALIDATION_FAILED,
|
||||
command.command_id,
|
||||
command_id,
|
||||
"Vertical infrastructure topology is not supported.",
|
||||
{
|
||||
&"reason": FacilityInfrastructureProjector.REASON_UNSUPPORTED_VERTICAL_TOPOLOGY,
|
||||
@@ -7592,18 +7612,28 @@ func _execute_build_facility(command: SimulationCommand) -> CommandResult:
|
||||
&"unchanged": true,
|
||||
}
|
||||
)
|
||||
var origin_value: Variant = _parse_world_cell(command.payload.get(&"origin", command.payload.get("origin", null)))
|
||||
var origin_value: Variant = _parse_world_cell(payload.get(&"origin", payload.get("origin", null)))
|
||||
if origin_value == null:
|
||||
return CommandResult.failed(CommandResult.Code.INVALID_PAYLOAD, command.command_id, "origin must be Vector3i or [x, y, layer].")
|
||||
return CommandResult.failed(CommandResult.Code.INVALID_PAYLOAD, command_id, "origin must be Vector3i or [x, y, layer].")
|
||||
var origin: Vector3i = origin_value
|
||||
if definition.id in [&"guest_stairs", &"service_stairs"] and not path_service.has_cell(origin + Vector3i(0, -1, 0)):
|
||||
return _staff_assignment_failure(command.command_id, &"STAIR_LANDING_MISSING", "先に階段の一つ下の階に通路を作ってください。")
|
||||
return _staff_assignment_failure(command_id, &"STAIR_LANDING_MISSING", "先に階段の一つ下の階に通路を作ってください。")
|
||||
for shaft: Dictionary in elevators.get_report()[&"shafts"]:
|
||||
if _elevator_touches_module(shaft, definition, origin) and _elevator_shaft_busy(shaft):
|
||||
return _staff_assignment_failure(command.command_id, &"ELEVATOR_BUSY", "Wait until the shaft is idle before extending it.")
|
||||
var rotation := int(command.payload.get(&"rotation", command.payload.get("rotation", 0)))
|
||||
return _staff_assignment_failure(command_id, &"ELEVATOR_BUSY", "Wait until the shaft is idle before extending it.")
|
||||
var rotation := int(payload.get(&"rotation", payload.get("rotation", 0)))
|
||||
if rotation not in definition.allowed_rotations:
|
||||
return CommandResult.failed(CommandResult.Code.INVALID_PAYLOAD, command.command_id, "The selected rotation is not allowed.")
|
||||
return CommandResult.failed(CommandResult.Code.INVALID_PAYLOAD, command_id, "The selected rotation is not allowed.")
|
||||
return null
|
||||
|
||||
func _execute_build_facility(command: SimulationCommand) -> CommandResult:
|
||||
var failure := _build_facility_precheck(command.command_id, command.payload)
|
||||
if failure != null:
|
||||
return failure
|
||||
var definition_id := StringName(command.payload.get(&"definition_id", command.payload.get("definition_id", "")))
|
||||
var definition := definition_registry.get_facility(definition_id)
|
||||
var origin: Vector3i = _parse_world_cell(command.payload.get(&"origin", command.payload.get("origin", null)))
|
||||
var rotation := int(command.payload.get(&"rotation", command.payload.get("rotation", 0)))
|
||||
var result := construction_service.start_construction(
|
||||
definition,
|
||||
origin,
|
||||
|
||||
Reference in New Issue
Block a user