mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-24 17:14:23 +00:00
29 lines
No EOL
797 B
GDScript
29 lines
No EOL
797 B
GDScript
@icon("res://behaviours/sampler.svg")
|
|
extends Node
|
|
class_name Sampler
|
|
|
|
|
|
## Abstract base class for sampling a certain reference among multiple.
|
|
|
|
|
|
## [Array] of [Node]s that can be [func sample]d by this [Sampler].
|
|
@export var possibilities: Array[Node] = []
|
|
|
|
|
|
## Get a reference.
|
|
func sample() -> Node:
|
|
Log.e(self, "Not implemented.")
|
|
return null
|
|
|
|
## Set the [field enabled] property to true on a [method sample]d node, and to false on all others.
|
|
func enable() -> void:
|
|
var selected = sample()
|
|
for possibility in get_all_refs():
|
|
possibility.enabled = (selected == possibility)
|
|
|
|
|
|
## Get all possible nodes referenced by [field possibilities].
|
|
##
|
|
## Useful as it may be overridden by some other [Sampler]s, such as [SamplerPriority].
|
|
func get_all_refs() -> Array[Node]:
|
|
return possibilities |