diff --git a/behaviours/sampler.gd b/behaviours/sampler.gd index 4e08e7f..00b87eb 100644 --- a/behaviours/sampler.gd +++ b/behaviours/sampler.gd @@ -6,10 +6,7 @@ class_name Sampler ## Abstract base class for sampling a certain reference among multiple. -signal notify_selected(node: Node) -signal notify_deselected(node: Node) - - +## [Array] of [Node]s that can be [func sample]d by this [Sampler]. @export var possibilities: Array[Node] = [] @@ -18,12 +15,15 @@ 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 +## 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_refs(): + 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 \ No newline at end of file diff --git a/behaviours/sampler_priority.gd b/behaviours/sampler_priority.gd index 4903981..e3bf47c 100644 --- a/behaviours/sampler_priority.gd +++ b/behaviours/sampler_priority.gd @@ -23,7 +23,7 @@ func sample() -> Priority: Log.p(self, "Sampled: %s (%d)" % [highest_possibility, highest_possibility.priority]) return highest_possibility.get_ref() -func get_refs() -> Array[Node]: +func get_all_refs() -> Array[Node]: var refs: Array[Node] = [] for possibility in possibilities: refs.append(possibility.get_ref())