Skip to content

Commit

Permalink
Networked behavior variables type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Oct 17, 2023
1 parent 8426c79 commit 5980642
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/inflators/networked-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Networked, NetworkedBehavior, NetworkedBehaviorData } from "../bit-comp
import { HubsWorld } from "../app";

type NetworkedBehaviorType = {
[key: string]: any;
[key: string]: {
type: string;
value: any;
};
};

export function inflateNetworkedBehavior(world: HubsWorld, eid: number, params: NetworkedBehaviorType): number {
Expand All @@ -12,9 +15,15 @@ export function inflateNetworkedBehavior(world: HubsWorld, eid: number, params:
if (params) {
const data = NetworkedBehaviorData.get(eid) || new Map();
for (let key in params) {
data.set(key, params[key]);
NetworkedBehaviorData.set(eid, data);
const type = params[key].type;
const value = params[key].value;
if (type === "integer") {
data.set(key, BigInt(value));
} else {
data.set(key, value);
}
}
NetworkedBehaviorData.set(eid, data);
}
return eid;
}

0 comments on commit 5980642

Please sign in to comment.