Skip to content

Commit

Permalink
feat: Optimizes animation commands (#446)
Browse files Browse the repository at this point in the history
Co-authored-by: Dennis Ploeger <[email protected]>
  • Loading branch information
dploeger and dploeger authored Nov 18, 2021
1 parent 294fc72 commit c9a6f80
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion addons/escoria-core/game/core-scripts/esc/commands/anim.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# without blocking. The next command in the event will be executed immediately
# after. Optional parameters:
#
# * reverse: plays the animation in reverse when true
# * `reverse`: plays the animation in reverse when true
#
# @ESC
extends ESCBaseCommand
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# `cut_scene object name [reverse]`
# `anim_block object name [reverse]`
#
# Executes the animation specificed with the "name" parameter on the object,
# blocking. The next command in the event will be executed when the animation
# is finished playing. Optional parameters:
#
# * reverse plays the animation in reverse when true
# * `reverse`: plays the animation in reverse when true
#
# @ESC
extends ESCBaseCommand
class_name CutSceneCommand
class_name AnimBlockCommand


# Return the descriptor of the arguments of this command
Expand All @@ -24,7 +24,7 @@ func configure() -> ESCCommandArgumentDescriptor:
func validate(arguments: Array):
if not escoria.object_manager.objects.has(arguments[0]):
escoria.logger.report_errors(
"anim: invalid object",
"anim_block.gd:validate",
[
"Object with global id %s not found." % arguments[0]
]
Expand Down
12 changes: 9 additions & 3 deletions addons/escoria-core/game/core-scripts/esc/commands/set_state.gd
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# `set_state object state [immediate]`
#
# Changes the state of an object, and executes the state animation if present.
# Changes the state of an object to the given state.
#
# If the associated animation player has an animation with the same name,
# it also plays that animation.
#
# The command can be used to change the appearance of an item or a player
# character.
# If `immediate` is set to true, the animation is run directly
# character. See https://docs.escoria-framework.org/states for details.
#
# If `immediate` is set to true, the animation is directly skipped to the last
# frame
#
# @ESC
extends ESCBaseCommand
Expand Down
6 changes: 6 additions & 0 deletions addons/escoria-core/game/core-scripts/esc_animation_player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ func seek_end(name: String):
#
# - name: Name of the animation played
func _on_animation_finished(name: String):
if _is_animation_player:
_animation_player.stop()
_animation_player.seek(0)
else:
_animated_sprite.stop()
_animated_sprite.frame = 0
emit_signal("animation_finished", name)


Expand Down
12 changes: 6 additions & 6 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ _global_script_classes=[ {
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/accept_input.gd"
}, {
"base": "ESCBaseCommand",
"class": "AnimBlockCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/anim_block.gd"
}, {
"base": "ESCBaseCommand",
"class": "AnimCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/anim.gd"
Expand Down Expand Up @@ -65,11 +70,6 @@ _global_script_classes=[ {
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/custom.gd"
}, {
"base": "ESCBaseCommand",
"class": "CutSceneCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/cut_scene.gd"
}, {
"base": "ESCBaseCommand",
"class": "DebugCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/debug.gd"
Expand Down Expand Up @@ -536,6 +536,7 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
"AcceptInputCommand": "",
"AnimBlockCommand": "",
"AnimCommand": "",
"CameraPushCommand": "",
"CameraSetLimitsCommand": "",
Expand All @@ -546,7 +547,6 @@ _global_script_class_icons={
"CameraShiftCommand": "",
"ChangeSceneCommand": "",
"CustomCommand": "",
"CutSceneCommand": "",
"DebugCommand": "",
"DecGlobalCommand": "",
"ESCActionManager": "",
Expand Down

0 comments on commit c9a6f80

Please sign in to comment.