Files
ai-game-2/SetPiece_.gd
2024-07-10 23:59:07 -07:00

51 lines
1.1 KiB
GDScript3

@tool
extends Polygon2D
#class_name SetPiece
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
self.color.a = 0.25
if Engine.is_editor_hint():
self.color.a = 0.25
notify_property_list_changed()
pass
else:
hide()
pass # Replace with function body.
signal interacted
signal entered(lab)
signal exited
@export var label: String
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")
is_in = false
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"):
get_viewport().set_input_as_handled()
emit_signal("interacted")