This commit is contained in:
bee
2026-07-10 17:26:23 +02:00
parent db201081f5
commit 90bae5f3e5
14 changed files with 308 additions and 9 deletions
+19 -3
View File
@@ -10,12 +10,13 @@ extends FloatingBody
@export var loadout: Dictionary[StringName, WeaponDef] = {} # WeaponSlot Name -> WeaponDef
@export var weapon_groups: Dictionary[int, Array] = {} # group id -> slot names; group 0 is auto-built (all slots), editor value ignored
var desired_throttle := 0.0 # move_toward target for actual throttle
var steer_input := 0.0
var throttle := 0.0 # current throttle state of ship
var desired_throttle := 0.0 # written by controller, move_toward target for actual throttle
var steer_input := 0.0 # written by controllers
var throttle := 0.0 # current throttle state of ship
var _slots: Array[WeaponSlot] = []
var _slots_by_name: Dictionary[StringName, WeaponSlot] = {}
var fire_intents: Dictionary[int, bool] = {} # written by controllers, like steer_input
var aim_point = null # Vector3 or null — written by controllers, like steer_input
func _ready() -> void:
super()
@@ -38,8 +39,11 @@ func _ready() -> void:
func _physics_process(delta: float) -> void:
super(delta)
# Propulsion
throttle = move_toward(throttle, desired_throttle, throttle_response * delta)
# Weapons
_process_aim(delta)
_process_fire()
if submerged_ratio <= 0.0:
@@ -74,3 +78,15 @@ func _process_fire() -> void:
var slot: WeaponSlot = _slots_by_name.get(slot_name)
if slot != null and slot.weapon != null:
slot.weapon.try_fire()
func _process_aim(delta: float) -> void:
for slot in _slots:
if slot.weapon != null:
slot.weapon.aim_at(aim_point, delta)
func aim_ray_exclusions() -> Array[RID]:
var rids: Array[RID] = [get_rid()]
for slot in _slots:
if slot.weapon != null and slot.weapon.hitbox != null:
rids.append(slot.weapon.hitbox.get_rid())
return rids