Implement production vertical slice foundation
This commit is contained in:
1 parent
9d4a89f355
commit
a18e82eb44
104 files changed
+10595
-268
No files matched your search
@@ -0,0 +1,32 @@
|
||||
class_name PilotUseCase
|
||||
extends RefCounted
|
||||
|
||||
const VehicleCommand = preload("res://game/application/vehicle/vehicle_command.gd")
|
||||
const VehicleCommandResult = preload(
|
||||
"res://game/application/vehicle/vehicle_command_result.gd"
|
||||
)
|
||||
const VehicleMotionPort = preload("res://game/application/interfaces/vehicle_motion_port.gd")
|
||||
|
||||
var _motion_port: VehicleMotionPort
|
||||
var _last_sequence := -1
|
||||
|
||||
|
||||
func _init(motion_port: VehicleMotionPort) -> void:
|
||||
_motion_port = motion_port
|
||||
|
||||
|
||||
func execute(command: VehicleCommand) -> VehicleCommandResult:
|
||||
if command == null:
|
||||
return VehicleCommandResult.new(false, -1, "vehicle command is missing")
|
||||
var error: String = command.validation_error()
|
||||
if not error.is_empty():
|
||||
return VehicleCommandResult.new(false, command.sequence, error)
|
||||
if command.sequence != _last_sequence + 1:
|
||||
return VehicleCommandResult.new(
|
||||
false,
|
||||
command.sequence,
|
||||
"vehicle command sequence is not consecutive"
|
||||
)
|
||||
_motion_port.apply_command(command)
|
||||
_last_sequence = command.sequence
|
||||
return VehicleCommandResult.new(true, command.sequence)
|
||||
Reference in new issue
Block a user