Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Lot.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class Lot : EClass
5{
6 public static Lot Void = new Lot();
7
8 public static Dictionary<int, int> roofCount = new Dictionary<int, int>();
9
10 public int id;
11
12 public int height = 2;
13
14 public int idRoofStyle;
15
16 public int idBGM;
17
18 public int heightFix;
19
20 public int idRoofTile;
21
22 public int idBlock;
23
24 public int idRamp;
25
26 public int idDeco;
27
28 public int idDeco2;
29
30 public int colRoof;
31
32 public int colBlock;
33
34 public int colDeco;
35
36 public int colDeco2;
37
38 public int decoFix;
39
40 public int decoFix2;
41
42 public bool reverse;
43
44 public bool snow;
45
46 public bool altRoof;
47
48 public bool fullblock;
49
50 public int x;
51
52 public int z;
53
54 public int mx;
55
56 public int mz;
57
58 public int mh;
59
60 public bool sync;
61
62 public bool dirty;
63
64 public float realHeight;
65
66 public float light;
67
69
71
72 private static int minX;
73
74 private static int minZ;
75
76 private static int maxX;
77
78 private static int maxZ;
79
81
82 public void SetBaseRoom(Room r)
83 {
84 board = null;
85 fullblock = false;
86 minX = r.x;
87 maxX = r.mx;
88 minZ = r.z;
89 maxZ = r.mz;
90 mh = r.mh;
94 x = minX;
95 mx = maxX;
96 z = minZ;
97 mz = maxZ;
98 bool flag = false;
99 roofCount.Clear();
100 foreach (Room item in EClass._map.rooms.listRoom)
101 {
102 if (item.lot != this)
103 {
104 continue;
105 }
106 if (item.roof)
107 {
108 flag = true;
109 }
110 if (item.fullblock)
111 {
112 fullblock = true;
113 }
114 foreach (KeyValuePair<int, int> item2 in item.roofCount)
115 {
116 if (!roofCount.ContainsKey(item2.Key))
117 {
118 roofCount[item2.Key] = 0;
119 }
120 roofCount[item2.Key] += item2.Value;
121 }
122 }
123 int num = 0;
124 int num2 = 0;
125 foreach (KeyValuePair<int, int> item3 in roofCount)
126 {
127 if (item3.Value > num)
128 {
129 num = item3.Value;
130 num2 = item3.Key;
131 }
132 }
133 if (board != null)
134 {
135 if (board.data == null)
136 {
137 TraitHouseBoard.Data data2 = (board.data = new TraitHouseBoard.Data());
138 CoreRef.DefaultRoof defaultRoof = EClass.core.refs.defaultRoofs[EClass.sources.blocks.map[num2 / 1000].roof];
139 data2.height = (fullblock ? 1 : 2);
140 data2.heightFix = (fullblock ? 40 : 0);
141 data2.reverse = EClass.rnd(2) == 0;
142 data2.idRoofStyle = ((!EClass._map.IsIndoor && flag) ? 2 : 0);
143 data2.idBlock = defaultRoof.idBlock;
144 data2.idRamp = defaultRoof.idRamp;
145 SourceMaterial.Row row = EClass.sources.materials.map[num2 % 1000];
146 data2.colRoof = IntColor.ToInt(row.matColor);
147 }
149 }
150 else
151 {
152 CoreRef.DefaultRoof defaultRoof2 = EClass.core.refs.defaultRoofs[EClass.sources.blocks.map[num2 / 1000].roof];
153 height = (fullblock ? 1 : 2);
154 heightFix = (fullblock ? 40 : 0);
155 idRoofStyle = ((!EClass._map.IsIndoor && flag) ? 2 : 0);
156 idBlock = defaultRoof2.idBlock;
157 idRamp = defaultRoof2.idRamp;
158 realHeight = (float)height * EClass.setting.render.roomHeightMod + 0.01f * (float)heightFix;
159 Color matColor = EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f);
160 colRoof = (colBlock = (colDeco = BaseTileMap.GetColorInt(ref matColor, 100)));
161 SourceMaterial.Row row2 = EClass.sources.materials.map[num2 % 1000];
162 colRoof = BaseTileMap.GetColorInt(ref row2.matColor, 100);
163 }
164 int num3 = (mx - x + pointMinX.z - z) / 2;
165 int num4 = pointMaxX.x - pointMinX.x + pointMaxX.z - pointMinX.z + 1;
166 int num5 = (mx - x + mz - z) / 2 + 4;
167 int num6 = pointMinX.x + num3 - num5;
168 int num7 = pointMinX.z - num3 + num5;
169 int num8 = 0;
170 for (int i = 0; i < num4; i++)
171 {
172 int num9 = num6;
173 int num10 = num7;
174 bool flag2 = false;
175 for (int j = 0; j < num5 + 1; j++)
176 {
177 if (num10 < num8 - 1 || num9 < 0 || num10 < 0 || num9 >= EClass._map.Size || num10 >= EClass._map.Size)
178 {
179 num9++;
180 num10--;
181 continue;
182 }
183 Cell cell = EClass._map.cells[num9, num10];
184 if (flag2 && (cell.room?.lot != this || (!cell.HasFullBlock && !cell.HasWall)))
185 {
186 break;
187 }
188 if (cell.room?.lot == this)
189 {
190 cell.lotWall = true;
191 if (!flag2 && !cell.HasFullBlock && !cell.HasWall)
192 {
193 break;
194 }
195 flag2 = true;
196 num8 = num10;
197 }
198 num9++;
199 num10--;
200 }
201 if (i % 2 == 0)
202 {
203 num6++;
204 }
205 else
206 {
207 num7++;
208 }
209 }
210 }
211
213 {
214 if (data.colRoof == 0)
215 {
216 data.colRoof = IntColor.ToInt(EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f));
217 }
218 if (data.colBlock == 0)
219 {
220 data.colBlock = IntColor.ToInt(EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f));
221 }
222 if (data.colDeco == 0)
223 {
224 data.colDeco = IntColor.ToInt(EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f));
225 }
226 if (data.colDeco2 == 0)
227 {
228 data.colDeco2 = IntColor.ToInt(EClass.sources.materials.alias["oak"].matColor.SetAlpha(1f));
229 }
230 height = data.height;
231 reverse = data.reverse;
232 altRoof = data.altRoof;
233 snow = data.snow;
234 idRoofStyle = data.idRoofStyle;
235 idRoofTile = data.idRoofTile;
236 idBlock = data.idBlock;
237 idRamp = data.idRamp;
238 idBGM = data.idBGM;
239 idDeco = data.idDeco;
240 idDeco2 = data.idDeco2;
241 heightFix = data.heightFix;
242 decoFix = data.decoFix;
243 decoFix2 = data.decoFix2;
244 realHeight = (float)height * EClass.setting.render.roomHeightMod + 0.01f * (float)heightFix;
245 Color matColor = IntColor.FromInt(data.colRoof);
246 Color matColor2 = IntColor.FromInt(data.colBlock);
247 Color matColor3 = IntColor.FromInt(data.colDeco);
248 Color matColor4 = IntColor.FromInt(data.colDeco2);
249 colRoof = BaseTileMap.GetColorInt(ref matColor, 100);
250 colBlock = BaseTileMap.GetColorInt(ref matColor2, 100);
251 colDeco = BaseTileMap.GetColorInt(ref matColor3, 100);
252 colDeco2 = BaseTileMap.GetColorInt(ref matColor4, 100);
253 }
254
255 public void AddConnectedRooms(Room r2)
256 {
257 r2.lot = this;
258 if (r2.x < minX)
259 {
260 minX = r2.x;
261 }
262 if (r2.mx > maxX)
263 {
264 maxX = r2.mx;
265 }
266 if (r2.z < minZ)
267 {
268 minZ = r2.z;
269 }
270 if (r2.mz > maxZ)
271 {
272 maxZ = r2.mz;
273 }
274 if (r2.mh > mh)
275 {
276 mh = r2.mh;
277 }
278 if (r2.pointMinX.x + r2.pointMinX.z < pointMinX.x + pointMinX.z)
279 {
280 pointMinX = r2.pointMinX;
281 }
282 if (r2.pointMaxX.x + r2.pointMaxX.z > pointMaxX.x + pointMaxX.z)
283 {
284 pointMaxX = r2.pointMaxX;
285 }
286 if (board == null)
287 {
288 foreach (Point point in r2.points)
289 {
290 TraitHouseBoard installed = point.GetInstalled<TraitHouseBoard>();
291 if (installed != null)
292 {
294 break;
295 }
296 }
297 }
298 foreach (Room item in EClass._map.rooms.listRoom)
299 {
300 if (item.lot != null)
301 {
302 continue;
303 }
304 bool flag = false;
305 foreach (Point point2 in item.points)
306 {
307 foreach (Point point3 in r2.points)
308 {
309 if (point3.Distance(point2) == 1 && r2.data.group == item.data.group)
310 {
312 flag = true;
313 break;
314 }
315 }
316 if (flag)
317 {
318 break;
319 }
320 }
321 }
322 }
323}
PointList points
Definition: BaseArea.cs:26
static int GetColorInt(ref Color matColor, int p)
Definition: Cell.cs:7
Room room
Definition: Cell.cs:102
bool HasWall
Definition: Cell.cs:833
bool HasFullBlock
Definition: Cell.cs:817
List< DefaultRoof > defaultRoofs
Definition: CoreRef.cs:367
CoreRef refs
Definition: Core.cs:51
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Core core
Definition: EClass.cs:6
static Map _map
Definition: EClass.cs:18
static SourceManager sources
Definition: EClass.cs:42
static GameSetting setting
Definition: EClass.cs:34
RenderSetting render
Definition: GameSetting.cs:301
static int ToInt(ref Color c)
Definition: IntColor.cs:24
static Color32 FromInt(int i)
Definition: IntColor.cs:15
Definition: Lot.cs:5
void AddConnectedRooms(Room r2)
Definition: Lot.cs:255
static Dictionary< int, int > roofCount
Definition: Lot.cs:8
int colDeco2
Definition: Lot.cs:36
bool altRoof
Definition: Lot.cs:46
int x
Definition: Lot.cs:50
void RefreshData(TraitHouseBoard.Data data)
Definition: Lot.cs:212
int colBlock
Definition: Lot.cs:32
static int maxX
Definition: Lot.cs:76
static int minX
Definition: Lot.cs:72
int z
Definition: Lot.cs:52
int mx
Definition: Lot.cs:54
int decoFix
Definition: Lot.cs:38
static Lot Void
Definition: Lot.cs:6
TraitHouseBoard board
Definition: Lot.cs:80
static int maxZ
Definition: Lot.cs:78
bool snow
Definition: Lot.cs:44
int idRamp
Definition: Lot.cs:24
int id
Definition: Lot.cs:10
bool dirty
Definition: Lot.cs:62
int decoFix2
Definition: Lot.cs:40
int colRoof
Definition: Lot.cs:30
int mh
Definition: Lot.cs:58
int colDeco
Definition: Lot.cs:34
bool fullblock
Definition: Lot.cs:48
int idRoofStyle
Definition: Lot.cs:14
int heightFix
Definition: Lot.cs:18
float realHeight
Definition: Lot.cs:64
bool sync
Definition: Lot.cs:60
float light
Definition: Lot.cs:66
int mz
Definition: Lot.cs:56
int idBlock
Definition: Lot.cs:22
void SetBaseRoom(Room r)
Definition: Lot.cs:82
Point pointMinX
Definition: Lot.cs:68
Point pointMaxX
Definition: Lot.cs:70
int height
Definition: Lot.cs:12
int idDeco2
Definition: Lot.cs:28
int idDeco
Definition: Lot.cs:26
static int minZ
Definition: Lot.cs:74
int idRoofTile
Definition: Lot.cs:20
bool reverse
Definition: Lot.cs:42
int idBGM
Definition: Lot.cs:16
int Size
Definition: MapBounds.cs:20
RoomManager rooms
Definition: Map.cs:31
Cell[,] cells
Definition: Map.cs:85
Definition: Point.cs:9
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
int Distance(Point p)
Definition: Point.cs:953
List< Room > listRoom
Definition: RoomManager.cs:13
Definition: Room.cs:4
Point pointMaxX
Definition: Room.cs:25
int x
Definition: Room.cs:5
int z
Definition: Room.cs:7
int mx
Definition: Room.cs:9
Point pointMinX
Definition: Room.cs:23
int mh
Definition: Room.cs:13
int mz
Definition: Room.cs:11
Lot lot
Definition: Room.cs:21
SourceMaterial materials
SourceBlock blocks