Skip to content

Commit

Permalink
fix: Receive event values should be initialized properly
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Nov 14, 2024
1 parent 57000a2 commit d05a489
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/BasicBehaveEngine/nodes/customEvent/Receive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d05a489

Please sign in to comment.