36 lines
1013 B
GDScript
36 lines
1013 B
GDScript
class_name SitePlacement
|
|
extends Resource
|
|
|
|
enum Kind {
|
|
WRECK_TARGET,
|
|
WRECK_DECOY,
|
|
SECONDARY_ITEM,
|
|
DEBRIS,
|
|
LANDMARK,
|
|
VESSEL_ANCHOR,
|
|
}
|
|
|
|
@export var placement_id: StringName
|
|
@export var kind: Kind = Kind.LANDMARK
|
|
@export var position_m: Vector3 = Vector3.ZERO
|
|
@export var yaw_radians: float = 0.0
|
|
@export var footprint_m: Vector3 = Vector3.ZERO
|
|
|
|
|
|
func is_sonar_metal() -> bool:
|
|
return kind in [Kind.WRECK_TARGET, Kind.WRECK_DECOY, Kind.SECONDARY_ITEM, Kind.DEBRIS]
|
|
|
|
|
|
func validation_error() -> String:
|
|
if placement_id.is_empty():
|
|
return "placement id is empty"
|
|
if not (is_finite(position_m.x) and is_finite(position_m.y) and is_finite(position_m.z)):
|
|
return "placement position must be finite"
|
|
if not is_finite(yaw_radians):
|
|
return "placement yaw must be finite"
|
|
if footprint_m.x < 0.0 or footprint_m.y < 0.0 or footprint_m.z < 0.0:
|
|
return "placement footprint must not be negative"
|
|
if is_sonar_metal() and footprint_m.length_squared() == 0.0:
|
|
return "sonar bodies need a footprint"
|
|
return ""
|