39 lines
863 B
GDScript3
39 lines
863 B
GDScript3
|
extends Sprite
|
||
|
|
||
|
class_name Anchor
|
||
|
|
||
|
export var selectable = false
|
||
|
export var selected = false
|
||
|
export(String, "normal", "attack_start", "defend_start") var anchor_type = "normal"
|
||
|
var content
|
||
|
|
||
|
func _process(delta):
|
||
|
if selected:
|
||
|
modulate = Color(1, 0.4, 0.4)
|
||
|
elif selectable:
|
||
|
modulate = Color(1, 0.8, 0.2)
|
||
|
else:
|
||
|
modulate = Color(1, 1, 1)
|
||
|
|
||
|
func _ready():
|
||
|
add_to_group("anchors")
|
||
|
|
||
|
func is_connected_to(other: Anchor) -> bool:
|
||
|
for route in get_tree().get_nodes_in_group("routes"):
|
||
|
if route is Route and route.is_connecting(self, other):
|
||
|
return true
|
||
|
return false
|
||
|
|
||
|
func set_content(val):
|
||
|
if val is Node:
|
||
|
var old_parent = val.get_parent()
|
||
|
if old_parent:
|
||
|
if old_parent.has_method("set_content"):
|
||
|
old_parent.set_content(null)
|
||
|
old_parent.remove_child(val)
|
||
|
self.add_child(val)
|
||
|
content = val
|
||
|
|
||
|
func is_empty() -> bool:
|
||
|
return not content
|