Skip to content

Commit

Permalink
Default parameters for networked variables
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Oct 17, 2023
1 parent b00f299 commit 9834bf2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/inflators/networked-behavior.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { addComponent } from "bitecs";
import { Networked, NetworkedBehavior } from "../bit-components";
import { Networked, NetworkedBehavior, NetworkedBehaviorData } from "../bit-components";
import { HubsWorld } from "../app";

export function inflateNetworkedBehavior(world: HubsWorld, eid: number): number {
type NetworkedBehaviorType = {
[key: string]: any;
};

export function inflateNetworkedBehavior(world: HubsWorld, eid: number, params: NetworkedBehaviorType): number {
addComponent(world, Networked, eid);
addComponent(world, NetworkedBehavior, eid);
if (params) {
const data = NetworkedBehaviorData.get(eid) || new Map();
for (let key in params) {
data.set(key, params[key]);
NetworkedBehaviorData.set(eid, data);
}
}
return eid;
}

0 comments on commit 9834bf2

Please sign in to comment.