fix: checks to make sure target_object after a walk to an object is the proper one in case action manager is already yielding and expecting a particular one; change to proper interrupt method name; clears out pending events
This commit is contained in:
committed by
Julian Murgia
parent
954e014cbf
commit
9e247a9218
@@ -522,6 +522,11 @@ func perform_inputevent_on_object(
|
||||
)
|
||||
if context is GDScriptFunctionState:
|
||||
context = yield(context, "completed")
|
||||
|
||||
# In case of an interrupted walk, we don't want to proceed.
|
||||
if context == null:
|
||||
return
|
||||
|
||||
destination_position = context.target_position
|
||||
dont_interact = context.dont_interact_on_arrival
|
||||
|
||||
@@ -640,11 +645,19 @@ func _walk_towards_object(
|
||||
escoria.main.current_scene.player.walk_to(destination_position,
|
||||
walk_context)
|
||||
|
||||
escoria.logger.debug("Player walking to destination. Yielding.")
|
||||
|
||||
# Wait for the player to arrive before continuing with action.
|
||||
var context: ESCWalkContext = yield(
|
||||
escoria.main.current_scene.player,
|
||||
"arrived"
|
||||
)
|
||||
|
||||
if context.target_object != obj:
|
||||
escoria.logger.debug("Original walk context target does not match " \
|
||||
+ "yielded walk context. Likely interrutped walk.")
|
||||
return
|
||||
|
||||
escoria.logger.info("Context arrived: %s" % context)
|
||||
|
||||
# Confirm that reached item was the one user clicked in the first place.
|
||||
|
||||
@@ -57,8 +57,11 @@ var _yielding: Dictionary = {}
|
||||
# Whether we're currently changing the scene.
|
||||
var _changing_scene: bool = false setget set_changing_scene
|
||||
|
||||
# ESC "change_scene" command.
|
||||
var _change_scene: ChangeSceneCommand
|
||||
|
||||
|
||||
# Constructor
|
||||
func _init():
|
||||
_change_scene = ChangeSceneCommand.new()
|
||||
|
||||
@@ -330,14 +333,14 @@ func get_running_event(name: String) -> ESCEvent:
|
||||
#
|
||||
# #### Parameterse
|
||||
# - value: boolean value to set _changing_scene to
|
||||
func set_changing_scene(value: bool) -> void:
|
||||
escoria.logger.trace("Setting _changing_scene to %s." % value)
|
||||
func set_changing_scene(p_is_changing_scene: bool) -> void:
|
||||
escoria.logger.trace("Setting _changing_scene to %s." % p_is_changing_scene)
|
||||
|
||||
_changing_scene = value
|
||||
_changing_scene = p_is_changing_scene
|
||||
|
||||
# If we're changing scenes, interrupt any (other) running events and purge
|
||||
# all event queues.
|
||||
if value:
|
||||
if _changing_scene:
|
||||
interrupt([EVENT_INIT, EVENT_EXIT_SCENE, _change_scene.get_command_name()])
|
||||
|
||||
|
||||
|
||||
@@ -44,4 +44,4 @@ func get_command_name() -> String:
|
||||
|
||||
# Function called when the command is interrupted.
|
||||
func interrupt():
|
||||
escoria.logger.info("Command %s did not override interrupt." % get_command_name())
|
||||
escoria.logger.trace("Command %s did not override interrupt." % get_command_name())
|
||||
|
||||
Reference in New Issue
Block a user