Tested and fixed effect computations

This commit is contained in:
Stefan Zermatten
2021-09-23 15:22:01 +02:00
parent 2f893710e2
commit c0a9a1251d
14 changed files with 100 additions and 38 deletions

View File

@@ -5,7 +5,6 @@ import computeByType from '/imports/api/creature/computation/newEngine/computeCo
export default function computeCreatureComputation(computation){
const stack = [];
// Computation scope of {variableName: prop}
const scope = computation.scope;
const graph = computation.dependencyGraph;
// Add all nodes to the stack
graph.forEachNode(node => {
@@ -24,7 +23,7 @@ export default function computeCreatureComputation(computation){
top._visited = true;
stack.pop();
// Compute the top object of the stack
compute(graph, top, scope);
compute(computation, top);
} else {
top._visitedChildren = true;
// Push dependencies to graph to be computed first
@@ -33,12 +32,12 @@ export default function computeCreatureComputation(computation){
}
}
function compute(graph, node, scope){
function compute(computation, node){
// Determine the prop's active status by its toggles
computeToggles(node);
computeCalculations(node, scope);
computeToggles(computation, node);
computeCalculations(computation, node);
// Compute the property by type
computeByType[node.data?.type || '_variable']?.(graph, node, scope);
computeByType[node.data?.type || '_variable']?.(computation, node);
}
function pushDependenciesToStack(nodeId, graph, stack){