Chelimbalo/scripts/player/player_pickup.gd
2025-11-28 19:39:31 +05:00

33 lines
814 B
GDScript

extends Area3D
@export var weapon_spawner: MultiplayerSpawner
@export var weapon_system: WeaponSystem
func _ready() -> void:
if is_multiplayer_authority() == false: return
body_entered.connect(on_body_entered)
func on_body_entered(body: Node3D):
if body is DroppableWeapon:
if weapon_system.can_add(body.slot) == false:
return
weapon_spawner.spawn({
"ammo": body.weapon.ammo,
"remaining_ammo": body.weapon.remaining_ammo,
"scene_file_path": body.weapon.scene_file_path,
"slot": body.slot
})
Session.despawn(body.get_path())
func start_temp_ignore():
if is_multiplayer_authority() == false:
return
monitoring = false
get_tree().create_timer(0.5).timeout.connect(stop_temp_ignore)
func stop_temp_ignore():
if is_multiplayer_authority() == false:
return
monitoring = true