24 lines
698 B
GDScript
24 lines
698 B
GDScript
extends WeaponState
|
|
|
|
@export var emptyable: bool
|
|
|
|
func _enter() -> void:
|
|
machine.animation_player.play(with_morphems("idle"))
|
|
if is_multiplayer_authority():
|
|
machine.player.get_node("PlayerInput").reload.connect(init_reload)
|
|
|
|
func _exit() -> void:
|
|
if is_multiplayer_authority():
|
|
machine.player.get_node("PlayerInput").reload.disconnect(init_reload)
|
|
|
|
func _use_begin() -> void:
|
|
if machine.ammo > 0:
|
|
transition.emit("Shoot")
|
|
|
|
func init_reload():
|
|
if machine.ammo == machine.max_ammo or machine.remaining_ammo <= 0:
|
|
return
|
|
transition.emit("Reload")
|
|
|
|
func with_morphems(animation):
|
|
return machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|