1
0
Fork 0
spacetac/arenas/anchor.gd

47 lines
1,007 B
GDScript

extends Sprite
class_name Anchor
export var selectable = false
export var selected = false
export(String, "normal", "attack_start", "defend_start") var anchor_type = "normal"
export(NodePath) 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.get_path()
else:
content = null
func get_content():
if content:
return get_node_or_null(content)
else:
return null
func is_empty() -> bool:
return not get_content()