progress
This commit is contained in:
25
SetPiece_.gd
25
SetPiece_.gd
@@ -34,6 +34,7 @@ signal entered(lab)
|
||||
signal exited(lab)
|
||||
|
||||
@export var label: String
|
||||
@export var priority: int = 0
|
||||
@export var points_resource: PolygonPointsResource:
|
||||
set(value):
|
||||
points_resource = value
|
||||
@@ -57,10 +58,34 @@ func _process(delta):
|
||||
|
||||
|
||||
|
||||
func _get_overlapping_setpieces() -> Array[SetPiece]:
|
||||
var overlapping: Array[SetPiece] = []
|
||||
var mouse_pos = to_local(get_global_mouse_position())
|
||||
|
||||
for child in get_tree().get_nodes_in_group("set-piece"):
|
||||
if child is SetPiece and child != self:
|
||||
if child.polygon.size() > 0 and Geometry2D.is_point_in_polygon(mouse_pos, child.polygon):
|
||||
overlapping.append(child)
|
||||
|
||||
return overlapping
|
||||
|
||||
func _input(event):
|
||||
if not Engine.is_editor_hint():
|
||||
if Geometry2D.is_point_in_polygon(to_local(get_global_mouse_position()), self.polygon):
|
||||
if event is InputEventMouseButton and event.is_action("interact"):
|
||||
# Find all overlapping SetPieces and check if this one has highest priority
|
||||
var overlapping = _get_overlapping_setpieces()
|
||||
overlapping.append(self)
|
||||
|
||||
var max_priority = self.priority
|
||||
for piece in overlapping:
|
||||
if piece.priority > max_priority:
|
||||
max_priority = piece.priority
|
||||
|
||||
# Only process if this SetPiece has the highest priority
|
||||
if self.priority < max_priority:
|
||||
return
|
||||
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
# Check if interacted signal has connections - it takes precedence
|
||||
|
||||
Reference in New Issue
Block a user