This commit is contained in:
2026-03-13 22:00:02 -05:00
parent 90241d6830
commit 6738e8d217
676 changed files with 15819 additions and 78 deletions

View File

@@ -1,8 +1,12 @@
extends Node2D
signal DrawingBowAnimationFinished
signal FiringArrowAnimationFinished
@export var state_machine: PlayerStateMachine
@export var direction_component: FacingDirectionComponent
@onready var full: AnimatedSprite2D = $Full
@onready var base: AnimatedSprite2D = $Base
@onready var hair: AnimatedSprite2D = $Hair
@onready var pants: AnimatedSprite2D = $Pants
@@ -15,7 +19,7 @@ var is_flipped := false
# Public Methods
func UpdateSprite() -> void:
var current_state := state_machine.GetCurrentState()
var current_state := state_machine.current_state
var current_direction := direction_component.GetCurrentDirection()
var animation := _build_animation_name(current_state, current_direction)
var should_flip := _should_flip_horizontal()
@@ -31,18 +35,26 @@ func UpdateSprite() -> void:
part.play()
part.flip_h = should_flip
func OnAnimationFinished() -> void:
if current_animation.begins_with("drawing-bow-"):
DrawingBowAnimationFinished.emit()
elif current_animation.begins_with("firing-arrow-"):
FiringArrowAnimationFinished.emit()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
all_parts = [
base, hair, pants, hands, shoes
full, #base, hair, pants, hands, shoes
]
UpdateSprite()
func _build_animation_name(state: PlayerStateMachine.States, direction: Enums.Directions) -> String:
func _build_animation_name(state: BaseState, direction: Enums.Directions) -> String:
# e.g. "idle-down", "walking-up"
var state_str = PlayerStateMachine.States.keys()[state].to_lower()
var state_str = state.GetAnimationBaseName().replace("_", "-")
var direction_str = _direction_to_animation_state(direction)
return "%s-%s" % [state_str, direction_str]