diff --git a/src/game/gameLoop.ts b/src/game/gameLoop.ts index f197526..3016185 100644 --- a/src/game/gameLoop.ts +++ b/src/game/gameLoop.ts @@ -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 => { diff --git a/src/typings/features/board.d.ts b/src/typings/features/board.d.ts index 6346516..bea8579 100644 --- a/src/typings/features/board.d.ts +++ b/src/typings/features/board.d.ts @@ -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[]; }