From b172e919d94a8e1cd39ecccf638f37dd4010a9d8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Apr 2024 03:11:57 +0200 Subject: [PATCH] Refactor `SpawnerChoice` --- behaviours/spawner_choice.gd | 9 +++++- behaviours/spawner_choice.svg | 41 ++++++++++++++++++++++++++++ behaviours/spawner_choice.svg.import | 37 +++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 behaviours/spawner_choice.svg create mode 100644 behaviours/spawner_choice.svg.import diff --git a/behaviours/spawner_choice.gd b/behaviours/spawner_choice.gd index 71def18..8af2a02 100644 --- a/behaviours/spawner_choice.gd +++ b/behaviours/spawner_choice.gd @@ -1,6 +1,11 @@ +@icon("res://behaviours/spawner_choice.svg") extends Node class_name SpawnerChoice +## Randomly choose a [Spawner] to use from [field spawners] considering [field weights]. +## +## If a null [Spawner] is selected, nothing is spawned. + @export var spawners: Array[Spawner] = [] @export var weights: Array[int] = [] @@ -24,7 +29,9 @@ func select_spawner() -> Spawner: return spawners[idx] func spawn(): - select_spawner().spawn() + var spawner = select_spawner() + if spawner != null: + spawner.spawn() func _ready(): diff --git a/behaviours/spawner_choice.svg b/behaviours/spawner_choice.svg new file mode 100644 index 0000000..6665d20 --- /dev/null +++ b/behaviours/spawner_choice.svg @@ -0,0 +1,41 @@ + + diff --git a/behaviours/spawner_choice.svg.import b/behaviours/spawner_choice.svg.import new file mode 100644 index 0000000..ad1beae --- /dev/null +++ b/behaviours/spawner_choice.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c0f5nbe7lhib6" +path="res://.godot/imported/spawner_choice.svg-91bce9cbbb63e3eb7738ffe03834ed28.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://behaviours/spawner_choice.svg" +dest_files=["res://.godot/imported/spawner_choice.svg-91bce9cbbb63e3eb7738ffe03834ed28.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