mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-22 08:04:23 +00:00
29 lines
638 B
GDScript
29 lines
638 B
GDScript
@icon("res://behaviours/sampler.svg")
|
|
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] = []
|
|
|
|
|
|
## Get a reference.
|
|
func sample() -> Node:
|
|
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)
|