2024-04-16 22:55:17 +00:00
|
|
|
@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.
|
|
|
|
|
|
|
|
|
2024-04-17 02:52:11 +00:00
|
|
|
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.
|
2024-04-17 02:52:11 +00:00
|
|
|
func sample() -> Node:
|
2024-04-16 03:08:25 +00:00
|
|
|
Log.e(self, "Not implemented.")
|
|
|
|
return null
|
2024-04-17 02:52:11 +00:00
|
|
|
|
|
|
|
## 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)
|