fix: manage clearing of current_action when action is interrupted (#584)
* fix: manage clearing of current_action when action is interrupted * fix: repairs change_scene, add comments and new RC_INTERRUPTED code * fix: manage ESC commands interruptions, even if running
This commit is contained in:
@@ -59,3 +59,9 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
escoria.inputs_manager.input_mode = mode
|
escoria.inputs_manager.input_mode = mode
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -52,3 +52,13 @@ func run(command_params: Array) -> int:
|
|||||||
else:
|
else:
|
||||||
animator.play(anim_id)
|
animator.play(anim_id)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -58,3 +58,13 @@ func run(command_params: Array) -> int:
|
|||||||
while animation_finished != anim_id:
|
while animation_finished != anim_id:
|
||||||
animation_finished = yield(animator, "animation_finished")
|
animation_finished = yield(animator, "animation_finished")
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -77,3 +77,13 @@ func run(command_params: Array) -> int:
|
|||||||
Tween.new().get("TRANS_%s" % command_params[2])
|
Tween.new().get("TRANS_%s" % command_params[2])
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -51,3 +51,13 @@ func validate(arguments: Array):
|
|||||||
func run(command_params: Array) -> int:
|
func run(command_params: Array) -> int:
|
||||||
escoria.main.set_camera_limits(command_params[0])
|
escoria.main.set_camera_limits(command_params[0])
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -32,3 +32,13 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[0]
|
command_params[0]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -51,3 +51,13 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[0]
|
command_params[0]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -36,3 +36,13 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[1]
|
command_params[1]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -49,3 +49,13 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[1]
|
command_params[1]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -69,3 +69,13 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -64,3 +64,13 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.room_manager.change_scene(command_params[0], command_params[1])
|
escoria.room_manager.change_scene(command_params[0], command_params[1])
|
||||||
|
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -83,3 +83,13 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[3]
|
command_params[3]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
get_command_name(),
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -45,3 +45,9 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[1]
|
command_params[1]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -43,3 +43,9 @@ func run(command_params: Array) -> int:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_ERROR
|
return ESCExecution.RC_ERROR
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -77,3 +77,9 @@ func run(command_params: Array) -> int:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -53,3 +53,9 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[1]
|
command_params[1]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -42,3 +42,9 @@ func validate(arguments: Array):
|
|||||||
func run(command_params: Array) -> int:
|
func run(command_params: Array) -> int:
|
||||||
escoria.inventory_manager.add_item(command_params[0])
|
escoria.inventory_manager.add_item(command_params[0])
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -26,3 +26,9 @@ func configure() -> ESCCommandArgumentDescriptor:
|
|||||||
func run(command_params: Array) -> int:
|
func run(command_params: Array) -> int:
|
||||||
escoria.inventory_manager.remove_item(command_params[0])
|
escoria.inventory_manager.remove_item(command_params[0])
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ extends ESCBaseCommand
|
|||||||
class_name PlaySndCommand
|
class_name PlaySndCommand
|
||||||
|
|
||||||
|
|
||||||
|
# The specified sound player
|
||||||
|
var _snd_player: String
|
||||||
|
|
||||||
|
|
||||||
# Return the descriptor of the arguments of this command
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
return ESCCommandArgumentDescriptor.new(
|
return ESCCommandArgumentDescriptor.new(
|
||||||
@@ -40,6 +44,7 @@ func validate(arguments: Array):
|
|||||||
["File %s not found" % arguments[0]]
|
["File %s not found" % arguments[0]]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
_snd_player = arguments[1]
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
@@ -49,3 +54,8 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[0]
|
command_params[0]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.object_manager.get_object(_snd_player).node.set_state("off")
|
||||||
|
|||||||
@@ -26,3 +26,9 @@ func run(command_params: Array) -> int:
|
|||||||
# Replace the names of any globals in "{ }" with their value
|
# Replace the names of any globals in "{ }" with their value
|
||||||
print(escoria.logger.replace_globals(command_params[0]))
|
print(escoria.logger.replace_globals(command_params[0]))
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -82,3 +82,9 @@ func run(arguments: Array) -> int:
|
|||||||
arguments[2], # channel name
|
arguments[2], # channel name
|
||||||
arguments[3] # whether to block
|
arguments[3] # whether to block
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -43,3 +43,9 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[1]
|
command_params[1]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -32,3 +32,9 @@ func run(command_params: Array) -> int:
|
|||||||
rnd
|
rnd
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -20,3 +20,9 @@ func configure() -> ESCCommandArgumentDescriptor:
|
|||||||
# Run the command
|
# Run the command
|
||||||
func run(command_params: Array) -> int:
|
func run(command_params: Array) -> int:
|
||||||
return ESCExecution.RC_CANCEL
|
return ESCExecution.RC_CANCEL
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -111,3 +111,13 @@ func run(command_params: Array) -> int:
|
|||||||
yield(escoria.dialog_player, "say_finished")
|
yield(escoria.dialog_player, "say_finished")
|
||||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
"say",
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -62,3 +62,9 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[0]
|
command_params[0]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -43,3 +43,9 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.object_manager.get_object(command_params[0]).active = \
|
escoria.object_manager.get_object(command_params[0]).active = \
|
||||||
command_params[1]
|
command_params[1]
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -33,3 +33,9 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.object_manager.get_object(command_params[0]).active = \
|
escoria.object_manager.get_object(command_params[0]).active = \
|
||||||
command_params[1]
|
command_params[1]
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -55,3 +55,9 @@ func run(command_params: Array) -> int:
|
|||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -68,3 +68,9 @@ func run(command_params: Array) -> int:
|
|||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -33,3 +33,9 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[2]
|
command_params[2]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -30,3 +30,9 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[1]
|
command_params[1]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -27,3 +27,9 @@ func run(command_params: Array) -> int:
|
|||||||
else:
|
else:
|
||||||
escoria.main.current_scene.game.hide_ui()
|
escoria.main.current_scene.game.hide_ui()
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -42,3 +42,9 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.object_manager.get_object(command_params[0]).interactive = \
|
escoria.object_manager.get_object(command_params[0]).interactive = \
|
||||||
command_params[1]
|
command_params[1]
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -40,3 +40,9 @@ func run(command_params: Array) -> int:
|
|||||||
(escoria.object_manager.get_object(command_params[0]).node as ESCItem).\
|
(escoria.object_manager.get_object(command_params[0]).node as ESCItem).\
|
||||||
set_speed(command_params[1])
|
set_speed(command_params[1])
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -51,3 +51,9 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[2]
|
command_params[2]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -81,3 +81,9 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.game_scene.pause_game()
|
escoria.game_scene.pause_game()
|
||||||
|
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -109,3 +109,9 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[2]
|
command_params[2]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
for tween in _tweens:
|
||||||
|
tween.stop_all()
|
||||||
|
|||||||
@@ -25,3 +25,8 @@ func run(command_params: Array) -> int:
|
|||||||
)
|
)
|
||||||
yield(tween, "tween_all_completed")
|
yield(tween, "tween_all_completed")
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
.interrupt()
|
||||||
|
|||||||
@@ -91,3 +91,9 @@ func run(command_params: Array) -> int:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -19,3 +19,9 @@ func configure() -> ESCCommandArgumentDescriptor:
|
|||||||
# Run the command
|
# Run the command
|
||||||
func run(command_params: Array) -> int:
|
func run(command_params: Array) -> int:
|
||||||
return ESCExecution.RC_CANCEL
|
return ESCExecution.RC_CANCEL
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ extends ESCBaseCommand
|
|||||||
class_name StopSndCommand
|
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
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
return ESCCommandArgumentDescriptor.new(
|
return ESCCommandArgumentDescriptor.new(
|
||||||
@@ -30,15 +37,24 @@ func validate(arguments: Array):
|
|||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.report_errors(
|
||||||
"stop_snd: invalid sound player",
|
"stop_snd: invalid sound player",
|
||||||
["Sound player %s not registered" % arguments[1]]
|
["Sound player %s not registered" % arguments[0]]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
_snd_player = arguments[0]
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
# Run the command
|
# Run the command
|
||||||
func run(command_params: Array) -> int:
|
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(
|
escoria.object_manager.get_object(command_params[0]).node.set_state(
|
||||||
"off"
|
"off"
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
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
|
||||||
|
)
|
||||||
|
|||||||
@@ -53,3 +53,9 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.object_manager.get_object(command_params[1]).node
|
escoria.object_manager.get_object(command_params[1]).node
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -44,3 +44,9 @@ func run(command_params: Array) -> int:
|
|||||||
Vector2(int(command_params[1]), int(command_params[2]))
|
Vector2(int(command_params[1]), int(command_params[2]))
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -72,3 +72,9 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.logger.debug("Ending transition #%s [%s, %s]"
|
escoria.logger.debug("Ending transition #%s [%s, %s]"
|
||||||
% [transition_id, command_params[0], command_params[1]])
|
% [transition_id, command_params[0], command_params[1]])
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
# Do nothing
|
||||||
|
pass
|
||||||
|
|||||||
@@ -61,3 +61,13 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[2]
|
command_params[2]
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
escoria.logger.report_warnings(
|
||||||
|
"turn_to",
|
||||||
|
[
|
||||||
|
"Interrupt() function not implemented"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
extends ESCBaseCommand
|
extends ESCBaseCommand
|
||||||
class_name WaitCommand
|
class_name WaitCommand
|
||||||
|
|
||||||
|
# Timer to wait for
|
||||||
|
var timer: Timer
|
||||||
|
|
||||||
|
|
||||||
# Return the descriptor of the arguments of this command
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
@@ -40,5 +43,15 @@ func validate(arguments: Array):
|
|||||||
|
|
||||||
# Run the command
|
# Run the command
|
||||||
func run(command_params: Array) -> int:
|
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
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
timer.emit_signal("timeout")
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ extends ESCBaseCommand
|
|||||||
class_name WalkCommand
|
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
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
return ESCCommandArgumentDescriptor.new(
|
return ESCCommandArgumentDescriptor.new(
|
||||||
@@ -46,6 +53,11 @@ func validate(arguments: Array):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
return false
|
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
|
return true
|
||||||
|
|
||||||
|
|
||||||
@@ -56,3 +68,8 @@ func run(command_params: Array) -> int:
|
|||||||
command_params
|
command_params
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
# Function called when the command is interrupted.
|
||||||
|
func interrupt():
|
||||||
|
walking_object_node.stop_walking_now()
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ extends ESCBaseCommand
|
|||||||
class_name WalkBlockCommand
|
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
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
return ESCCommandArgumentDescriptor.new(
|
return ESCCommandArgumentDescriptor.new(
|
||||||
@@ -46,6 +53,11 @@ func validate(arguments: Array):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
return false
|
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
|
return true
|
||||||
|
|
||||||
|
|
||||||
@@ -55,8 +67,11 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.action_manager.ACTION.BACKGROUND_CLICK,
|
escoria.action_manager.ACTION.BACKGROUND_CLICK,
|
||||||
command_params
|
command_params
|
||||||
)
|
)
|
||||||
yield(
|
yield(walking_object_node, "arrived")
|
||||||
(escoria.object_manager.get_object(command_params[0]).node as ESCItem),
|
|
||||||
"arrived"
|
|
||||||
)
|
|
||||||
return ESCExecution.RC_OK
|
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()
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ extends ESCBaseCommand
|
|||||||
class_name WalkToPosCommand
|
class_name WalkToPosCommand
|
||||||
|
|
||||||
|
|
||||||
|
# Walking object
|
||||||
|
var walking_object_node: ESCItem
|
||||||
|
|
||||||
|
|
||||||
# Return the descriptor of the arguments of this command
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
return ESCCommandArgumentDescriptor.new(
|
return ESCCommandArgumentDescriptor.new(
|
||||||
@@ -40,6 +44,10 @@ func validate(arguments: Array):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
walking_object_node = (escoria.object_manager.get_object(
|
||||||
|
arguments[0]).node as ESCItem
|
||||||
|
)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
@@ -50,3 +58,9 @@ func run(command_params: Array) -> int:
|
|||||||
Vector2(command_params[1], command_params[2]), command_params[3]
|
Vector2(command_params[1], command_params[2]), command_params[3]
|
||||||
])
|
])
|
||||||
return ESCExecution.RC_OK
|
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()
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ extends ESCBaseCommand
|
|||||||
class_name WalkToPosBlockCommand
|
class_name WalkToPosBlockCommand
|
||||||
|
|
||||||
|
|
||||||
|
# Walking object
|
||||||
|
var walking_object_node: ESCItem
|
||||||
|
|
||||||
|
|
||||||
# Return the descriptor of the arguments of this command
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
return ESCCommandArgumentDescriptor.new(
|
return ESCCommandArgumentDescriptor.new(
|
||||||
@@ -40,6 +44,10 @@ func validate(arguments: Array):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
walking_object_node = (escoria.object_manager.get_object(
|
||||||
|
arguments[0]).node as ESCItem
|
||||||
|
)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
@@ -54,3 +62,9 @@ func run(command_params: Array) -> int:
|
|||||||
"arrived"
|
"arrived"
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
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()
|
||||||
|
|||||||
@@ -281,6 +281,8 @@ func _on_event_finished(finished_statement: ESCStatement, return_code: int, chan
|
|||||||
if event_flags & ESCEvent.FLAG_NO_SAVE:
|
if event_flags & ESCEvent.FLAG_NO_SAVE:
|
||||||
escoria.save_manager.save_enabled = true
|
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:
|
if return_code == ESCExecution.RC_CANCEL:
|
||||||
return_code = ESCExecution.RC_OK
|
return_code = ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|||||||
@@ -133,3 +133,19 @@ func run() -> int:
|
|||||||
return rc
|
return rc
|
||||||
else:
|
else:
|
||||||
return ESCExecution.RC_ERROR
|
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)]
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ class_name ESCExecution
|
|||||||
|
|
||||||
# Return codes handled by events
|
# Return codes handled by events
|
||||||
# * RC_OK: Event run okay
|
# * 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_ERROR: Error running a command
|
||||||
# * RC_REPEAT: Repeat the current scope from the beginning
|
# * 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}
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ signal interrupted(return_code)
|
|||||||
# The list of ESC commands
|
# The list of ESC commands
|
||||||
var statements: Array = []
|
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.
|
# The source of this statement, e.g. an ESC script or a class.
|
||||||
var source: String = ""
|
var source: String = ""
|
||||||
|
|
||||||
@@ -36,7 +33,8 @@ func run() -> int:
|
|||||||
var final_rc = ESCExecution.RC_OK
|
var final_rc = ESCExecution.RC_OK
|
||||||
for statement in statements:
|
for statement in statements:
|
||||||
if _is_interrupted:
|
if _is_interrupted:
|
||||||
final_rc = ESCExecution.RC_CANCEL
|
final_rc = ESCExecution.RC_INTERRUPTED
|
||||||
|
statement.interrupt()
|
||||||
emit_signal("interrupted", final_rc)
|
emit_signal("interrupted", final_rc)
|
||||||
return final_rc
|
return final_rc
|
||||||
|
|
||||||
@@ -49,11 +47,8 @@ func run() -> int:
|
|||||||
["Statement (%s) was completed."
|
["Statement (%s) was completed."
|
||||||
% statement]
|
% statement]
|
||||||
)
|
)
|
||||||
statement.is_finished = true
|
|
||||||
if rc == ESCExecution.RC_REPEAT:
|
if rc == ESCExecution.RC_REPEAT:
|
||||||
return self.run()
|
return self.run()
|
||||||
elif rc == ESCExecution.RC_OK:
|
|
||||||
statement.is_finished = true
|
|
||||||
elif rc != ESCExecution.RC_OK:
|
elif rc != ESCExecution.RC_OK:
|
||||||
final_rc = rc
|
final_rc = rc
|
||||||
break
|
break
|
||||||
@@ -72,14 +67,7 @@ func interrupt():
|
|||||||
)
|
)
|
||||||
_is_interrupted = true
|
_is_interrupted = true
|
||||||
for statement in statements:
|
for statement in statements:
|
||||||
if statement.is_finished:
|
if statement.has_method("interrupt"):
|
||||||
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:
|
|
||||||
statement.interrupt()
|
statement.interrupt()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -461,6 +461,20 @@ func walk_to(pos: Vector2, p_walk_context: ESCWalkContext = null) -> void:
|
|||||||
_movable.walk_to(pos, p_walk_context)
|
_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
|
# Set the moving speed
|
||||||
#
|
#
|
||||||
# #### Parameters
|
# #### Parameters
|
||||||
|
|||||||
@@ -397,5 +397,6 @@ func _on_action_finished() -> void:
|
|||||||
tooltip.clear()
|
tooltip.clear()
|
||||||
|
|
||||||
func _on_event_done(_return_code: int, _event_name: String):
|
func _on_event_done(_return_code: int, _event_name: String):
|
||||||
escoria.action_manager.clear_current_action()
|
if _return_code == ESCExecution.RC_OK:
|
||||||
verbs_menu.unselect_actions()
|
escoria.action_manager.clear_current_action()
|
||||||
|
verbs_menu.unselect_actions()
|
||||||
|
|||||||
@@ -372,8 +372,9 @@ func _on_action_finished():
|
|||||||
$mouse_layer/verbs_menu.iterate_actions_cursor(0)
|
$mouse_layer/verbs_menu.iterate_actions_cursor(0)
|
||||||
|
|
||||||
func _on_event_done(_return_code: int, _event_name: String):
|
func _on_event_done(_return_code: int, _event_name: String):
|
||||||
escoria.action_manager.clear_current_action()
|
if _return_code == ESCExecution.RC_OK:
|
||||||
$mouse_layer/verbs_menu.clear_tool_texture()
|
escoria.action_manager.clear_current_action()
|
||||||
|
$mouse_layer/verbs_menu.clear_tool_texture()
|
||||||
|
|
||||||
|
|
||||||
func _on_MenuButton_pressed() -> void:
|
func _on_MenuButton_pressed() -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user