1
0
Fork 0
spacetac/arenas/anchor.gd

47 lines
1,007 B
GDScript3
Raw Normal View History

2020-02-03 21:59:43 +00:00
extends Sprite
class_name Anchor
export var selectable = false
export var selected = false
export(String, "normal", "attack_start", "defend_start") var anchor_type = "normal"
2020-02-09 23:28:05 +00:00
export(NodePath) var content
2020-02-03 21:59:43 +00:00
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)
2020-02-18 22:24:00 +00:00
2020-02-03 21:59:43 +00:00
func _ready():
add_to_group("anchors")
2020-02-18 22:24:00 +00:00
2020-02-03 21:59:43 +00:00
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
2020-02-18 22:24:00 +00:00
2020-02-03 21:59:43 +00:00
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)
2020-02-09 23:28:05 +00:00
content = val.get_path()
else:
content = null
2020-02-18 22:24:00 +00:00
2020-02-09 23:28:05 +00:00
func get_content():
if content:
return get_node_or_null(content)
else:
return null
2020-02-18 22:24:00 +00:00
2020-02-03 21:59:43 +00:00
func is_empty() -> bool:
2020-02-09 23:28:05 +00:00
return not get_content()