From d05a489b5e91bf879e51b55ad0689e2119b8be58 Mon Sep 17 00:00:00 2001 From: hybridherbst Date: Thu, 14 Nov 2024 13:53:33 +0100 Subject: [PATCH] fix: Receive event values should be initialized properly --- .../nodes/customEvent/Receive.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/BasicBehaveEngine/nodes/customEvent/Receive.ts b/src/BasicBehaveEngine/nodes/customEvent/Receive.ts index 84c6790..eb15ff5 100644 --- a/src/BasicBehaveEngine/nodes/customEvent/Receive.ts +++ b/src/BasicBehaveEngine/nodes/customEvent/Receive.ts @@ -17,14 +17,25 @@ export class Receive extends BehaveEngineNode { const customEventDesc: ICustomEvent = this.events[event]; + customEventDesc.values.forEach((key) => { + // TODO Probably should be the default value based on type + // TODO Spec says that the default for float is NaN, not sure why + const defaultValue = 0; + this.outValues[key.id] = { + id: key.id, + value: defaultValue, + type: key.type, + } + }); + this.graphEngine.addCustomEventListener(`KHR_INTERACTIVITY:${customEventDesc.id}`, (e: any) => { this.graphEngine.processNodeStarted(this); - const ce = e as CustomEvent; - Object.keys(ce.detail).forEach((key) => { + const ce = (e as CustomEvent).detail as { [key: string]: any }; + Object.keys(ce).forEach((key) => { const typeIndex = customEventDesc.values.find(val => val.id === key)!.type! const typeName: string = this.getType(typeIndex); - const rawVal = ce.detail[key]; - const val = this.parseType(typeName, rawVal); + const rawVal = ce[key]; + const val = this.parseType(typeName, [rawVal]); this.outValues[key] = { id: key, value: val,