State machine rework

This commit is contained in:
Rendo 2025-12-09 22:34:17 +05:00
commit 87919ed890
25 changed files with 102 additions and 76 deletions

View file

@ -2,18 +2,19 @@ extends WeaponState
@export var emptyable: bool
func enter() -> void:
func _enter() -> void:
machine.animation_player.play(with_morphems("idle"))
machine.player.get_node("PlayerInput").reload.connect(init_reload)
if is_multiplayer_authority():
machine.player.get_node("PlayerInput").reload.connect(init_reload)
func exit() -> void:
machine.player.get_node("PlayerInput").reload.disconnect(init_reload)
func _exit() -> void:
if is_multiplayer_authority():
machine.player.get_node("PlayerInput").reload.disconnect(init_reload)
func use_begin() -> void:
func _use_begin() -> void:
if machine.ammo > 0:
transition.emit("Shoot")
@rpc("authority","call_local","reliable")
func init_reload():
if machine.ammo == machine.max_ammo or machine.remaining_ammo <= 0:
return

View file

@ -2,11 +2,11 @@ extends WeaponState
@export var emptyable: bool
func enter() -> void:
func _enter() -> void:
machine.animation_player.play(with_morphems("intro"))
machine.animation_player.animation_finished.connect(on_animation_finished)
func exit() -> void:
func _exit() -> void:
machine.animation_player.animation_finished.disconnect(on_animation_finished)
func on_animation_finished(animation):

View file

@ -2,11 +2,11 @@ extends WeaponState
@export var emptyable: bool
func enter() -> void:
func _enter() -> void:
machine.animation_player.play(with_morphems("reload"))
machine.animation_player.animation_finished.connect(on_animation_finished)
func exit() -> void:
func _exit() -> void:
machine.animation_player.animation_finished.disconnect(on_animation_finished)
func on_animation_finished(animation):

View file

@ -11,11 +11,11 @@ extends WeaponState
var bullets_shot: int = 0
func enter() -> void:
func _enter() -> void:
fire()
machine.animation_player.animation_finished.connect(on_animation_finished)
func exit() -> void:
func _exit() -> void:
bullets_shot = 0
machine.animation_player.animation_finished.disconnect(on_animation_finished)
@ -23,7 +23,7 @@ func on_animation_finished(animation):
if animation == with_morphems("shoot"):
transition.emit("Idle")
func use_begin() -> void:
func _use_begin() -> void:
if fire_timer.time_left > 0:
return
fire()