Added update() method to nodes

This commit is contained in:
thepaperpilot 2021-08-20 22:07:34 -05:00
parent fbe4f7883f
commit 0ced1d7cd7
2 changed files with 12 additions and 2 deletions

View file

@ -68,6 +68,14 @@ function updateLayers(diff: DecimalSource) {
);
}
layers[layer].update?.(diff);
if (layers[layer].boards) {
Reflect.ownKeys(player.layers[layer].boards).forEach(board => {
player.layers[layer].boards[board.toString()].forEach(node => {
const nodeType = layers[layer].boards!.data[board.toString()].types[node.type];
nodeType.update?.(node, diff);
});
});
}
});
// Automate each active layer
activeLayers.forEach(layer => {

View file

@ -1,3 +1,4 @@
import { DecimalSource } from "@/lib/break_eternity";
import { State } from "../state";
import { Feature, RawFeature } from "./feature";
@ -41,7 +42,8 @@ export interface NodeType extends Feature {
fillColor?: string | ((node: BoardNode) => string);
outlineColor?: string | ((node: BoardNode) => string);
titleColor?: string | ((node: BoardNode) => string);
onClick: (node: BoardNode) => void;
onDrop: (node: BoardNode, otherNode: BoardNode) => void;
onClick?: (node: BoardNode) => void;
onDrop?: (node: BoardNode, otherNode: BoardNode) => void;
update?: (node: BoardNode, diff: DecimalSource) => void;
nodes: BoardNode[];
}