Weapon system small refactor
This commit is contained in:
parent
02842948ba
commit
ac8ea51d9c
1 changed files with 15 additions and 15 deletions
|
|
@ -68,6 +68,21 @@ func switch(to: StringName, exit: bool = true):
|
||||||
|
|
||||||
update_remotes.rpc(to,exit)
|
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():
|
func drop():
|
||||||
if slots.find_key(current_state) == "knife":
|
if slots.find_key(current_state) == "knife":
|
||||||
return
|
return
|
||||||
|
|
@ -113,21 +128,6 @@ func pick_up_weapon(data: Variant) -> Node:
|
||||||
|
|
||||||
return scene
|
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:
|
func _process(delta: float) -> void:
|
||||||
if current_state == null:
|
if current_state == null:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue