feat: Optimizes animation commands (#446)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-11-18 20:01:03 +01:00
committed by GitHub
parent 294fc72840
commit c9a6f802c7
5 changed files with 26 additions and 14 deletions

View File

@@ -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

View File

@@ -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
@@ -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]
]

View File

@@ -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

View File

@@ -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)

View File

@@ -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"
@@ -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"
@@ -536,6 +536,7 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
"AcceptInputCommand": "",
"AnimBlockCommand": "",
"AnimCommand": "",
"CameraPushCommand": "",
"CameraSetLimitsCommand": "",
@@ -546,7 +547,6 @@ _global_script_class_icons={
"CameraShiftCommand": "",
"ChangeSceneCommand": "",
"CustomCommand": "",
"CutSceneCommand": "",
"DebugCommand": "",
"DecGlobalCommand": "",
"ESCActionManager": "",