From ac8ea51d9c4ad12240805f209c922e4484351b01 Mon Sep 17 00:00:00 2001 From: Rendo Date: Fri, 28 Nov 2025 22:04:55 +0500 Subject: [PATCH] Weapon system small refactor --- scripts/weapon_system/weapon_system.gd | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/weapon_system/weapon_system.gd b/scripts/weapon_system/weapon_system.gd index 8aca5a0..34e5a59 100644 --- a/scripts/weapon_system/weapon_system.gd +++ b/scripts/weapon_system/weapon_system.gd @@ -68,6 +68,21 @@ func switch(to: StringName, exit: bool = true): update_remotes.rpc(to,exit) +func return_to_previous(exit: bool = true): + if last_slot != "": + switch(last_slot, exit) + else: + switch("knife", exit) + +@rpc("authority","call_remote","reliable") +func update_remotes(to: StringName,exit: bool): + if current_state != null and exit: + current_state.exit() + current_state = slots[to] + current_state.enter() + + switched_to.emit(current_state) + func drop(): if slots.find_key(current_state) == "knife": return @@ -113,21 +128,6 @@ func pick_up_weapon(data: Variant) -> Node: return scene -func return_to_previous(exit: bool = true): - if last_slot != "": - switch(last_slot, exit) - else: - switch("knife", exit) - -@rpc("authority","call_remote","reliable") -func update_remotes(to: StringName,exit: bool): - if current_state != null and exit: - current_state.exit() - current_state = slots[to] - current_state.enter() - - switched_to.emit(current_state) - func _process(delta: float) -> void: if current_state == null: return