From 7a66f72aa8f2d4cab70dfe45251c3f2923856b41 Mon Sep 17 00:00:00 2001 From: Nadine Ganz Date: Wed, 8 Jan 2025 21:05:50 +0100 Subject: [PATCH] Add SetParameter function in NamedStudioEventEmitter --- Viagg-io/Assets/Packages/MyBT/BTC/BTC.cs | 12 ++++++++++++ .../Packages/MyBT/BTC/Handlers/ComponentHandler.cs | 9 +++++++++ .../MyBT/BTC/Handlers/NamedStudioEventEmitter.cs | 10 ++++++++++ 3 files changed, 31 insertions(+) diff --git a/Viagg-io/Assets/Packages/MyBT/BTC/BTC.cs b/Viagg-io/Assets/Packages/MyBT/BTC/BTC.cs index 745f807..363c919 100644 --- a/Viagg-io/Assets/Packages/MyBT/BTC/BTC.cs +++ b/Viagg-io/Assets/Packages/MyBT/BTC/BTC.cs @@ -217,6 +217,18 @@ public class BTC : MonoBehaviour { } } + [Task] + public void SetFloat(string objectName, string key, float value) + { + List handlers = GetHandlers(objectName); + handlers.ForEach(handler => handler.SetFloat(Task.getState, key, value)); + if (handlers.Count == 0) + { + Debug.LogWarning($"BTC.SetFloat: no components under the name '{objectName}'"); + Task.SetSucceeded(); + } + } + [Task] public void Enable(string objectName) { diff --git a/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/ComponentHandler.cs b/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/ComponentHandler.cs index 2fb74f0..790ac11 100644 --- a/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/ComponentHandler.cs +++ b/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/ComponentHandler.cs @@ -180,6 +180,15 @@ public class ComponentHandler : MonoBehaviour { Task.SetError(); } + public virtual void SetFloat(MyBT.NodeState nodeState, string key, float value) + { + if (Task.isDebugging) + { + Debug.LogWarning($"ComponentHandler.SetFloat: not implemented for {this.GetType()}"); + } + Task.SetError(); + } + public virtual void Enable(MyBT.NodeState nodeState) { if (Task.isDebugging) diff --git a/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/NamedStudioEventEmitter.cs b/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/NamedStudioEventEmitter.cs index ed9ff3a..d335ca0 100644 --- a/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/NamedStudioEventEmitter.cs +++ b/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/NamedStudioEventEmitter.cs @@ -114,6 +114,16 @@ public class NamedStudioEventEmitter : ComponentHandler { return; } } + + public override void SetFloat(NodeState nodeState, string key, float value) + { + if (nodeState == NodeState.FirstRun) + { + studioEventEmitter.SetParameter(key, value); + Task.SetSucceeded(); + return; + } + } #else [Header("FMod Support disabled: Window->MyBT->PreCompiler Definitions")] public string dummy;