1
- using System ;
2
- using System . Collections . Generic ;
1
+ using System . Collections . Generic ;
3
2
using System . Linq ;
4
- using RimWorld ;
5
3
using UnityEngine ;
6
4
using Verse ;
7
5
8
6
namespace HeatMap
9
7
{
10
8
public class RoomTemperatureDisplayer
11
9
{
12
- public List < RoomWithLabelCell > RoomsWithLabelCells { get ; } = new List < RoomWithLabelCell > ( ) ;
10
+ public List < IntVec3 > LabelCells { get ; } = new List < IntVec3 > ( ) ;
13
11
14
12
private int _nextUpdateTick ;
15
13
@@ -24,7 +22,7 @@ public void Update(int updateDelay)
24
22
_lastSeenMap = Find . CurrentMap ;
25
23
26
24
_nextUpdateTick = tick + updateDelay ;
27
- RoomsWithLabelCells . Clear ( ) ;
25
+ LabelCells . Clear ( ) ;
28
26
29
27
var map = Find . CurrentMap ;
30
28
foreach ( var room in map . regionGrid . allRooms )
@@ -33,7 +31,7 @@ public void Update(int updateDelay)
33
31
continue ;
34
32
35
33
var cell = GetBestCellForRoom ( room , map ) ;
36
- RoomsWithLabelCells . Add ( new RoomWithLabelCell ( room , cell ) ) ;
34
+ LabelCells . Add ( cell ) ;
37
35
}
38
36
}
39
37
@@ -81,7 +79,7 @@ private static IntVec3 GetBestCellForRoom(Room room, Map map)
81
79
82
80
public void Reset ( )
83
81
{
84
- RoomsWithLabelCells . Clear ( ) ;
82
+ LabelCells . Clear ( ) ;
85
83
_nextUpdateTick = 0 ;
86
84
}
87
85
@@ -90,18 +88,21 @@ public void OnGUI()
90
88
Text . Font = GameFont . Tiny ;
91
89
var map = Find . CurrentMap ;
92
90
CellRect currentViewRect = Find . CameraDriver . CurrentViewRect ;
93
- foreach ( var roomWithLabelCell in RoomsWithLabelCells )
91
+ foreach ( var cell in LabelCells )
94
92
{
95
- var cell = roomWithLabelCell . Cell ;
96
93
if ( ! currentViewRect . Contains ( cell ) )
97
94
continue ;
98
95
96
+ var room = cell . GetRoom ( map , RegionType . Set_All ) ;
97
+ if ( room == null )
98
+ continue ;
99
+
99
100
var panelLength = 20f ;
100
101
var panelHeight = 20f ;
101
102
var panelSize = new Vector2 ( panelLength , panelHeight ) ;
102
103
var drawTopLeft = GenMapUI . LabelDrawPosFor ( cell ) ;
103
104
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" ) ) ;
105
106
}
106
107
}
107
108
}
0 commit comments