Skip to content

Commit

Permalink
Use the right component entity in get/set component property
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Nov 17, 2023
1 parent 70a794a commit 8e4a242
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/bit-systems/behavior-graph/entity-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,16 +653,16 @@ function makeMaterialPropertyNodes<T extends SettableMaterialProperties, S exten
const entity = read("entity") as EntityID;

const { component, set } = getComponentBindings(componentName);
if (set) {
if (configuration.networked) {
const cmpEid = findChildWithComponent(world, component, entity);
if (cmpEid) {
if (set && component) {
const cmpEid = findChildWithComponent(world, component, entity);
if (cmpEid) {
if (configuration.networked) {
takeOwnership(world, cmpEid);
}
set(world, cmpEid, {
[propertyName]: read(type)
});
}
set(world, entity, {
[propertyName]: read(type)
});
} else {
console.error(`Set not supported for ${componentName}.${propertyName}`);
}
Expand Down Expand Up @@ -715,12 +715,15 @@ function makeMaterialPropertyNodes<T extends SettableMaterialProperties, S exten

const entity = read("entity") as EntityID;

const { get } = getComponentBindings(componentName);
if (get) {
const props = get(world, entity);
write(type, props[propertyName]);
} else {
console.error(`Get not supported for ${componentName}.${propertyName}`);
const { get, component } = getComponentBindings(componentName);
const cmpEid = findChildWithComponent(world, component, entity);
if (cmpEid) {
if (get) {
const props = get(world, cmpEid);
write(type, props[propertyName]);
} else {
console.error(`Get not supported for ${componentName}.${propertyName}`);
}
}
}
})
Expand Down

0 comments on commit 8e4a242

Please sign in to comment.