diff --git a/behaviours/spawner_choice.gd b/behaviours/spawner_choice.gd new file mode 100644 index 0000000..71def18 --- /dev/null +++ b/behaviours/spawner_choice.gd @@ -0,0 +1,34 @@ +extends Node +class_name SpawnerChoice + + +@export var spawners: Array[Spawner] = [] +@export var weights: Array[int] = [] + + +func compute_total_weight() -> int: + var total = 0 + for weight in weights: + if weight < 0: + Log.e(self, "Weight with negative value detected.") + total += weight + return total + +func select_spawner() -> Spawner: + var total = compute_total_weight() + var sampled = Random.rng.randi_range(0, total - 1) + var idx = -1 + while sampled >= 0: + idx += 1 + sampled -= weights[idx] + return spawners[idx] + +func spawn(): + select_spawner().spawn() + + +func _ready(): + if len(spawners) != len(weights): + Log.e(self, "Spawners and weights are different lengths.") + if compute_total_weight() <= 0: + Log.e(self, "Weight total is less or equal to 0.") diff --git a/behaviours/spawner_choice.tscn b/behaviours/spawner_choice.tscn new file mode 100644 index 0000000..b11a7b0 --- /dev/null +++ b/behaviours/spawner_choice.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cokdfsk6rgeup"] + +[ext_resource type="Script" path="res://behaviours/spawner_choice.gd" id="1_jkwdb"] + +[node name="SpawnerChoice" type="Node"] +script = ExtResource("1_jkwdb") diff --git a/temp/bones.wav b/temp/bones.wav index 610d47c..62b8b2b 100644 Binary files a/temp/bones.wav and b/temp/bones.wav differ diff --git a/temp/bones.wav.import b/temp/bones.wav.import new file mode 100644 index 0000000..8ba7e5d --- /dev/null +++ b/temp/bones.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dq3xf4i2wpt50" +path="res://.godot/imported/bones.wav-53a2d1735511ef1f1bf2921348b332aa.sample" + +[deps] + +source_file="res://temp/bones.wav" +dest_files=["res://.godot/imported/bones.wav-53a2d1735511ef1f1bf2921348b332aa.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/temp/click&pop.wav b/temp/click&pop.wav index afb5170..39ea710 100644 Binary files a/temp/click&pop.wav and b/temp/click&pop.wav differ diff --git a/temp/click&pop.wav.import b/temp/click&pop.wav.import new file mode 100644 index 0000000..c1ba1f8 --- /dev/null +++ b/temp/click&pop.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://byn68h5qg6p5x" +path="res://.godot/imported/click&pop.wav-72c07aaf987d2bd80254015b6c36b256.sample" + +[deps] + +source_file="res://temp/click&pop.wav" +dest_files=["res://.godot/imported/click&pop.wav-72c07aaf987d2bd80254015b6c36b256.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/temp/gore.wav b/temp/gore.wav index 43e0777..681e56b 100644 Binary files a/temp/gore.wav and b/temp/gore.wav differ diff --git a/temp/gore.wav.import b/temp/gore.wav.import new file mode 100644 index 0000000..59719b5 --- /dev/null +++ b/temp/gore.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dlp0oo8tbp3w1" +path="res://.godot/imported/gore.wav-c74757bf12b5b41aaaf2eb9a0f1110a0.sample" + +[deps] + +source_file="res://temp/gore.wav" +dest_files=["res://.godot/imported/gore.wav-c74757bf12b5b41aaaf2eb9a0f1110a0.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/temp/mouth_pop.wav b/temp/mouth_pop.wav deleted file mode 100644 index b3890ce..0000000 Binary files a/temp/mouth_pop.wav and /dev/null differ diff --git a/temp/place.wav b/temp/place.wav index 1988a33..2dbb33c 100644 Binary files a/temp/place.wav and b/temp/place.wav differ diff --git a/temp/place.wav.import b/temp/place.wav.import new file mode 100644 index 0000000..b94a9be --- /dev/null +++ b/temp/place.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://buxgivpkh8dyl" +path="res://.godot/imported/place.wav-6f3a5aef81053f3b0b94fbbb722a0c32.sample" + +[deps] + +source_file="res://temp/place.wav" +dest_files=["res://.godot/imported/place.wav-6f3a5aef81053f3b0b94fbbb722a0c32.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/temp/pop.wav b/temp/pop.wav index 79eedd2..523a1e2 100644 Binary files a/temp/pop.wav and b/temp/pop.wav differ diff --git a/temp/pop.wav.import b/temp/pop.wav.import new file mode 100644 index 0000000..82ce6ca --- /dev/null +++ b/temp/pop.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dgd1ldpffk6ql" +path="res://.godot/imported/pop.wav-5c8ab1a460889e6b7e24366eae5d4a3a.sample" + +[deps] + +source_file="res://temp/pop.wav" +dest_files=["res://.godot/imported/pop.wav-5c8ab1a460889e6b7e24366eae5d4a3a.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/temp/puff.wav b/temp/puff.wav index e188675..325f6de 100644 Binary files a/temp/puff.wav and b/temp/puff.wav differ diff --git a/temp/puff.wav.import b/temp/puff.wav.import new file mode 100644 index 0000000..b1d7783 --- /dev/null +++ b/temp/puff.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cwvdddro7u38g" +path="res://.godot/imported/puff.wav-5458e43df0efe164a3d8534b8a23be21.sample" + +[deps] + +source_file="res://temp/puff.wav" +dest_files=["res://.godot/imported/puff.wav-5458e43df0efe164a3d8534b8a23be21.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/temp/sheep.wav b/temp/sheep.wav index 44010fb..4828122 100644 Binary files a/temp/sheep.wav and b/temp/sheep.wav differ diff --git a/temp/sheep.wav.import b/temp/sheep.wav.import new file mode 100644 index 0000000..140fa34 --- /dev/null +++ b/temp/sheep.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bmfscpnugaejk" +path="res://.godot/imported/sheep.wav-5e192fa241f3aae906a657036a0b94de.sample" + +[deps] + +source_file="res://temp/sheep.wav" +dest_files=["res://.godot/imported/sheep.wav-5e192fa241f3aae906a657036a0b94de.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/temp/tollbell.mp3 b/temp/tollbell.mp3 index f89c465..9393601 100644 Binary files a/temp/tollbell.mp3 and b/temp/tollbell.mp3 differ diff --git a/temp/tollbell.mp3.import b/temp/tollbell.mp3.import new file mode 100644 index 0000000..2520230 --- /dev/null +++ b/temp/tollbell.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://bwfscrmf25vkv" +path="res://.godot/imported/tollbell.mp3-eacf00af005e4b329c6241109d68c18b.mp3str" + +[deps] + +source_file="res://temp/tollbell.mp3" +dest_files=["res://.godot/imported/tollbell.mp3-eacf00af005e4b329c6241109d68c18b.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4