From 91fac7fa2335702723eaf3284cbc4b25e041e790 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 31 Mar 2026 06:17:35 +0200 Subject: [PATCH] Add function to compare interaction links --- src/interactions/interaction-links.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/interactions/interaction-links.ts b/src/interactions/interaction-links.ts index 5e2561d7..9244edd0 100644 --- a/src/interactions/interaction-links.ts +++ b/src/interactions/interaction-links.ts @@ -108,6 +108,26 @@ export function cloneInteractionLink(link: InteractionLink): InteractionLink { }; } +export function areInteractionLinksEqual(left: InteractionLink, right: InteractionLink): boolean { + if (left.id !== right.id || left.sourceEntityId !== right.sourceEntityId || left.trigger !== right.trigger) { + return false; + } + + if (left.action.type !== right.action.type) { + return false; + } + + switch (left.action.type) { + case "teleportPlayer": + return left.action.targetEntityId === (right.action as TeleportPlayerAction).targetEntityId; + case "toggleVisibility": + return ( + left.action.targetBrushId === (right.action as ToggleVisibilityAction).targetBrushId && + left.action.visible === (right.action as ToggleVisibilityAction).visible + ); + } +} + export function cloneInteractionLinkRegistry(links: Record): Record { return Object.fromEntries(Object.entries(links).map(([linkId, link]) => [linkId, cloneInteractionLink(link)])); }