Skip to content

Commit

Permalink
fix: fix / improve map visuals
Browse files Browse the repository at this point in the history
  • Loading branch information
schealex committed Apr 4, 2024
1 parent 2f95a26 commit 3c02acb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/international/mapVisuals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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',
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 3c02acb

Please sign in to comment.