Elin Modding Docs Doc
Loading...
Searching...
No Matches
Room.cs
1using System;
2using System.Collections.Generic;
3
4// Token: 0x020006AA RID: 1706
5public class Room : BaseArea
6{
7 // Token: 0x17000E35 RID: 3637
8 // (get) Token: 0x06003181 RID: 12673 RVA: 0x00115A50 File Offset: 0x00113C50
9 public bool HasRoof
10 {
11 get
12 {
13 return this.lot.idRoofStyle != 0;
14 }
15 }
16
17 // Token: 0x06003182 RID: 12674 RVA: 0x00115A60 File Offset: 0x00113C60
18 public override string ToString()
19 {
20 return this.uid.ToString() ?? "";
21 }
22
23 // Token: 0x06003183 RID: 12675 RVA: 0x00115A78 File Offset: 0x00113C78
24 public void OnLoad()
25 {
26 foreach (Point point in this.points)
27 {
28 point.cell.room = this;
29 }
30 EClass._map.rooms.mapIDs[this.uid] = this;
31 this.SetDirty();
32 }
33
34 // Token: 0x06003184 RID: 12676 RVA: 0x00115AF0 File Offset: 0x00113CF0
35 public void AddPoint(Point p)
36 {
37 this.points.Add(p);
38 p.cell.room = this;
39 this.lot = Lot.Void;
40 this.SetDirty();
41 }
42
43 // Token: 0x06003185 RID: 12677 RVA: 0x00115B1C File Offset: 0x00113D1C
44 public void OnRemove()
45 {
46 this.Clean();
47 for (int i = this.points.Count - 1; i >= 0; i--)
48 {
49 this.points[i].cell.room = null;
50 }
51 this.points.Clear();
52 EClass._map.rooms.dirtyLots = true;
53 }
54
55 // Token: 0x06003186 RID: 12678 RVA: 0x00115B79 File Offset: 0x00113D79
56 public void Clean()
57 {
58 this.plate = null;
59 }
60
61 // Token: 0x06003187 RID: 12679 RVA: 0x00115B84 File Offset: 0x00113D84
62 public void Refresh()
63 {
64 this.Clean();
65 this.roofCount.Clear();
66 this.x = (this.mx = this.points[0].x);
67 this.z = (this.mz = this.points[0].z);
68 this.mh = 0;
69 int num = 0;
70 int num2 = 0;
71 int num3 = 0;
72 int num4 = 0;
73 this.pointMinX = this.points[0];
74 this.pointMaxX = this.points[0];
75 foreach (Point point in this.points)
76 {
77 Cell cell = point.cell;
78 if (point.x < this.x)
79 {
80 this.x = point.x;
81 }
82 else if (point.x > this.mx)
83 {
84 this.mx = point.x;
85 }
86 if (point.z < this.z)
87 {
88 this.z = point.z;
89 }
90 else if (point.z > this.mz)
91 {
92 this.mz = point.z;
93 }
94 if (point.x + point.z < this.pointMinX.x + this.pointMinX.z)
95 {
96 this.pointMinX = point;
97 }
98 if (point.x + point.z > this.pointMaxX.x + this.pointMaxX.z)
99 {
100 this.pointMaxX = point;
101 }
102 bool hasFullBlockOrWallOrFence = cell.HasFullBlockOrWallOrFence;
103 if ((int)cell.TopHeight > this.mh && hasFullBlockOrWallOrFence)
104 {
105 this.mh = (int)cell.TopHeight;
106 }
107 if (hasFullBlockOrWallOrFence)
108 {
109 TileType tileType = point.sourceBlock.tileType;
110 if (tileType.IsWall)
111 {
112 num3++;
113 }
114 else if (tileType.IsFence)
115 {
116 num2++;
117 }
118 else
119 {
120 num++;
121 }
122 int num5 = point.sourceBlock.id * 1000 + point.matBlock.id;
123 if (!this.roofCount.ContainsKey(num5))
124 {
125 this.roofCount[num5] = 0;
126 }
127 Dictionary<int, int> dictionary = this.roofCount;
128 int key = num5;
129 int num6 = dictionary[key];
130 dictionary[key] = num6 + 1;
131 }
132 if (this.plate == null)
133 {
134 this.plate = point.GetInstalled<TraitRoomPlate>();
135 }
136 num4 += point.x + point.z * 256;
137 cell.fullWall = false;
138 cell.lotWall = false;
139 }
140 int num7 = (this.mx - this.x + this.pointMinX.z - this.z) / 2;
141 int num8 = this.pointMaxX.x - this.pointMinX.x + this.pointMaxX.z - this.pointMinX.z + 1;
142 int num9 = (this.mx - this.x + this.mz - this.z) / 2 + 2;
143 int num10 = this.pointMinX.x + num7 - num9;
144 int num11 = this.pointMinX.z - num7 + num9;
145 int num12 = 0;
146 for (int i = 0; i < num8; i++)
147 {
148 int num13 = num10;
149 int num14 = num11;
150 bool flag = false;
151 for (int j = 0; j < num9 + 1; j++)
152 {
153 if (num14 >= num12 - 1 && num13 >= 0 && num14 >= 0 && num13 < EClass._map.Size && num14 < EClass._map.Size)
154 {
155 Cell cell2 = EClass._map.cells[num13, num14];
156 if (flag && (cell2.room != this || (!cell2.HasFullBlock && !cell2.HasWall)))
157 {
158 break;
159 }
160 if (cell2.room == this)
161 {
162 cell2.fullWall = true;
163 if (!flag && !cell2.HasFullBlock && !cell2.HasWall)
164 {
165 break;
166 }
167 flag = true;
168 num12 = num14;
169 }
170 num13++;
171 num14--;
172 }
173 }
174 if (i % 2 == 0)
175 {
176 num10++;
177 }
178 else
179 {
180 num11++;
181 }
182 }
183 this.fullblock = (num > num3);
184 this.roof = ((this.mx - this.x + (this.mz - this.z)) / 2 > num2);
185 this.dirty = false;
186 EClass._map.rooms.dirtyLots = true;
187 this.type = new AreaTypeRoom
188 {
189 owner = this
190 };
191 base.SetRandomName(num4);
192 if (this.plate != null)
193 {
194 this.data.name = this.plate.areaData.name;
195 if (this.plate.areaData.type != null)
196 {
197 this.type = this.plate.areaData.type;
198 }
199 this.data.group = this.plate.areaData.group;
200 this.data.atrium = this.plate.areaData.atrium;
201 }
202 }
203
204 // Token: 0x06003188 RID: 12680 RVA: 0x001160BC File Offset: 0x001142BC
205 public void SetDirty()
206 {
207 this.dirty = true;
208 EClass._map.rooms.dirtyRooms = true;
209 }
210
211 // Token: 0x04001B83 RID: 7043
212 public int x;
213
214 // Token: 0x04001B84 RID: 7044
215 public int z;
216
217 // Token: 0x04001B85 RID: 7045
218 public int mx;
219
220 // Token: 0x04001B86 RID: 7046
221 public int mz;
222
223 // Token: 0x04001B87 RID: 7047
224 public int mh;
225
226 // Token: 0x04001B88 RID: 7048
227 public bool dirty;
228
229 // Token: 0x04001B89 RID: 7049
230 public bool roof;
231
232 // Token: 0x04001B8A RID: 7050
233 public bool fullblock;
234
235 // Token: 0x04001B8B RID: 7051
236 public Lot lot;
237
238 // Token: 0x04001B8C RID: 7052
239 public Point pointMinX;
240
241 // Token: 0x04001B8D RID: 7053
242 public Point pointMaxX;
243
244 // Token: 0x04001B8E RID: 7054
245 public Dictionary<int, int> roofCount = new Dictionary<int, int>();
246}
Definition Cell.cs:10
Definition Lot.cs:7
Definition Point.cs:11
Definition Room.cs:6