Trying out signals emmitted by states since i'm still stuck and the states and everything else are part of the same scene.
This commit is contained in:
parent
2ccd8bcb8b
commit
85907a32b7
|
|
@ -9,6 +9,7 @@ export(String, "Player", "Enemy", "NPC") var actor_type
|
|||
export(Array, Resource) var SoundEffects
|
||||
export var debug_actor: bool = false
|
||||
|
||||
|
||||
onready var movement_animations: AnimatedSprite = $AnimatedSprite
|
||||
|
||||
onready var sound_effect_player: AudioStreamPlayer = $SE_Player
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ extends Node
|
|||
export var debug_state: bool = false
|
||||
export var timeout_seconds: float = 0.0
|
||||
|
||||
signal state_entered()
|
||||
signal state_exited()
|
||||
signal frame_reached(state_name, animation_name, frame_number)
|
||||
export(Dictionary) var emitter_frame_subscriptions
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
var modifier_stack_ref: Array # Well this didn't work
|
||||
var state_timeout: Timer
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ func enter() -> void:
|
|||
if debug_state:
|
||||
print(parent.name, " entering State: ", self.name)
|
||||
move_component.current_movement_state = self.name
|
||||
emit_signal("state_entered")
|
||||
#modifier_stack_ref = state_modifiers
|
||||
if modifier_stack_ref.empty() == false:
|
||||
if modifier_stack_ref[-1].animation_name != '':
|
||||
|
|
@ -78,8 +79,9 @@ func enter() -> void:
|
|||
return
|
||||
|
||||
func exit() -> void:
|
||||
emit_signal("state_exited")
|
||||
# animations.disconnect("animation_finished", self, "_on_AnimatedSprite_animation_finished")
|
||||
pass
|
||||
return
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
return null
|
||||
|
|
@ -92,6 +94,9 @@ func process_frame(_delta: float) -> State:
|
|||
animations.play(animation_sequence[animation_index] + animation_suffix)
|
||||
print("An animation sequence: ", animations.animation , animation_index)
|
||||
current_animation_sequence = animation_index
|
||||
if emitter_frame_subscriptions.has(animations.frame):
|
||||
if emitter_frame_subscriptions[animations.frame] == animations.animation:
|
||||
emit_signal("frame_reached", self.name, animations.animation, animations.frame)
|
||||
return null
|
||||
|
||||
func process_physics(_delta: float) -> State:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user