diff --git a/behaviours/priority.gd b/behaviours/priority.gd new file mode 100644 index 0000000..e1e9e39 --- /dev/null +++ b/behaviours/priority.gd @@ -0,0 +1,10 @@ +@icon("res://behaviours/priority.svg") +extends Node +class_name Priority + + +@export var priority: int = 0 + + +func get_ref() -> Node: + return get_parent() diff --git a/behaviours/priority.svg b/behaviours/priority.svg new file mode 100644 index 0000000..5223e43 --- /dev/null +++ b/behaviours/priority.svg @@ -0,0 +1,39 @@ + + + + + + + diff --git a/behaviours/priority.svg.import b/behaviours/priority.svg.import new file mode 100644 index 0000000..9148364 --- /dev/null +++ b/behaviours/priority.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ctc4lx571jksr" +path="res://.godot/imported/priority.svg-d16c10b6303969bc43c2b8feaccb77ae.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/priority.svg" +dest_files=["res://.godot/imported/priority.svg-d16c10b6303969bc43c2b8feaccb77ae.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/behaviours/priority.tscn b/behaviours/priority.tscn new file mode 100644 index 0000000..1c489db --- /dev/null +++ b/behaviours/priority.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cm67ko1k6kn4u"] + +[ext_resource type="Script" path="res://behaviours/priority.gd" id="1_8u7ji"] + +[node name="Priority" type="Node"] +script = ExtResource("1_8u7ji") diff --git a/behaviours/sampler.gd b/behaviours/sampler.gd index 1b208a5..1c63eea 100644 --- a/behaviours/sampler.gd +++ b/behaviours/sampler.gd @@ -1,3 +1,4 @@ +@icon("res://behaviours/sampler.svg") extends Node class_name Sampler diff --git a/behaviours/sampler.svg b/behaviours/sampler.svg new file mode 100644 index 0000000..de84648 --- /dev/null +++ b/behaviours/sampler.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + diff --git a/behaviours/sampler.svg.import b/behaviours/sampler.svg.import new file mode 100644 index 0000000..4b58e6a --- /dev/null +++ b/behaviours/sampler.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cv32pf38ugoh1" +path="res://.godot/imported/sampler.svg-3634a55299eb9a683092cba4e7d215f9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/sampler.svg" +dest_files=["res://.godot/imported/sampler.svg-3634a55299eb9a683092cba4e7d215f9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/behaviours/sampler_priority.gd b/behaviours/sampler_priority.gd index 4aafaf5..ca3ea44 100644 --- a/behaviours/sampler_priority.gd +++ b/behaviours/sampler_priority.gd @@ -5,4 +5,21 @@ class_name SamplerPriority ## Always sample the object with the highest priority in the queue. -## TODO \ No newline at end of file +@export var possibilities: Array[Priority] = [] + + +## Get a reference. +func sample() -> Priority: + if len(possibilities) == 0: + return null + + # FIXME: Change this to something more efficient when needed + var highest_possibility: Priority = null + for possibility in possibilities: + if possibility.priority > highest_possibility.priority: + highest_possibility = possibility + + if highest_possibility == null: + return null + + return highest_possibility.get_ref()