feat: Added warning message when multiple locations found for an item
This commit is contained in:
committed by
Julian Murgia
parent
0a1f16f61f
commit
b4a57fa788
@@ -523,11 +523,7 @@ func perform_inputevent_on_object(
|
|||||||
event.doubleclick
|
event.doubleclick
|
||||||
)
|
)
|
||||||
if context is GDScriptFunctionState:
|
if context is GDScriptFunctionState:
|
||||||
context = yield(_walk_towards_object(
|
context = yield(context, "completed")
|
||||||
obj,
|
|
||||||
event.position,
|
|
||||||
event.doubleclick
|
|
||||||
), "completed")
|
|
||||||
destination_position = context.target_position
|
destination_position = context.target_position
|
||||||
dont_interact = context.dont_interact_on_arrival
|
dont_interact = context.dont_interact_on_arrival
|
||||||
|
|
||||||
@@ -620,10 +616,14 @@ func _walk_towards_object(
|
|||||||
var destination_position: Vector2
|
var destination_position: Vector2
|
||||||
var dont_interact: bool = false
|
var dont_interact: bool = false
|
||||||
|
|
||||||
|
if obj == null || obj.node == null:
|
||||||
|
escoria.logger.report_errors("esc_action_manager.gd:_walk_towards_object",
|
||||||
|
["obj or obj.node not populated."])
|
||||||
|
var interact_position = obj.node.get_interact_position()
|
||||||
# If clicked object is interactive, get destination position from it.
|
# If clicked object is interactive, get destination position from it.
|
||||||
if escoria.object_manager.get_object(obj.global_id).interactive:
|
if escoria.object_manager.get_object(obj.global_id).interactive:
|
||||||
if obj.node.get_interact_position() != null:
|
if interact_position != null:
|
||||||
destination_position = obj.node.get_interact_position()
|
destination_position = interact_position
|
||||||
else:
|
else:
|
||||||
destination_position = obj.node.position
|
destination_position = obj.node.position
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -379,14 +379,20 @@ func get_animation_player() -> Node:
|
|||||||
#
|
#
|
||||||
# **Returns** The interaction position
|
# **Returns** The interaction position
|
||||||
func get_interact_position() -> Vector2:
|
func get_interact_position() -> Vector2:
|
||||||
|
var multiple_positions_found = false
|
||||||
var interact_position = null
|
var interact_position = null
|
||||||
for c in get_children():
|
for c in get_children():
|
||||||
if c is Position2D:
|
if c is Position2D:
|
||||||
|
if interact_position != null:
|
||||||
|
multiple_positions_found = true
|
||||||
interact_position = c.global_position
|
interact_position = c.global_position
|
||||||
|
|
||||||
if interact_position == null and collision != null:
|
if interact_position == null and collision != null:
|
||||||
interact_position = collision.global_position
|
interact_position = collision.global_position
|
||||||
|
|
||||||
|
if multiple_positions_found:
|
||||||
|
escoria.logger.warning("Multiple ESClocations found to walk to for object " +
|
||||||
|
"%s. Last one will be used." % global_id)
|
||||||
return interact_position
|
return interact_position
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user