diff --git a/addons/escoria-core/game/core-scripts/esc/commands/accept_input.gd b/addons/escoria-core/game/core-scripts/esc/commands/accept_input.gd index 1a4ce389..46c20b1c 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/accept_input.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/accept_input.gd @@ -59,3 +59,9 @@ func run(command_params: Array) -> int: escoria.inputs_manager.input_mode = mode return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/anim.gd b/addons/escoria-core/game/core-scripts/esc/commands/anim.gd index 8c0f7468..0d3ca5e7 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/anim.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/anim.gd @@ -52,3 +52,13 @@ func run(command_params: Array) -> int: else: animator.play(anim_id) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/anim_block.gd b/addons/escoria-core/game/core-scripts/esc/commands/anim_block.gd index 5f9c6c96..eab773e4 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/anim_block.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/anim_block.gd @@ -58,3 +58,13 @@ func run(command_params: Array) -> int: while animation_finished != anim_id: animation_finished = yield(animator, "animation_finished") return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd index 67eeff4c..b5ada507 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd @@ -77,3 +77,13 @@ func run(command_params: Array) -> int: Tween.new().get("TRANS_%s" % command_params[2]) ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_limits.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_limits.gd index 92106128..e7588f14 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_limits.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_limits.gd @@ -51,3 +51,13 @@ func validate(arguments: Array): func run(command_params: Array) -> int: escoria.main.set_camera_limits(command_params[0]) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_pos.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_pos.gd index 90a9e2df..e7c902e2 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_pos.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_pos.gd @@ -32,3 +32,13 @@ func run(command_params: Array) -> int: command_params[0] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_target.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_target.gd index 88ad86bb..15f7d985 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_target.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_target.gd @@ -51,3 +51,13 @@ func run(command_params: Array) -> int: command_params[0] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom.gd index 285a65e9..419f68d0 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom.gd @@ -36,3 +36,13 @@ func run(command_params: Array) -> int: command_params[1] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom_height.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom_height.gd index 3d5d1347..c7e1d1d2 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom_height.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom_height.gd @@ -49,3 +49,13 @@ func run(command_params: Array) -> int: command_params[1] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd index 827ba97a..45f51f88 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd @@ -69,3 +69,13 @@ func validate(arguments: Array): return false return true + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd b/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd index 499e8f57..6978aa78 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd @@ -64,3 +64,13 @@ func run(command_params: Array) -> int: escoria.room_manager.change_scene(command_params[0], command_params[1]) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/custom.gd b/addons/escoria-core/game/core-scripts/esc/commands/custom.gd index c8af83f9..84cc6767 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/custom.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/custom.gd @@ -83,3 +83,13 @@ func run(command_params: Array) -> int: command_params[3] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + get_command_name(), + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/dec_global.gd b/addons/escoria-core/game/core-scripts/esc/commands/dec_global.gd index 6b560215..07dc2633 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/dec_global.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/dec_global.gd @@ -45,3 +45,9 @@ func run(command_params: Array) -> int: command_params[1] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd b/addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd index d43c2523..2b4fc227 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd @@ -43,3 +43,9 @@ func run(command_params: Array) -> int: ] ) return ESCExecution.RC_ERROR + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd b/addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd index 3b821d76..eea480e2 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd @@ -77,3 +77,9 @@ func run(command_params: Array) -> int: pass return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd b/addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd index da046271..a3660b16 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd @@ -53,3 +53,9 @@ func run(command_params: Array) -> int: command_params[1] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/inventory_add.gd b/addons/escoria-core/game/core-scripts/esc/commands/inventory_add.gd index cf9a5961..e31d13bc 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/inventory_add.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/inventory_add.gd @@ -42,3 +42,9 @@ func validate(arguments: Array): func run(command_params: Array) -> int: escoria.inventory_manager.add_item(command_params[0]) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/inventory_remove.gd b/addons/escoria-core/game/core-scripts/esc/commands/inventory_remove.gd index 23f9f282..8c11dc0c 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/inventory_remove.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/inventory_remove.gd @@ -26,3 +26,9 @@ func configure() -> ESCCommandArgumentDescriptor: func run(command_params: Array) -> int: escoria.inventory_manager.remove_item(command_params[0]) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd b/addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd index b4ca57eb..ef9272ce 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd @@ -14,6 +14,10 @@ extends ESCBaseCommand class_name PlaySndCommand +# The specified sound player +var _snd_player: String + + # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( @@ -40,6 +44,7 @@ func validate(arguments: Array): ["File %s not found" % arguments[0]] ) return false + _snd_player = arguments[1] return true @@ -49,3 +54,8 @@ func run(command_params: Array) -> int: command_params[0] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.object_manager.get_object(_snd_player).node.set_state("off") diff --git a/addons/escoria-core/game/core-scripts/esc/commands/print.gd b/addons/escoria-core/game/core-scripts/esc/commands/print.gd index 1403e3f3..e550535f 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/print.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/print.gd @@ -26,3 +26,9 @@ func run(command_params: Array) -> int: # Replace the names of any globals in "{ }" with their value print(escoria.logger.replace_globals(command_params[0])) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/queue_event.gd b/addons/escoria-core/game/core-scripts/esc/commands/queue_event.gd index 5dd37b7a..08511376 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/queue_event.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/queue_event.gd @@ -82,3 +82,9 @@ func run(arguments: Array) -> int: arguments[2], # channel name arguments[3] # whether to block ) + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/queue_resource.gd b/addons/escoria-core/game/core-scripts/esc/commands/queue_resource.gd index 00200609..b9dc594d 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/queue_resource.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/queue_resource.gd @@ -43,3 +43,9 @@ func run(command_params: Array) -> int: command_params[1] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/rand_global.gd b/addons/escoria-core/game/core-scripts/esc/commands/rand_global.gd index 0d4056d0..c7bcc240 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/rand_global.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/rand_global.gd @@ -32,3 +32,9 @@ func run(command_params: Array) -> int: rnd ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/repeat.gd b/addons/escoria-core/game/core-scripts/esc/commands/repeat.gd index ad35098e..26990be3 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/repeat.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/repeat.gd @@ -20,3 +20,9 @@ func configure() -> ESCCommandArgumentDescriptor: # Run the command func run(command_params: Array) -> int: return ESCExecution.RC_CANCEL + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/say.gd b/addons/escoria-core/game/core-scripts/esc/commands/say.gd index 7d1aa4da..4c2bed58 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/say.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/say.gd @@ -111,3 +111,13 @@ func run(command_params: Array) -> int: yield(escoria.dialog_player, "say_finished") escoria.current_state = escoria.GAME_STATE.DEFAULT return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + "say", + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/sched_event.gd b/addons/escoria-core/game/core-scripts/esc/commands/sched_event.gd index 0c1ceeae..1847c65e 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/sched_event.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/sched_event.gd @@ -62,3 +62,9 @@ func run(command_params: Array) -> int: command_params[0] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_active.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_active.gd index cf699884..b00c6974 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_active.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_active.gd @@ -43,3 +43,9 @@ func run(command_params: Array) -> int: escoria.object_manager.get_object(command_params[0]).active = \ command_params[1] return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_active_if_exists.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_active_if_exists.gd index a5e69b56..dbf2149c 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_active_if_exists.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_active_if_exists.gd @@ -33,3 +33,9 @@ func run(command_params: Array) -> int: escoria.object_manager.get_object(command_params[0]).active = \ command_params[1] return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_angle.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_angle.gd index 5eb03136..d50b7fa3 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_angle.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_angle.gd @@ -55,3 +55,9 @@ func run(command_params: Array) -> int: ) return ESCExecution.RC_OK + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass + diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_animations.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_animations.gd index 111c2e66..50d0ade2 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_animations.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_animations.gd @@ -68,3 +68,9 @@ func run(command_params: Array) -> int: ) return ESCExecution.RC_OK + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass + diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_global.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_global.gd index 282a271c..e7ecb191 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_global.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_global.gd @@ -33,3 +33,9 @@ func run(command_params: Array) -> int: command_params[2] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_globals.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_globals.gd index d47cba44..a4b91166 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_globals.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_globals.gd @@ -30,3 +30,9 @@ func run(command_params: Array) -> int: command_params[1] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_gui_visible.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_gui_visible.gd index 8914983b..dcc1e696 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_gui_visible.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_gui_visible.gd @@ -27,3 +27,9 @@ func run(command_params: Array) -> int: else: escoria.main.current_scene.game.hide_ui() return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_interactive.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_interactive.gd index 596f45fd..034bc603 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_interactive.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_interactive.gd @@ -42,3 +42,9 @@ func run(command_params: Array) -> int: escoria.object_manager.get_object(command_params[0]).interactive = \ command_params[1] return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_speed.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_speed.gd index 61a4ccde..6443e446 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_speed.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_speed.gd @@ -40,3 +40,9 @@ func run(command_params: Array) -> int: (escoria.object_manager.get_object(command_params[0]).node as ESCItem).\ set_speed(command_params[1]) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_state.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_state.gd index db8f35bb..350356f8 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_state.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_state.gd @@ -51,3 +51,9 @@ func run(command_params: Array) -> int: command_params[2] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd b/addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd index 0d772a8d..6cd6eec0 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd @@ -81,3 +81,9 @@ func run(command_params: Array) -> int: escoria.game_scene.pause_game() return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/slide.gd b/addons/escoria-core/game/core-scripts/esc/commands/slide.gd index 0bb546eb..f8d90289 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/slide.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/slide.gd @@ -109,3 +109,9 @@ func run(command_params: Array) -> int: command_params[2] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + for tween in _tweens: + tween.stop_all() diff --git a/addons/escoria-core/game/core-scripts/esc/commands/slide_block.gd b/addons/escoria-core/game/core-scripts/esc/commands/slide_block.gd index 980675ec..c88b616f 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/slide_block.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/slide_block.gd @@ -25,3 +25,8 @@ func run(command_params: Array) -> int: ) yield(tween, "tween_all_completed") return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + .interrupt() diff --git a/addons/escoria-core/game/core-scripts/esc/commands/spawn.gd b/addons/escoria-core/game/core-scripts/esc/commands/spawn.gd index 054a2039..b3a2890c 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/spawn.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/spawn.gd @@ -91,3 +91,9 @@ func run(command_params: Array) -> int: ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/stop.gd b/addons/escoria-core/game/core-scripts/esc/commands/stop.gd index 8cbb7cd8..c1264843 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/stop.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/stop.gd @@ -19,3 +19,9 @@ func configure() -> ESCCommandArgumentDescriptor: # Run the command func run(command_params: Array) -> int: return ESCExecution.RC_CANCEL + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/stop_snd.gd b/addons/escoria-core/game/core-scripts/esc/commands/stop_snd.gd index 1d417e4d..5eecf1a2 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/stop_snd.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/stop_snd.gd @@ -13,6 +13,13 @@ extends ESCBaseCommand class_name StopSndCommand +# The specified sound player +var _snd_player: String + +# The previous sound state, saved for interrupting +var previous_snd_state: String + + # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( @@ -30,15 +37,24 @@ func validate(arguments: Array): if not escoria.object_manager.has(arguments[0]): escoria.logger.report_errors( "stop_snd: invalid sound player", - ["Sound player %s not registered" % arguments[1]] + ["Sound player %s not registered" % arguments[0]] ) return false + _snd_player = arguments[0] return true # Run the command func run(command_params: Array) -> int: + previous_snd_state = escoria.object_manager.get_object(command_params[0]).node.state escoria.object_manager.get_object(command_params[0]).node.set_state( "off" ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.object_manager.get_object(_snd_player).node.set_state( + previous_snd_state + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/teleport.gd b/addons/escoria-core/game/core-scripts/esc/commands/teleport.gd index a6da5da1..97f2a9c7 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/teleport.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/teleport.gd @@ -53,3 +53,9 @@ func run(command_params: Array) -> int: escoria.object_manager.get_object(command_params[1]).node ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/teleport_pos.gd b/addons/escoria-core/game/core-scripts/esc/commands/teleport_pos.gd index 253d625f..cd21ee2f 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/teleport_pos.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/teleport_pos.gd @@ -44,3 +44,9 @@ func run(command_params: Array) -> int: Vector2(int(command_params[1]), int(command_params[2])) ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/transition.gd b/addons/escoria-core/game/core-scripts/esc/commands/transition.gd index 358c9535..fa043bd6 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/transition.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/transition.gd @@ -72,3 +72,9 @@ func run(command_params: Array) -> int: escoria.logger.debug("Ending transition #%s [%s, %s]" % [transition_id, command_params[0], command_params[1]]) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/addons/escoria-core/game/core-scripts/esc/commands/turn_to.gd b/addons/escoria-core/game/core-scripts/esc/commands/turn_to.gd index 1aa2789f..4aab04fe 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/turn_to.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/turn_to.gd @@ -61,3 +61,13 @@ func run(command_params: Array) -> int: command_params[2] ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + escoria.logger.report_warnings( + "turn_to", + [ + "Interrupt() function not implemented" + ] + ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/wait.gd b/addons/escoria-core/game/core-scripts/esc/commands/wait.gd index 9d712992..40f4ede1 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/wait.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/wait.gd @@ -10,6 +10,9 @@ extends ESCBaseCommand class_name WaitCommand +# Timer to wait for +var timer: Timer + # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: @@ -40,5 +43,15 @@ func validate(arguments: Array): # Run the command func run(command_params: Array) -> int: - yield(escoria.get_tree().create_timer(float(command_params[0])), "timeout") + timer = Timer.new() + timer.wait_time = float(command_params[0]) + escoria.add_child(timer) + timer.start() + yield(timer, "timeout") + escoria.remove_child(timer) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + timer.emit_signal("timeout") diff --git a/addons/escoria-core/game/core-scripts/esc/commands/walk.gd b/addons/escoria-core/game/core-scripts/esc/commands/walk.gd index 2318ad15..a825d31c 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/walk.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/walk.gd @@ -16,6 +16,13 @@ extends ESCBaseCommand class_name WalkCommand +# Walking object +var walking_object_node: ESCItem + +# Target object +var target_object_node: ESCObject + + # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( @@ -46,6 +53,11 @@ func validate(arguments: Array): ] ) return false + + walking_object_node = (escoria.object_manager.get_object( + arguments[0]).node as ESCItem + ) + target_object_node = escoria.object_manager.get_object(arguments[1]) return true @@ -56,3 +68,8 @@ func run(command_params: Array) -> int: command_params ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + walking_object_node.stop_walking_now() diff --git a/addons/escoria-core/game/core-scripts/esc/commands/walk_block.gd b/addons/escoria-core/game/core-scripts/esc/commands/walk_block.gd index ba34974e..b36da888 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/walk_block.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/walk_block.gd @@ -16,6 +16,13 @@ extends ESCBaseCommand class_name WalkBlockCommand +# Walking object +var walking_object_node: ESCItem + +# Target object +var target_object_node: ESCObject + + # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( @@ -46,6 +53,11 @@ func validate(arguments: Array): ] ) return false + + walking_object_node = (escoria.object_manager.get_object( + arguments[0]).node as ESCItem + ) + target_object_node = escoria.object_manager.get_object(arguments[1]) return true @@ -55,8 +67,11 @@ func run(command_params: Array) -> int: escoria.action_manager.ACTION.BACKGROUND_CLICK, command_params ) - yield( - (escoria.object_manager.get_object(command_params[0]).node as ESCItem), - "arrived" - ) + yield(walking_object_node, "arrived") return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + if not walking_object_node is ESCPlayer: + walking_object_node.stop_walking_now() diff --git a/addons/escoria-core/game/core-scripts/esc/commands/walk_to_pos.gd b/addons/escoria-core/game/core-scripts/esc/commands/walk_to_pos.gd index 639390a5..6f50c9fc 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/walk_to_pos.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/walk_to_pos.gd @@ -18,6 +18,10 @@ extends ESCBaseCommand class_name WalkToPosCommand +# Walking object +var walking_object_node: ESCItem + + # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( @@ -40,6 +44,10 @@ func validate(arguments: Array): ] ) return false + + walking_object_node = (escoria.object_manager.get_object( + arguments[0]).node as ESCItem + ) return true @@ -50,3 +58,9 @@ func run(command_params: Array) -> int: Vector2(command_params[1], command_params[2]), command_params[3] ]) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + if not walking_object_node is ESCPlayer: + walking_object_node.stop_walking_now() diff --git a/addons/escoria-core/game/core-scripts/esc/commands/walk_to_pos_block.gd b/addons/escoria-core/game/core-scripts/esc/commands/walk_to_pos_block.gd index 3861d873..2f7abbfe 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/walk_to_pos_block.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/walk_to_pos_block.gd @@ -18,6 +18,10 @@ extends ESCBaseCommand class_name WalkToPosBlockCommand +# Walking object +var walking_object_node: ESCItem + + # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( @@ -40,6 +44,10 @@ func validate(arguments: Array): ] ) return false + + walking_object_node = (escoria.object_manager.get_object( + arguments[0]).node as ESCItem + ) return true @@ -54,3 +62,9 @@ func run(command_params: Array) -> int: "arrived" ) return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + if not walking_object_node is ESCPlayer: + walking_object_node.stop_walking_now() diff --git a/addons/escoria-core/game/core-scripts/esc/esc_event_manager.gd b/addons/escoria-core/game/core-scripts/esc/esc_event_manager.gd index c6620a05..16059c4b 100644 --- a/addons/escoria-core/game/core-scripts/esc/esc_event_manager.gd +++ b/addons/escoria-core/game/core-scripts/esc/esc_event_manager.gd @@ -280,7 +280,9 @@ func _on_event_finished(finished_statement: ESCStatement, return_code: int, chan if event_flags & ESCEvent.FLAG_NO_SAVE: escoria.save_manager.save_enabled = true - + + # If the return code was RC_CANCEL due to an event finishing with "stop" command for example + # we convert it to RC_OK so that other processed waiting for RC_OK can carry on. if return_code == ESCExecution.RC_CANCEL: return_code = ESCExecution.RC_OK diff --git a/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd b/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd index fb5d2ccc..190654ef 100644 --- a/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd +++ b/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd @@ -133,3 +133,19 @@ func run() -> int: return rc else: return ESCExecution.RC_ERROR + + +# This function interrupts the command. If it was not started, it will not run. +# If it had already started, the execution will be considered as finished +# immediately and finish. If it was already finished, nothing will happen. +func interrupt(): + _is_interrupted = true + var command = escoria.command_registry.get_command(self.name) + if command.has_method("interrupt"): + command.interrupt() + + +# Override of built-in _to_string function to display the statement. +func _to_string() -> String: + return "Command %s with parameters: %s" % [name, str(parameters)] + diff --git a/addons/escoria-core/game/core-scripts/esc/types/esc_execution.gd b/addons/escoria-core/game/core-scripts/esc/types/esc_execution.gd index 84ed827e..0a4b3727 100644 --- a/addons/escoria-core/game/core-scripts/esc/types/esc_execution.gd +++ b/addons/escoria-core/game/core-scripts/esc/types/esc_execution.gd @@ -5,7 +5,9 @@ class_name ESCExecution # Return codes handled by events # * RC_OK: Event run okay -# * RC_CANCEL: Cancel all scheduled and queued events +# * RC_CANCEL: Cancel all scheduled and queued events. This return code tells the Event Manager +# that no execution is required for this command (such as "stop" and "repeat") # * RC_ERROR: Error running a command # * RC_REPEAT: Repeat the current scope from the beginning -enum {RC_OK, RC_CANCEL, RC_ERROR, RC_REPEAT} +# * RC_INTERRUPTED: Event was interrupted +enum {RC_OK, RC_CANCEL, RC_ERROR, RC_REPEAT, RC_INTERRUPTED} diff --git a/addons/escoria-core/game/core-scripts/esc/types/esc_statement.gd b/addons/escoria-core/game/core-scripts/esc/types/esc_statement.gd index 67624a03..8d890c6a 100644 --- a/addons/escoria-core/game/core-scripts/esc/types/esc_statement.gd +++ b/addons/escoria-core/game/core-scripts/esc/types/esc_statement.gd @@ -13,9 +13,6 @@ signal interrupted(return_code) # The list of ESC commands var statements: Array = [] -# Indicates whether this event was finished. -var is_finished: bool = false - # The source of this statement, e.g. an ESC script or a class. var source: String = "" @@ -36,7 +33,8 @@ func run() -> int: var final_rc = ESCExecution.RC_OK for statement in statements: if _is_interrupted: - final_rc = ESCExecution.RC_CANCEL + final_rc = ESCExecution.RC_INTERRUPTED + statement.interrupt() emit_signal("interrupted", final_rc) return final_rc @@ -49,11 +47,8 @@ func run() -> int: ["Statement (%s) was completed." % statement] ) - statement.is_finished = true if rc == ESCExecution.RC_REPEAT: return self.run() - elif rc == ESCExecution.RC_OK: - statement.is_finished = true elif rc != ESCExecution.RC_OK: final_rc = rc break @@ -72,14 +67,7 @@ func interrupt(): ) _is_interrupted = true for statement in statements: - if statement.is_finished: - var name = statement.name if "name" in statement else "group" - escoria.logger.debug( - "event manager", - ["Event %s (%s) is already finished. Won't interrupt." - % [name, str(statement)]] - ) - else: + if statement.has_method("interrupt"): statement.interrupt() diff --git a/addons/escoria-core/game/core-scripts/esc_item.gd b/addons/escoria-core/game/core-scripts/esc_item.gd index abf9cb9e..a5ee0933 100644 --- a/addons/escoria-core/game/core-scripts/esc_item.gd +++ b/addons/escoria-core/game/core-scripts/esc_item.gd @@ -461,6 +461,20 @@ func walk_to(pos: Vector2, p_walk_context: ESCWalkContext = null) -> void: _movable.walk_to(pos, p_walk_context) +# Stop the movable node immediately and remain where it is at this moment, +# or teleport it directly at destination position if 'to_target' is true. +# +# #### Parameters +# +# - to_target: if true, the movable node is teleport directly at its target +# destination +func stop_walking_now(to_target: bool = false) -> void: + var where: Vector2 = position + if to_target: + where = _movable.walk_destination + _movable.walk_stop(where) + + # Set the moving speed # # #### Parameters diff --git a/addons/escoria-ui-keyboard-9verbs/game.gd b/addons/escoria-ui-keyboard-9verbs/game.gd index 7a9fac29..4c540767 100644 --- a/addons/escoria-ui-keyboard-9verbs/game.gd +++ b/addons/escoria-ui-keyboard-9verbs/game.gd @@ -397,5 +397,6 @@ func _on_action_finished() -> void: tooltip.clear() func _on_event_done(_return_code: int, _event_name: String): - escoria.action_manager.clear_current_action() - verbs_menu.unselect_actions() + if _return_code == ESCExecution.RC_OK: + escoria.action_manager.clear_current_action() + verbs_menu.unselect_actions() diff --git a/addons/escoria-ui-simplemouse/game.gd b/addons/escoria-ui-simplemouse/game.gd index 17c39b06..ddd24a74 100644 --- a/addons/escoria-ui-simplemouse/game.gd +++ b/addons/escoria-ui-simplemouse/game.gd @@ -372,8 +372,9 @@ func _on_action_finished(): $mouse_layer/verbs_menu.iterate_actions_cursor(0) func _on_event_done(_return_code: int, _event_name: String): - escoria.action_manager.clear_current_action() - $mouse_layer/verbs_menu.clear_tool_texture() + if _return_code == ESCExecution.RC_OK: + escoria.action_manager.clear_current_action() + $mouse_layer/verbs_menu.clear_tool_texture() func _on_MenuButton_pressed() -> void: