Skip to content

Commit 9dcb677

Browse files
committed
Fix error when room is deleted
1 parent d8d8c21 commit 9dcb677

File tree

4 files changed

+13
-30
lines changed

4 files changed

+13
-30
lines changed

src/HeatMap/HeatMap.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@
235235
<Compile Include="Properties\AssemblyInfo.cs" />
236236
<Compile Include="Resources.cs" />
237237
<Compile Include="RoomTemperatureDisplayer.cs" />
238-
<Compile Include="RoomWithLabelCell.cs" />
239238
</ItemGroup>
240239
<ItemGroup>
241240
<Content Include="..\..\mod-structure\About\About.xml">

src/HeatMap/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.1.9.0")]
35-
[assembly: AssemblyFileVersion("1.1.9.0")]
34+
[assembly: AssemblyVersion("1.1.10.0")]
35+
[assembly: AssemblyFileVersion("1.1.10.0")]
3636

3737

3838

src/HeatMap/RoomTemperatureDisplayer.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
4-
using RimWorld;
53
using UnityEngine;
64
using Verse;
75

86
namespace HeatMap
97
{
108
public class RoomTemperatureDisplayer
119
{
12-
public List<RoomWithLabelCell> RoomsWithLabelCells { get; } = new List<RoomWithLabelCell>();
10+
public List<IntVec3> LabelCells { get; } = new List<IntVec3>();
1311

1412
private int _nextUpdateTick;
1513

@@ -24,7 +22,7 @@ public void Update(int updateDelay)
2422
_lastSeenMap = Find.CurrentMap;
2523

2624
_nextUpdateTick = tick + updateDelay;
27-
RoomsWithLabelCells.Clear();
25+
LabelCells.Clear();
2826

2927
var map = Find.CurrentMap;
3028
foreach (var room in map.regionGrid.allRooms)
@@ -33,7 +31,7 @@ public void Update(int updateDelay)
3331
continue;
3432

3533
var cell = GetBestCellForRoom(room, map);
36-
RoomsWithLabelCells.Add(new RoomWithLabelCell(room, cell));
34+
LabelCells.Add(cell);
3735
}
3836
}
3937

@@ -81,7 +79,7 @@ private static IntVec3 GetBestCellForRoom(Room room, Map map)
8179

8280
public void Reset()
8381
{
84-
RoomsWithLabelCells.Clear();
82+
LabelCells.Clear();
8583
_nextUpdateTick = 0;
8684
}
8785

@@ -90,18 +88,21 @@ public void OnGUI()
9088
Text.Font = GameFont.Tiny;
9189
var map = Find.CurrentMap;
9290
CellRect currentViewRect = Find.CameraDriver.CurrentViewRect;
93-
foreach (var roomWithLabelCell in RoomsWithLabelCells)
91+
foreach (var cell in LabelCells)
9492
{
95-
var cell = roomWithLabelCell.Cell;
9693
if (!currentViewRect.Contains(cell))
9794
continue;
9895

96+
var room = cell.GetRoom(map, RegionType.Set_All);
97+
if (room == null)
98+
continue;
99+
99100
var panelLength = 20f;
100101
var panelHeight = 20f;
101102
var panelSize = new Vector2(panelLength, panelHeight);
102103
var drawTopLeft = GenMapUI.LabelDrawPosFor(cell);
103104
var labelRect = new Rect(drawTopLeft.x, drawTopLeft.y, panelSize.x, panelSize.y);
104-
Widgets.Label(labelRect, roomWithLabelCell.Room.Temperature.ToStringTemperature("F0"));
105+
Widgets.Label(labelRect, room.Temperature.ToStringTemperature("F0"));
105106
}
106107
}
107108
}

src/HeatMap/RoomWithLabelCell.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)