Weapon system small refactor

This commit is contained in:
Rendo 2025-11-28 22:04:55 +05:00
commit ac8ea51d9c

View file

@ -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