From f2808507ea4e46999df2b55b407263321dd3078d Mon Sep 17 00:00:00 2001 From: Aitolda <21160271+Aitolda@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:05:17 -0500 Subject: [PATCH] Fixed "undefined" ZoneEntityController name ZoneEntityController will now get it's suffix and ID from it's parent Zone --- .../components/controllers/ZoneEntityController.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/entity/components/controllers/ZoneEntityController.ts b/src/modules/entity/components/controllers/ZoneEntityController.ts index 20bf00bf..665a69f5 100644 --- a/src/modules/entity/components/controllers/ZoneEntityController.ts +++ b/src/modules/entity/components/controllers/ZoneEntityController.ts @@ -79,10 +79,15 @@ export class ZoneEntityController extends EntityController { private _zoneMesh: Mesh | null = null; constructor(entity: IZoneEntity) { - // Extract the numeric part from the zone's ID - const zoneNumber = entity.id.split('_')[1]; + // Extract a unique identifier from the zone's ID + let uniqueId = "unknown"; + if (entity.id) { + const parts = entity.id.split('_'); + uniqueId = parts.length > 1 ? parts[1] : entity.id; + } + // Create a unique ID for this controller - const controllerId = `ZoneEntityController_${zoneNumber}`; + const controllerId = `ZoneEntityController_${uniqueId}`; super(entity, controllerId); this._zoneEntity = entity;