From 450e41a131eba2b641aa7d6926545e1e65c19889 Mon Sep 17 00:00:00 2001 From: Jonathan Bell Date: Tue, 19 Mar 2024 09:00:45 -0400 Subject: [PATCH] Fixes crash when attempting to use a viewing area --- frontend/src/classes/TownController.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/classes/TownController.ts b/frontend/src/classes/TownController.ts index c14989d1a..c30c5d2cf 100644 --- a/frontend/src/classes/TownController.ts +++ b/frontend/src/classes/TownController.ts @@ -773,13 +773,20 @@ export function useTownSettings() { */ export function useInteractableAreaController(interactableAreaID: string): T { const townController = useTownController(); - const interactableAreaController = townController.gameAreas.find( + const gameAreaController = townController.gameAreas.find( eachArea => eachArea.id == interactableAreaID, ); - if (!interactableAreaController) { + if (!gameAreaController) { + //Look for a viewing area + const viewingAreaController = townController.viewingAreas.find( + eachArea => eachArea.id == interactableAreaID, + ); + if (viewingAreaController) { + return viewingAreaController as unknown as T; + } throw new Error(`Requested interactable area ${interactableAreaID} does not exist`); } - return interactableAreaController as unknown as T; + return gameAreaController as unknown as T; } /**