1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-25 01:24:23 +00:00
hella-farm/behaviours/sampler.gd

30 lines
638 B
GDScript3
Raw Normal View History

@icon("res://behaviours/sampler.svg")
2024-04-16 03:08:25 +00:00
extends Node
class_name Sampler
## Abstract base class for sampling a certain reference among multiple.
signal notify_selected(node: Node)
signal notify_deselected(node: Node)
@export var possibilities: Array[Node] = []
2024-04-16 03:08:25 +00:00
## Get a reference.
func sample() -> Node:
2024-04-16 03:08:25 +00:00
Log.e(self, "Not implemented.")
return null
## Get all possible nodes referenced by [field possibilities].
func get_refs() -> Array[Node]:
return possibilities
## Set the "enabled" property on
func enable() -> void:
var selected = sample()
for possibility in get_refs():
possibility.enabled = (selected == possibility)