State machine rework
This commit is contained in:
parent
3f99f1b8dd
commit
87919ed890
25 changed files with 102 additions and 76 deletions
|
|
@ -1,12 +1,12 @@
|
|||
extends WeaponState
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix+"idle")
|
||||
|
||||
func exit() -> void:
|
||||
func _exit() -> void:
|
||||
pass
|
||||
|
||||
func use_begin() -> void:
|
||||
func _use_begin() -> void:
|
||||
if Session.is_on_site(machine.player.player_id):
|
||||
transition.emit("Plant")
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends WeaponState
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix+"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: StringName):
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ extends WeaponState
|
|||
|
||||
@export var bomb_scene: PackedScene
|
||||
|
||||
func enter():
|
||||
func _enter():
|
||||
machine.animation_player.play(machine.animation_prefix+"plant")
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
if is_multiplayer_authority():
|
||||
machine.speed_modifier = 0.0
|
||||
machine.player.get_node("PlantAudio").multiplayer_play()
|
||||
|
||||
func exit():
|
||||
func _exit():
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
machine.speed_modifier = 1.0
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ extends WeaponState
|
|||
@export var damage: int
|
||||
var end_it: bool = true
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix + "attack")
|
||||
attack()
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
|
||||
func exit() -> void:
|
||||
func _exit() -> void:
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
end_it = false
|
||||
|
||||
|
|
@ -24,8 +24,8 @@ func on_animation_finished(animation):
|
|||
attack()
|
||||
machine.animation_player.play(machine.animation_prefix + "attack")
|
||||
|
||||
func use_begin() -> void:
|
||||
func _use_begin() -> void:
|
||||
end_it = false
|
||||
|
||||
func use_end() -> void:
|
||||
func _use_end() -> void:
|
||||
end_it = true
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ extends WeaponState
|
|||
|
||||
@export var damage: int
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix + "heavy_attack")
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
attack()
|
||||
|
||||
func exit() -> void:
|
||||
func _exit() -> void:
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
||||
func attack() -> void:
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
extends WeaponState
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix + "idle")
|
||||
|
||||
func exit() -> void:
|
||||
func _exit() -> void:
|
||||
pass
|
||||
|
||||
func use_begin() -> void:
|
||||
func _use_begin() -> void:
|
||||
transition.emit("Attack")
|
||||
|
||||
func alternate_state() -> void:
|
||||
func _alternate_state() -> void:
|
||||
transition.emit("HeavyAttack")
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends WeaponState
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix + "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):
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends WeaponState
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix +"idle")
|
||||
|
||||
func exit() -> void:
|
||||
func _exit() -> void:
|
||||
pass
|
||||
|
||||
func use_begin() -> void:
|
||||
func _use_begin() -> void:
|
||||
if machine.ammo > 0:
|
||||
transition.emit("Throw")
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ extends WeaponState
|
|||
|
||||
@export var emptyable: bool
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix + "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):
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ extends WeaponState
|
|||
|
||||
const molik: PackedScene = preload("uid://b6qahd6q60js7")
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
fire()
|
||||
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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue