From 3c02acbef634fb3346c02e1ced31a6ce45c8dbc8 Mon Sep 17 00:00:00 2001 From: Alexander Scherer Date: Thu, 4 Apr 2024 03:13:28 +0200 Subject: [PATCH] fix: fix / improve map visuals --- src/international/mapVisuals.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/international/mapVisuals.ts b/src/international/mapVisuals.ts index 032bec4f4..27f52db91 100644 --- a/src/international/mapVisuals.ts +++ b/src/international/mapVisuals.ts @@ -22,7 +22,7 @@ export class MapVisualsManager { const roomMemory = Memory.rooms[roomName] const type = roomMemory[RoomMemoryKeys.type] - if (!type) continue + if (type === undefined || type === null) continue if (roomMemory[RoomMemoryKeys.type] === RoomTypes.commune) { this.visualizeCommune(roomName, roomMemory) @@ -45,11 +45,11 @@ export class MapVisualsManager { const room = Game.rooms[roomName] if (!room) continue - const anchor = room.roomManager.anchor - if (!anchor) throw Error('No anchor for mapVisuals commune ' + roomName) - + // Energy + const storedEnergy = room.roomManager.resourcesInStoringStructures.energy; + const storedEnergyPercent = Math.floor((storedEnergy / CommuneUtils.minStoredEnergy(room)) * 100); Game.map.visual.text( - `⚡${room.roomManager.resourcesInStoringStructures.energy} / ${CommuneUtils.minStoredEnergy(room)}`, + `⚡${storedEnergy}( ${storedEnergyPercent}%)`, new RoomPosition(2, 8, roomName), { align: 'left', @@ -85,6 +85,10 @@ export class MapVisualsManager { }, ) + const anchor = room.roomManager.anchor + // if (!anchor) throw Error('No anchor for mapVisuals commune ' + roomName) + if (!anchor) continue; + if (roomMemory[RoomMemoryKeys.workRequest]) { Game.map.visual.line( anchor || new RoomPosition(25, 25, roomName),