Elin Modding Docs Doc
Loading...
Searching...
No Matches
Lot.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x020006A8 RID: 1704
6public class Lot : EClass
7{
8 // Token: 0x0600317A RID: 12666 RVA: 0x00114F1C File Offset: 0x0011311C
9 public void SetBaseRoom(Room r)
10 {
11 this.board = null;
12 this.fullblock = false;
13 Lot.minX = r.x;
14 Lot.maxX = r.mx;
15 Lot.minZ = r.z;
16 Lot.maxZ = r.mz;
17 this.mh = r.mh;
18 this.pointMinX = r.pointMinX;
19 this.pointMaxX = r.pointMaxX;
20 this.AddConnectedRooms(r);
21 this.x = Lot.minX;
22 this.mx = Lot.maxX;
23 this.z = Lot.minZ;
24 this.mz = Lot.maxZ;
25 bool flag = false;
26 Lot.roofCount.Clear();
27 foreach (Room room in EClass._map.rooms.listRoom)
28 {
29 if (room.lot == this)
30 {
31 if (room.roof)
32 {
33 flag = true;
34 }
35 if (room.fullblock)
36 {
37 this.fullblock = true;
38 }
39 foreach (KeyValuePair<int, int> keyValuePair in room.roofCount)
40 {
41 if (!Lot.roofCount.ContainsKey(keyValuePair.Key))
42 {
43 Lot.roofCount[keyValuePair.Key] = 0;
44 }
45 Dictionary<int, int> dictionary = Lot.roofCount;
46 int key = keyValuePair.Key;
47 dictionary[key] += keyValuePair.Value;
48 }
49 }
50 }
51 int num = 0;
52 int num2 = 0;
53 foreach (KeyValuePair<int, int> keyValuePair2 in Lot.roofCount)
54 {
55 if (keyValuePair2.Value > num)
56 {
57 num = keyValuePair2.Value;
58 num2 = keyValuePair2.Key;
59 }
60 }
61 if (this.board != null)
62 {
63 if (this.board.data == null)
64 {
65 TraitHouseBoard.Data data = this.board.data = new TraitHouseBoard.Data();
66 CoreRef.DefaultRoof defaultRoof = EClass.core.refs.defaultRoofs[EClass.sources.blocks.map[num2 / 1000].roof];
67 data.height = (this.fullblock ? 1 : 2);
68 data.heightFix = (this.fullblock ? 40 : 0);
69 data.reverse = (EClass.rnd(2) == 0);
70 data.idRoofStyle = ((!EClass._map.IsIndoor && flag) ? 2 : 0);
71 data.idBlock = defaultRoof.idBlock;
72 data.idRamp = defaultRoof.idRamp;
73 SourceMaterial.Row row = EClass.sources.materials.map[num2 % 1000];
74 data.colRoof = IntColor.ToInt(row.matColor);
75 }
76 this.RefreshData(this.board.data);
77 }
78 else
79 {
80 CoreRef.DefaultRoof defaultRoof2 = EClass.core.refs.defaultRoofs[EClass.sources.blocks.map[num2 / 1000].roof];
81 this.height = (this.fullblock ? 1 : 2);
82 this.heightFix = (this.fullblock ? 40 : 0);
83 this.idRoofStyle = ((!EClass._map.IsIndoor && flag) ? 2 : 0);
84 this.idBlock = defaultRoof2.idBlock;
85 this.idRamp = defaultRoof2.idRamp;
86 this.realHeight = (float)this.height * EClass.setting.render.roomHeightMod + 0.01f * (float)this.heightFix;
87 Color color = EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f);
88 this.colRoof = (this.colBlock = (this.colDeco = BaseTileMap.GetColorInt(ref color, 100)));
89 SourceMaterial.Row row2 = EClass.sources.materials.map[num2 % 1000];
90 this.colRoof = BaseTileMap.GetColorInt(ref row2.matColor, 100);
91 }
92 int num3 = (this.mx - this.x + this.pointMinX.z - this.z) / 2;
93 int num4 = this.pointMaxX.x - this.pointMinX.x + this.pointMaxX.z - this.pointMinX.z + 1;
94 int num5 = (this.mx - this.x + this.mz - this.z) / 2 + 2;
95 int num6 = this.pointMinX.x + num3 - num5;
96 int num7 = this.pointMinX.z - num3 + num5;
97 int num8 = 0;
98 for (int i = 0; i < num4; i++)
99 {
100 int num9 = num6;
101 int num10 = num7;
102 bool flag2 = false;
103 for (int j = 0; j < num5 + 1; j++)
104 {
105 if (num10 >= num8 - 1 && num9 >= 0 && num10 >= 0 && num9 < EClass._map.Size && num10 < EClass._map.Size)
106 {
107 Cell cell = EClass._map.cells[num9, num10];
108 if (flag2)
109 {
110 Room room2 = cell.room;
111 if (((room2 != null) ? room2.lot : null) != this || (!cell.HasFullBlock && !cell.HasWall))
112 {
113 break;
114 }
115 }
116 Room room3 = cell.room;
117 if (((room3 != null) ? room3.lot : null) == this)
118 {
119 cell.lotWall = true;
120 if (!flag2 && !cell.HasFullBlock && !cell.HasWall)
121 {
122 break;
123 }
124 flag2 = true;
125 num8 = num10;
126 }
127 num9++;
128 num10--;
129 }
130 }
131 if (i % 2 == 0)
132 {
133 num6++;
134 }
135 else
136 {
137 num7++;
138 }
139 }
140 }
141
142 // Token: 0x0600317B RID: 12667 RVA: 0x00115528 File Offset: 0x00113728
143 public void RefreshData(TraitHouseBoard.Data data)
144 {
145 if (data.colRoof == 0)
146 {
147 data.colRoof = IntColor.ToInt(EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f));
148 }
149 if (data.colBlock == 0)
150 {
151 data.colBlock = IntColor.ToInt(EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f));
152 }
153 if (data.colDeco == 0)
154 {
155 data.colDeco = IntColor.ToInt(EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f));
156 }
157 if (data.colDeco2 == 0)
158 {
159 data.colDeco2 = IntColor.ToInt(EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f));
160 }
161 this.height = data.height;
162 this.reverse = data.reverse;
163 this.altRoof = data.altRoof;
164 this.snow = data.snow;
165 this.idRoofStyle = data.idRoofStyle;
166 this.idRoofTile = data.idRoofTile;
167 this.idBlock = data.idBlock;
168 this.idRamp = data.idRamp;
169 this.idBGM = data.idBGM;
170 this.idDeco = data.idDeco;
171 this.idDeco2 = data.idDeco2;
172 this.heightFix = data.heightFix;
173 this.decoFix = data.decoFix;
174 this.decoFix2 = data.decoFix2;
175 this.realHeight = (float)this.height * EClass.setting.render.roomHeightMod + 0.01f * (float)this.heightFix;
176 Color color = IntColor.FromInt(data.colRoof);
177 Color color2 = IntColor.FromInt(data.colBlock);
178 Color color3 = IntColor.FromInt(data.colDeco);
179 Color color4 = IntColor.FromInt(data.colDeco2);
180 this.colRoof = BaseTileMap.GetColorInt(ref color, 100);
181 this.colBlock = BaseTileMap.GetColorInt(ref color2, 100);
182 this.colDeco = BaseTileMap.GetColorInt(ref color3, 100);
183 this.colDeco2 = BaseTileMap.GetColorInt(ref color4, 100);
184 }
185
186 // Token: 0x0600317C RID: 12668 RVA: 0x00115774 File Offset: 0x00113974
187 public void AddConnectedRooms(Room r2)
188 {
189 r2.lot = this;
190 if (r2.x < Lot.minX)
191 {
192 Lot.minX = r2.x;
193 }
194 if (r2.mx > Lot.maxX)
195 {
196 Lot.maxX = r2.mx;
197 }
198 if (r2.z < Lot.minZ)
199 {
200 Lot.minZ = r2.z;
201 }
202 if (r2.mz > Lot.maxZ)
203 {
204 Lot.maxZ = r2.mz;
205 }
206 if (r2.mh > this.mh)
207 {
208 this.mh = r2.mh;
209 }
210 if (r2.pointMinX.x + r2.pointMinX.z < this.pointMinX.x + this.pointMinX.z)
211 {
212 this.pointMinX = r2.pointMinX;
213 }
214 if (r2.pointMaxX.x + r2.pointMaxX.z > this.pointMaxX.x + this.pointMaxX.z)
215 {
216 this.pointMaxX = r2.pointMaxX;
217 }
218 if (this.board == null)
219 {
220 foreach (Point point in r2.points)
221 {
222 TraitHouseBoard installed = point.GetInstalled<TraitHouseBoard>();
223 if (installed != null)
224 {
225 this.board = installed;
226 break;
227 }
228 }
229 }
230 foreach (Room room in EClass._map.rooms.listRoom)
231 {
232 if (room.lot == null)
233 {
234 bool flag = false;
235 foreach (Point p in room.points)
236 {
237 using (List<Point>.Enumerator enumerator3 = r2.points.GetEnumerator())
238 {
239 while (enumerator3.MoveNext())
240 {
241 if (enumerator3.Current.Distance(p) == 1 && r2.data.group == room.data.group)
242 {
243 this.AddConnectedRooms(room);
244 flag = true;
245 break;
246 }
247 }
248 }
249 if (flag)
250 {
251 break;
252 }
253 }
254 }
255 }
256 }
257
258 // Token: 0x04001B5D RID: 7005
259 public static Lot Void = new Lot();
260
261 // Token: 0x04001B5E RID: 7006
262 public static Dictionary<int, int> roofCount = new Dictionary<int, int>();
263
264 // Token: 0x04001B5F RID: 7007
265 public int id;
266
267 // Token: 0x04001B60 RID: 7008
268 public int height = 2;
269
270 // Token: 0x04001B61 RID: 7009
271 public int idRoofStyle;
272
273 // Token: 0x04001B62 RID: 7010
274 public int idBGM;
275
276 // Token: 0x04001B63 RID: 7011
277 public int heightFix;
278
279 // Token: 0x04001B64 RID: 7012
280 public int idRoofTile;
281
282 // Token: 0x04001B65 RID: 7013
283 public int idBlock;
284
285 // Token: 0x04001B66 RID: 7014
286 public int idRamp;
287
288 // Token: 0x04001B67 RID: 7015
289 public int idDeco;
290
291 // Token: 0x04001B68 RID: 7016
292 public int idDeco2;
293
294 // Token: 0x04001B69 RID: 7017
295 public int colRoof;
296
297 // Token: 0x04001B6A RID: 7018
298 public int colBlock;
299
300 // Token: 0x04001B6B RID: 7019
301 public int colDeco;
302
303 // Token: 0x04001B6C RID: 7020
304 public int colDeco2;
305
306 // Token: 0x04001B6D RID: 7021
307 public int decoFix;
308
309 // Token: 0x04001B6E RID: 7022
310 public int decoFix2;
311
312 // Token: 0x04001B6F RID: 7023
313 public bool reverse;
314
315 // Token: 0x04001B70 RID: 7024
316 public bool snow;
317
318 // Token: 0x04001B71 RID: 7025
319 public bool altRoof;
320
321 // Token: 0x04001B72 RID: 7026
322 public bool fullblock;
323
324 // Token: 0x04001B73 RID: 7027
325 public int x;
326
327 // Token: 0x04001B74 RID: 7028
328 public int z;
329
330 // Token: 0x04001B75 RID: 7029
331 public int mx;
332
333 // Token: 0x04001B76 RID: 7030
334 public int mz;
335
336 // Token: 0x04001B77 RID: 7031
337 public int mh;
338
339 // Token: 0x04001B78 RID: 7032
340 public bool sync;
341
342 // Token: 0x04001B79 RID: 7033
343 public bool dirty;
344
345 // Token: 0x04001B7A RID: 7034
346 public float realHeight;
347
348 // Token: 0x04001B7B RID: 7035
349 public float light;
350
351 // Token: 0x04001B7C RID: 7036
352 public Point pointMinX;
353
354 // Token: 0x04001B7D RID: 7037
355 public Point pointMaxX;
356
357 // Token: 0x04001B7E RID: 7038
358 private static int minX;
359
360 // Token: 0x04001B7F RID: 7039
361 private static int minZ;
362
363 // Token: 0x04001B80 RID: 7040
364 private static int maxX;
365
366 // Token: 0x04001B81 RID: 7041
367 private static int maxZ;
368
369 // Token: 0x04001B82 RID: 7042
370 public TraitHouseBoard board;
371}
Definition Cell.cs:10
Definition Lot.cs:7
Definition Point.cs:11
Definition Room.cs:6