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,22 @@
|
||||
class_name CameraLookCommand
|
||||
extends RefCounted
|
||||
|
||||
var yaw_delta_radians: float
|
||||
var pitch_delta_radians: float
|
||||
var recenter_requested: bool
|
||||
|
||||
|
||||
func _init(
|
||||
p_yaw_delta_radians: float = 0.0,
|
||||
p_pitch_delta_radians: float = 0.0,
|
||||
p_recenter_requested: bool = false
|
||||
) -> void:
|
||||
yaw_delta_radians = p_yaw_delta_radians
|
||||
pitch_delta_radians = p_pitch_delta_radians
|
||||
recenter_requested = p_recenter_requested
|
||||
|
||||
|
||||
func validation_error() -> String:
|
||||
if not is_finite(yaw_delta_radians) or not is_finite(pitch_delta_radians):
|
||||
return "camera look deltas must be finite"
|
||||
return ""
|
||||
@@ -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)
|
||||
@@ -0,0 +1,16 @@
|
||||
class_name VehicleCollisionSample
|
||||
extends RefCounted
|
||||
|
||||
var sample_id: StringName
|
||||
var sequence: int
|
||||
var normal_impact_speed_mps: float
|
||||
|
||||
|
||||
func _init(
|
||||
p_sample_id: StringName,
|
||||
p_sequence: int,
|
||||
p_normal_impact_speed_mps: float
|
||||
) -> void:
|
||||
sample_id = p_sample_id
|
||||
sequence = p_sequence
|
||||
normal_impact_speed_mps = p_normal_impact_speed_mps
|
||||
@@ -0,0 +1,35 @@
|
||||
class_name VehicleCommand
|
||||
extends RefCounted
|
||||
|
||||
var sequence: int
|
||||
var longitudinal: float
|
||||
var steering: float
|
||||
var vertical: float
|
||||
var high_thrust_active: bool
|
||||
|
||||
|
||||
func _init(
|
||||
p_sequence: int,
|
||||
p_longitudinal: float,
|
||||
p_steering: float,
|
||||
p_vertical: float,
|
||||
p_high_thrust_active: bool
|
||||
) -> void:
|
||||
sequence = p_sequence
|
||||
longitudinal = p_longitudinal
|
||||
steering = p_steering
|
||||
vertical = p_vertical
|
||||
high_thrust_active = p_high_thrust_active
|
||||
|
||||
|
||||
func validation_error() -> String:
|
||||
if sequence < 0:
|
||||
return "vehicle command sequence is negative"
|
||||
for value: float in [longitudinal, steering, vertical]:
|
||||
if not is_finite(value) or value < -1.0 or value > 1.0:
|
||||
return "vehicle command axes must be finite and normalized"
|
||||
return ""
|
||||
|
||||
|
||||
static func neutral(p_sequence: int) -> VehicleCommand:
|
||||
return new(p_sequence, 0.0, 0.0, 0.0, false)
|
||||
@@ -0,0 +1,12 @@
|
||||
class_name VehicleCommandResult
|
||||
extends RefCounted
|
||||
|
||||
var accepted: bool
|
||||
var sequence: int
|
||||
var rejection_reason: String
|
||||
|
||||
|
||||
func _init(p_accepted: bool, p_sequence: int, p_rejection_reason: String = "") -> void:
|
||||
accepted = p_accepted
|
||||
sequence = p_sequence
|
||||
rejection_reason = p_rejection_reason
|
||||
Reference in new issue
Block a user