Checked whether multiple enabled navpolys upon adding and deleting
Impossible to check upon navpoly enabling without creating a new script/custom node.
This commit is contained in:
committed by
Duncan Brown
parent
056db75929
commit
7dcd1fdd67
@@ -64,8 +64,36 @@ onready var logger = Logger.ESCLoggerFile.new()
|
||||
# Set a reference to the active navigation polygon, register to Escoria
|
||||
# and update the texture
|
||||
func _ready():
|
||||
connect("child_entered_tree", self, "_check_multiple_enabled_navpolys")
|
||||
connect("child_exiting_tree", self, "_check_multiple_enabled_navpolys", [true])
|
||||
|
||||
_check_multiple_enabled_navpolys()
|
||||
if !Engine.is_editor_hint():
|
||||
escoria.room_terrain = self
|
||||
_update_texture()
|
||||
|
||||
|
||||
# Checks whether multiple navigation polygons are enabled.
|
||||
# Shows a warning in the terminal if this happens.
|
||||
# TODO: change this "simple" console log for an editor warning
|
||||
# by overriding Node._get_configuration_warning() after we get rid of
|
||||
# deprecated Navigation2D.
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - node: if this method is triggered by child_entered_tree or
|
||||
# child_exited_tree signals, parameter is the added node.
|
||||
func _check_multiple_enabled_navpolys(node: Node = null, is_exiting: bool = false) -> void:
|
||||
var navigation_enabled_found = false
|
||||
if node != null \
|
||||
and not is_exiting\
|
||||
and node is NavigationPolygonInstance \
|
||||
and node.enabled:
|
||||
navigation_enabled_found = true
|
||||
|
||||
for n in get_children():
|
||||
if is_exiting and n == node:
|
||||
continue
|
||||
if n is NavigationPolygonInstance and n.enabled:
|
||||
if navigation_enabled_found:
|
||||
if Engine.is_editor_hint():
|
||||
@@ -80,16 +108,12 @@ func _ready():
|
||||
"Multiple NavigationPolygonInstances enabled " + \
|
||||
"at the same time."
|
||||
)
|
||||
return
|
||||
else:
|
||||
navigation_enabled_found = true
|
||||
current_active_navigation_instance = n
|
||||
|
||||
|
||||
if !Engine.is_editor_hint():
|
||||
escoria.room_terrain = self
|
||||
_update_texture()
|
||||
|
||||
|
||||
# Return the Color of the lightmap pixel for the specified position
|
||||
#
|
||||
# #### Parameters
|
||||
|
||||
Reference in New Issue
Block a user