Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Room.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2
3public class Room : BaseArea
4{
5 public int x;
6
7 public int z;
8
9 public int mx;
10
11 public int mz;
12
13 public int mh;
14
15 public bool dirty;
16
17 public bool roof;
18
19 public bool fullblock;
20
21 public Lot lot;
22
24
26
27 public Dictionary<int, int> roofCount = new Dictionary<int, int>();
28
29 public bool HasRoof => lot.idRoofStyle != 0;
30
31 public override string ToString()
32 {
33 return uid.ToString() ?? "";
34 }
35
36 public void OnLoad()
37 {
38 foreach (Point point in points)
39 {
40 point.cell.room = this;
41 }
42 EClass._map.rooms.mapIDs[uid] = this;
43 SetDirty();
44 }
45
46 public void AddPoint(Point p)
47 {
48 points.Add(p);
49 p.cell.room = this;
50 lot = Lot.Void;
51 SetDirty();
52 }
53
54 public void OnRemove()
55 {
56 Clean();
57 for (int num = points.Count - 1; num >= 0; num--)
58 {
59 points[num].cell.room = null;
60 }
61 points.Clear();
62 EClass._map.rooms.dirtyLots = true;
63 }
64
65 public void Clean()
66 {
67 plate = null;
68 }
69
70 public void Refresh()
71 {
72 Clean();
73 roofCount.Clear();
74 x = (mx = points[0].x);
75 z = (mz = points[0].z);
76 mh = 0;
77 int num = 0;
78 int num2 = 0;
79 int num3 = 0;
80 int num4 = 0;
81 pointMinX = points[0];
82 pointMaxX = points[0];
83 foreach (Point point in points)
84 {
85 Cell cell = point.cell;
86 if (point.x < x)
87 {
88 x = point.x;
89 }
90 else if (point.x > mx)
91 {
92 mx = point.x;
93 }
94 if (point.z < z)
95 {
96 z = point.z;
97 }
98 else if (point.z > mz)
99 {
100 mz = point.z;
101 }
102 if (point.x + point.z < pointMinX.x + pointMinX.z)
103 {
104 pointMinX = point;
105 }
106 if (point.x + point.z > pointMaxX.x + pointMaxX.z)
107 {
108 pointMaxX = point;
109 }
110 bool hasFullBlockOrWallOrFence = cell.HasFullBlockOrWallOrFence;
111 if (cell.TopHeight > mh && hasFullBlockOrWallOrFence)
112 {
113 mh = cell.TopHeight;
114 }
115 if (hasFullBlockOrWallOrFence)
116 {
117 TileType tileType = point.sourceBlock.tileType;
118 if (tileType.IsWall)
119 {
120 num3++;
121 }
122 else if (tileType.IsFence)
123 {
124 num2++;
125 }
126 else
127 {
128 num++;
129 }
130 int key = point.sourceBlock.id * 1000 + point.matBlock.id;
131 if (!roofCount.ContainsKey(key))
132 {
133 roofCount[key] = 0;
134 }
135 roofCount[key]++;
136 }
137 if (plate == null)
138 {
139 plate = point.GetInstalled<TraitRoomPlate>();
140 }
141 num4 += point.x + point.z * 256;
142 cell.fullWall = false;
143 cell.lotWall = false;
144 }
145 int num5 = (mx - x + pointMinX.z - z) / 2;
146 int num6 = pointMaxX.x - pointMinX.x + pointMaxX.z - pointMinX.z + 1;
147 int num7 = (mx - x + mz - z) / 2 + 2;
148 int num8 = pointMinX.x + num5 - num7;
149 int num9 = pointMinX.z - num5 + num7;
150 int num10 = 0;
151 for (int i = 0; i < num6; i++)
152 {
153 int num11 = num8;
154 int num12 = num9;
155 bool flag = false;
156 for (int j = 0; j < num7 + 1; j++)
157 {
158 if (num12 < num10 - 1 || num11 < 0 || num12 < 0 || num11 >= EClass._map.Size || num12 >= EClass._map.Size)
159 {
160 num11++;
161 num12--;
162 continue;
163 }
164 Cell cell2 = EClass._map.cells[num11, num12];
165 if (flag && (cell2.room != this || (!cell2.HasFullBlock && !cell2.HasWall)))
166 {
167 break;
168 }
169 if (cell2.room == this)
170 {
171 cell2.fullWall = true;
172 if (!flag && !cell2.HasFullBlock && !cell2.HasWall)
173 {
174 break;
175 }
176 flag = true;
177 num10 = num12;
178 }
179 num11++;
180 num12--;
181 }
182 if (i % 2 == 0)
183 {
184 num8++;
185 }
186 else
187 {
188 num9++;
189 }
190 }
191 fullblock = num > num3;
192 roof = (mx - x + (mz - z)) / 2 > num2;
193 dirty = false;
194 EClass._map.rooms.dirtyLots = true;
195 type = new AreaTypeRoom
196 {
197 owner = this
198 };
199 SetRandomName(num4);
200 if (plate != null)
201 {
202 data.name = plate.areaData.name;
203 if (plate.areaData.type != null)
204 {
206 }
207 data.group = plate.areaData.group;
208 data.atrium = plate.areaData.atrium;
209 data.accessType = plate.areaData.accessType;
210 }
211 }
212
213 public void SetDirty()
214 {
215 dirty = true;
216 EClass._map.rooms.dirtyRooms = true;
217 }
218}
AreaType type
Definition: AreaData.cs:10
BaseArea.AccessType accessType
Definition: AreaData.cs:42
int group
Definition: AreaData.cs:18
bool atrium
Definition: AreaData.cs:66
string name
Definition: AreaData.cs:7
TraitRoomPlate plate
Definition: BaseArea.cs:34
AreaType type
Definition: BaseArea.cs:32
void SetRandomName(int seed=-1)
Definition: BaseArea.cs:117
PointList points
Definition: BaseArea.cs:26
int uid
Definition: BaseArea.cs:23
Definition: Cell.cs:7
Room room
Definition: Cell.cs:102
byte TopHeight
Definition: Cell.cs:117
bool HasWall
Definition: Cell.cs:833
bool HasFullBlockOrWallOrFence
Definition: Cell.cs:820
bool HasFullBlock
Definition: Cell.cs:817
Definition: EClass.cs:5
static Map _map
Definition: EClass.cs:18
Definition: Lot.cs:5
static Lot Void
Definition: Lot.cs:6
int Size
Definition: MapBounds.cs:20
RoomManager rooms
Definition: Map.cs:31
Cell[,] cells
Definition: Map.cs:85
Definition: Point.cs:9
SourceMaterial.Row matBlock
Definition: Point.cs:55
SourceBlock.Row sourceBlock
Definition: Point.cs:63
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
Cell cell
Definition: Point.cs:51
Dictionary< int, BaseArea > mapIDs
Definition: RoomManager.cs:18
Definition: Room.cs:4
void SetDirty()
Definition: Room.cs:213
void AddPoint(Point p)
Definition: Room.cs:46
Point pointMaxX
Definition: Room.cs:25
int x
Definition: Room.cs:5
int z
Definition: Room.cs:7
bool HasRoof
Definition: Room.cs:29
void Refresh()
Definition: Room.cs:70
bool roof
Definition: Room.cs:17
bool dirty
Definition: Room.cs:15
void OnLoad()
Definition: Room.cs:36
bool fullblock
Definition: Room.cs:19
override string ToString()
Definition: Room.cs:31
int mx
Definition: Room.cs:9
Point pointMinX
Definition: Room.cs:23
int mh
Definition: Room.cs:13
void OnRemove()
Definition: Room.cs:54
Dictionary< int, int > roofCount
Definition: Room.cs:27
void Clean()
Definition: Room.cs:65
int mz
Definition: Room.cs:11
Lot lot
Definition: Room.cs:21
virtual bool IsWall
Definition: TileType.cs:133
virtual bool IsFence
Definition: TileType.cs:167
AreaData areaData