Add SetParameter function in NamedStudioEventEmitter

programming
Nadine Ganz 2025-01-08 21:05:50 +01:00
parent 75d6785dc6
commit 7a66f72aa8
3 changed files with 31 additions and 0 deletions

View File

@ -217,6 +217,18 @@ public class BTC : MonoBehaviour {
} }
} }
[Task]
public void SetFloat(string objectName, string key, float value)
{
List<ComponentHandler> 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] [Task]
public void Enable(string objectName) public void Enable(string objectName)
{ {

View File

@ -180,6 +180,15 @@ public class ComponentHandler : MonoBehaviour {
Task.SetError(); 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) public virtual void Enable(MyBT.NodeState nodeState)
{ {
if (Task.isDebugging) if (Task.isDebugging)

View File

@ -114,6 +114,16 @@ public class NamedStudioEventEmitter : ComponentHandler {
return; return;
} }
} }
public override void SetFloat(NodeState nodeState, string key, float value)
{
if (nodeState == NodeState.FirstRun)
{
studioEventEmitter.SetParameter(key, value);
Task.SetSucceeded();
return;
}
}
#else #else
[Header("FMod Support disabled: Window->MyBT->PreCompiler Definitions")] [Header("FMod Support disabled: Window->MyBT->PreCompiler Definitions")]
public string dummy; public string dummy;