From 9820eb944518c4e84a2827b8f00c85fdeb4a09fe Mon Sep 17 00:00:00 2001 From: Rendo Date: Tue, 8 Jul 2025 00:25:14 +0500 Subject: [PATCH] EffectBasedPlayer channel settings --- scenes/entities/Zombies/zombie.tscn | 9 ++++++++- scripts/audio/EffectBasedPlayer.cs | 8 +++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scenes/entities/Zombies/zombie.tscn b/scenes/entities/Zombies/zombie.tscn index 47f2b94..60dabed 100644 --- a/scenes/entities/Zombies/zombie.tscn +++ b/scenes/entities/Zombies/zombie.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=30 format=3 uid="uid://co11v3w8hbwgf"] +[gd_scene load_steps=32 format=3 uid="uid://co11v3w8hbwgf"] [ext_resource type="Script" uid="uid://dildme6epx8l4" path="res://scripts/components/zombies/RuntimeZombieData.cs" id="1_qq3f1"] [ext_resource type="Texture2D" uid="uid://bwdqbrnn7ygtr" path="res://assets/sprites/atlases/zombies/Зондби.png" id="2_4pdxh"] @@ -20,6 +20,7 @@ [ext_resource type="Script" uid="uid://b8r6fxsfjdo3a" path="res://scripts/audio/EffectBasedPlayer.cs" id="17_ltj46"] [ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://resources/effects/GarlicEffect.tres" id="18_2q05d"] [ext_resource type="Resource" uid="uid://7uj0oe656jfx" path="res://resources/effects/SnowSlow.tres" id="19_ccrjo"] +[ext_resource type="Script" uid="uid://c1x4n4nqyq72f" path="res://scripts/audio/ChannelSettings.cs" id="21_xnora"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_63ls2"] resource_local_to_scene = true @@ -76,6 +77,11 @@ flat_value = 0.2 percentage_value = 0.0 mult_value = 1.0 +[sub_resource type="Resource" id="Resource_dn8ha"] +script = ExtResource("21_xnora") +restartTreshold = -1.0 +metadata/_custom_type_script = "uid://c1x4n4nqyq72f" + [node name="Zombie" type="Node2D"] y_sort_enabled = true script = ExtResource("1_qq3f1") @@ -157,6 +163,7 @@ autostart = true script = ExtResource("17_ltj46") effectsToMap = Array[Resource]([ExtResource("18_2q05d"), ExtResource("19_ccrjo")]) streamsToMapTo = Array[AudioStream]([ExtResource("2_hh4qh"), ExtResource("3_ltj46")]) +streamSettings = Array[Object]([null, SubResource("Resource_dn8ha")]) [connection signal="OnDamaged" from="." to="HitPlayer" method="Play"] [connection signal="OnHPChanged" from="." to="CanvasGroup" method="DamageFlash"] diff --git a/scripts/audio/EffectBasedPlayer.cs b/scripts/audio/EffectBasedPlayer.cs index 1713e94..786d853 100644 --- a/scripts/audio/EffectBasedPlayer.cs +++ b/scripts/audio/EffectBasedPlayer.cs @@ -8,20 +8,22 @@ public partial class EffectBasedPlayer : Node { [Export] public Array effectsToMap; [Export] public Array streamsToMapTo; - private System.Collections.Generic.Dictionary effectToAudioMap = new(); + [Export] public Array streamSettings; + private System.Collections.Generic.Dictionary effectToAudioMap = new(); public override void _Ready() { GetParent().EffectStarted += OnEffectStarted; for (int i = 0; i < effectsToMap.Count; i++) { - effectToAudioMap.Add(effectsToMap[i], streamsToMapTo[i]); + effectToAudioMap.Add(effectsToMap[i], (streamsToMapTo[i],streamSettings[i])); } } public void OnEffectStarted(Effect what) { if (effectToAudioMap.ContainsKey(what) == false) return; - AudioSequencer.Play(what.Slot, effectToAudioMap[what]); + AudioSequencer.Play(what.Slot, effectToAudioMap[what].Item1); + AudioSequencer.ChangeSettings(what.Slot, effectToAudioMap[what].Item2); } }