fix: Interrupts player's simple walk on any new action

This commit is contained in:
Julian Murgia
2022-08-28 10:25:39 +02:00
committed by Duncan Brown
parent 895700870d
commit d28118f567
3 changed files with 21 additions and 1 deletions

View File

@@ -251,7 +251,7 @@ func _get_event_to_queue(
escoria.logger.info(
self,
"Checking action %s on %s..." % [action, target]
"Checking if action '%s' on '%s' is valid..." % [action, target]
)
var event_to_return: ESCEvent = null
@@ -360,6 +360,13 @@ func _get_event_to_queue(
return event_to_return
# Runs the specified event.
#
# #### Parameters
#
# - event: the event to be run
#
# *Returns* the return code of the event once executed
func _run_event(event: ESCEvent) -> int:
escoria.event_manager.queue_event(event)

View File

@@ -284,6 +284,11 @@ func queue_background_event(channel_name: String, event: ESCEvent) -> void:
# #### Parameters
# - exceptions: an optional list of events which should be left running or queued
func interrupt(exceptions: PoolStringArray = []) -> void:
if escoria.main.current_scene != null \
and escoria.main.current_scene.player != null \
and escoria.main.current_scene.player.is_moving():
escoria.main.current_scene.player.stop_walking_now()
for channel_name in _running_events.keys():
if _running_events[channel_name] != null and not _running_events[channel_name].name in exceptions:
escoria.logger.debug(

View File

@@ -747,3 +747,11 @@ func _get_identifier_as_key_value() -> String:
return "global_id: %s" % self.global_id
else:
return "node: %s" % get_name()
# Whether the item is currently moving.
#
# *Returns*
# Returns true if the player is currently moving, false otherwise
func is_moving() -> bool:
return _movable.task != ESCMovable.MovableTask.NONE