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
+25
View File
@@ -0,0 +1,25 @@
class_name WeaponSlot
extends Node3D
@export var allowed_sizes: Array[WeaponDef.Size] = [WeaponDef.Size.MEDIUM]
@export var allowed_types: Array[WeaponDef.Type] = [WeaponDef.Type.BALLISTIC]
var weapon: Weapon = null # currently mounted, if any
func can_mount(def: WeaponDef) -> bool:
return def != null and def.weapon_scene != null \
and def.size in allowed_sizes and def.type in allowed_types
func mount(def: WeaponDef) -> bool:
if not can_mount(def):
return false
unmount()
weapon = def.weapon_scene.instantiate()
weapon.def = def
add_child(weapon)
return true
func unmount() -> void:
if weapon != null:
weapon.queue_free()
weapon = null