diff --git a/src/actor.gd b/src/actor.gd index 7b6e695..b0f5ee4 100644 --- a/src/actor.gd +++ b/src/actor.gd @@ -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 diff --git a/src/state.gd b/src/state.gd index 5cbb5e7..8421250 100644 --- a/src/state.gd +++ b/src/state.gd @@ -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 diff --git a/src/state_animated_actor.gd b/src/state_animated_actor.gd index d477243..71d78ee 100644 --- a/src/state_animated_actor.gd +++ b/src/state_animated_actor.gd @@ -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: