weapon slots and loadout done

This commit is contained in:
bee
2026-07-07 23:04:20 +02:00
parent a40d0bfdd3
commit c4f2c0a202
21 changed files with 227 additions and 3 deletions
+17 -1
View File
@@ -7,10 +7,21 @@ extends FloatingBody
@export var throttle_response := 1.5 # how fast the engine spools up/down
@export var rudder_strength := 2.5 # turning torque at speed
@export var keel_grip := 3.0 # resistance to sliding sideways
@export var loadout: Dictionary[StringName, WeaponDef] = {}
var desired_throttle := 0.0 # move_toward target for actual throttle
var steer_input := 0.0
var throttle := 0.0
var throttle := 0.0 # current throttle state of ship
var _slots: Array[WeaponSlot] = []
func _ready() -> void:
super()
for child in get_children():
if child is WeaponSlot:
_slots.append(child)
var def: WeaponDef = loadout.get(child.name)
if def != null:
child.mount(def)
func _physics_process(delta: float) -> void:
super(delta)
@@ -40,3 +51,8 @@ func _physics_process(delta: float) -> void:
right = right.normalized()
var lateral_speed := linear_velocity.dot(right)
apply_central_force(-right * lateral_speed * keel_grip * mass * submerged_ratio)
func fire_weapons() -> void:
for slot in _slots:
if slot.weapon != null:
slot.weapon.try_fire()