Chelimbalo/weapons/gun/idle_state.gd

24 lines
654 B
GDScript

extends WeaponState
@export var emptyable: bool
func _enter() -> void:
machine.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 ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)