weapon slots and loadout done
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user