changes
This commit is contained in:
102
SetPiece_.gd
102
SetPiece_.gd
@@ -40,75 +40,37 @@ signal exited(lab)
|
||||
points_resource = value
|
||||
_update_polygon_from_resource()
|
||||
|
||||
var is_in = false
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if Engine.is_editor_hint():
|
||||
self.color.a = 0.25
|
||||
else:
|
||||
if Geometry2D.is_point_in_polygon(to_local(get_global_mouse_position()), self.polygon):
|
||||
if is_in == false:
|
||||
is_in = true
|
||||
emit_signal("entered", label)
|
||||
else:
|
||||
if is_in == true:
|
||||
emit_signal("exited", label)
|
||||
is_in = false
|
||||
|
||||
|
||||
|
||||
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 Input.is_action_just_released("interact"):
|
||||
# Check if a script is running that shouldn't be interrupted
|
||||
var script_builder = get_node_or_null("/root/Node2D/GameScript")
|
||||
if script_builder and script_builder.current_script and not script_builder.current_script.can_interrupt:
|
||||
return # Let the script handle the input
|
||||
|
||||
# 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
|
||||
|
||||
print("MAX PRIOORITY", max_priority)
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
# Check if interacted signal has connections - it takes precedence
|
||||
if interacted.get_connections().size() > 0:
|
||||
emit_signal("interacted")
|
||||
return
|
||||
|
||||
# Otherwise, emit action-specific signal based on current cursor
|
||||
match ActionState.current_action:
|
||||
ActionState.Action.WALK:
|
||||
if walked.get_connections().size() > 0:
|
||||
emit_signal("walked")
|
||||
ActionState.Action.LOOK:
|
||||
if looked.get_connections().size() > 0:
|
||||
emit_signal("looked")
|
||||
ActionState.Action.TOUCH:
|
||||
if touched.get_connections().size() > 0:
|
||||
emit_signal("touched")
|
||||
ActionState.Action.TALK:
|
||||
if talked.get_connections().size() > 0:
|
||||
emit_signal("talked")
|
||||
if event is InputEventMouseButton and Input.is_action_just_released("interact"):
|
||||
# Check if a script is running that shouldn't be interrupted
|
||||
var script_builder = get_node_or_null("/root/Node2D/GameScript")
|
||||
if script_builder and script_builder.current_script and not script_builder.current_script.can_interrupt:
|
||||
return # Let the script handle the input
|
||||
|
||||
# Check if this is the top-priority hovered SetPiece
|
||||
var top_piece = ActionState.get_top_hovered_setpiece()
|
||||
if top_piece != self:
|
||||
return
|
||||
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
# Check if interacted signal has connections - it takes precedence
|
||||
if interacted.get_connections().size() > 0:
|
||||
emit_signal("interacted")
|
||||
return
|
||||
|
||||
# Otherwise, emit action-specific signal based on current cursor
|
||||
match ActionState.current_action:
|
||||
ActionState.Action.WALK:
|
||||
if walked.get_connections().size() > 0:
|
||||
emit_signal("walked")
|
||||
ActionState.Action.LOOK:
|
||||
if looked.get_connections().size() > 0:
|
||||
emit_signal("looked")
|
||||
ActionState.Action.TOUCH:
|
||||
if touched.get_connections().size() > 0:
|
||||
emit_signal("touched")
|
||||
ActionState.Action.TALK:
|
||||
if talked.get_connections().size() > 0:
|
||||
emit_signal("talked")
|
||||
|
||||
Reference in New Issue
Block a user