Weapon switch
This commit is contained in:
parent
b94e4cdf30
commit
e2540d8417
1 changed files with 13 additions and 1 deletions
|
|
@ -31,6 +31,9 @@ func _ready() -> void:
|
|||
player_input.drop.connect(drop_current)
|
||||
player_input.fire_begin.connect(use_begin)
|
||||
player_input.fire_end.connect(use_end)
|
||||
player_input.switch_weapon.connect(switch)
|
||||
player_input.alternate_state.connect(alternate_state)
|
||||
player_input.switch_firemode.connect(switch_mode)
|
||||
|
||||
func get_speed_modifier() -> float:
|
||||
if current_state == null:
|
||||
|
|
@ -68,8 +71,9 @@ func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = fa
|
|||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
state.enter.call_deferred()
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func switch(to: StringName, exit: bool = true):
|
||||
if slots.has(to) == false or slots[to] == null or slots[to] == current_state or is_multiplayer_authority() == false:
|
||||
if slots.has(to) == false or slots[to] == null or slots[to] == current_state or (multiplayer.get_remote_sender_id() != 1 and is_multiplayer_authority() == false):
|
||||
return
|
||||
if current_state != null and exit:
|
||||
current_state.exit()
|
||||
|
|
@ -82,6 +86,8 @@ func switch(to: StringName, exit: bool = true):
|
|||
|
||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
switched_to.emit(current_state)
|
||||
if is_multiplayer_authority():
|
||||
switch.rpc(to,exit)
|
||||
|
||||
func return_to_previous(exit: bool = true):
|
||||
if last_slot != "":
|
||||
|
|
@ -173,3 +179,9 @@ func use_begin() -> void:
|
|||
|
||||
func use_end() -> void:
|
||||
current_state.use_end.rpc()
|
||||
|
||||
func alternate_state() -> void:
|
||||
current_state.alternate_state()
|
||||
|
||||
func switch_mode() -> void:
|
||||
current_state.switch_mode()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue