38 lines
882 B
GDScript
38 lines
882 B
GDScript
extends Area3D
|
|
|
|
@export var weapon_system: WeaponSystem
|
|
var disabled: bool
|
|
|
|
func _ready() -> void:
|
|
if is_multiplayer_authority() == false: return
|
|
|
|
body_entered.connect(on_body_entered)
|
|
|
|
func disable() -> void:
|
|
disabled = true
|
|
|
|
func on_body_entered(body: Node3D):
|
|
if disabled:
|
|
return
|
|
if body is DroppableWeapon:
|
|
if weapon_system.can_add(body.slot) == false or (body.team != Session.TEAMS.UNASSIGNED and get_parent().team != body.team):
|
|
return
|
|
var weapon: WeaponSubStateMachine = body.weapon.duplicate()
|
|
weapon_system.add(weapon,weapon.slot)
|
|
|
|
body.queue_free()
|
|
|
|
func start_temp_ignore():
|
|
if disabled:
|
|
return
|
|
if is_multiplayer_authority() == false:
|
|
return
|
|
monitoring = false
|
|
get_tree().create_timer(0.5).timeout.connect(stop_temp_ignore)
|
|
|
|
func stop_temp_ignore():
|
|
if disabled:
|
|
return
|
|
if is_multiplayer_authority() == false:
|
|
return
|
|
monitoring = true
|