Skip to content

Commit

Permalink
Update networkedVariable node to support input entity socket
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Sep 14, 2023
1 parent 1d99f49 commit 5a95973
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/bit-systems/behavior-graph/networking-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ export const NetworkingNodes = definitionListToMap([
category: "Components" as any,
label: "Networked Variable Set",
configuration: {
target: {
valueType: "entity"
},
prop_name: {
valueType: "string"
},
Expand All @@ -150,6 +147,10 @@ export const NetworkingNodes = definitionListToMap([
key: "flow",
valueType: "flow"
},
{
key: "entity",
valueType: "entity"
},
{
key: type,
valueType: type,
Expand All @@ -162,12 +163,12 @@ export const NetworkingNodes = definitionListToMap([
initialState: undefined,
out: { flow: "flow" },
triggered: ({ read, commit, configuration }) => {
const entity = configuration.target as EntityID;
const name = configuration.prop_name as string;
const type = configuration.prop_type as string;

const data = NetworkedBehaviorData.get(entity) || new Map();
const entity = read("entity") as EntityID;
const value = read(type);
const data = NetworkedBehaviorData.get(entity) || new Map();
data.set(name, value);
NetworkedBehaviorData.set(entity, data);
NetworkedBehavior.timestamp[entity] = performance.now();
Expand All @@ -180,17 +181,23 @@ export const NetworkingNodes = definitionListToMap([
category: "Components" as any,
label: "Get",
configuration: {
target: {
valueType: "entity"
},
prop_name: {
valueType: "string"
},
prop_type: {
valueType: "string"
}
},
in: {},
in: () => {
const sockets: SocketsList = [
{
key: "entity",
valueType: "entity"
}
];

return sockets;
},
out: configuration => {
const type = configuration.prop_type || "string";
const name = configuration.prop_name || "prop";
Expand All @@ -205,11 +212,11 @@ export const NetworkingNodes = definitionListToMap([

return result;
},
exec: ({ write, configuration }) => {
const entity = configuration.target as EntityID;
exec: ({ read, write, configuration }) => {
const name = configuration.prop_name as string;
const type = configuration.prop_type || "string";

const entity = read("entity") as EntityID;
if (NetworkedBehaviorData.has(entity)) {
const data = NetworkedBehaviorData.get(entity)!;
if (data.has(name)) {
Expand Down

0 comments on commit 5a95973

Please sign in to comment.