Elin Decompiled Documentation EA 23.348.1 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<long, int> roofCount = new Dictionary<long, 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 long key = ((long)point.sourceBlock.id << 32) | (uint)point.matBlock.id;
131 roofCount.TryAdd(key, 0);
132 roofCount[key]++;
133 }
134 if (plate == null)
135 {
136 plate = point.GetInstalled<TraitRoomPlate>();
137 }
138 num4 += point.x + point.z * 256;
139 cell.fullWall = false;
140 cell.lotWall = false;
141 }
142 int num5 = (mx - x + pointMinX.z - z) / 2;
143 int num6 = pointMaxX.x - pointMinX.x + pointMaxX.z - pointMinX.z + 1;
144 int num7 = (mx - x + mz - z) / 2 + 2;
145 int num8 = pointMinX.x + num5 - num7;
146 int num9 = pointMinX.z - num5 + num7;
147 int num10 = 0;
148 for (int i = 0; i < num6; i++)
149 {
150 int num11 = num8;
151 int num12 = num9;
152 bool flag = false;
153 for (int j = 0; j < num7 + 1; j++)
154 {
155 if (num12 < num10 - 1 || num11 < 0 || num12 < 0 || num11 >= EClass._map.Size || num12 >= EClass._map.Size)
156 {
157 num11++;
158 num12--;
159 continue;
160 }
161 Cell cell2 = EClass._map.cells[num11, num12];
162 if (flag && (cell2.room != this || (!cell2.HasFullBlock && !cell2.HasWall)))
163 {
164 break;
165 }
166 if (cell2.room == this)
167 {
168 cell2.fullWall = true;
169 if (!flag && !cell2.HasFullBlock && !cell2.HasWall)
170 {
171 break;
172 }
173 flag = true;
174 num10 = num12;
175 }
176 num11++;
177 num12--;
178 }
179 if (i % 2 == 0)
180 {
181 num8++;
182 }
183 else
184 {
185 num9++;
186 }
187 }
188 fullblock = num > num3;
189 roof = (mx - x + (mz - z)) / 2 > num2;
190 dirty = false;
191 EClass._map.rooms.dirtyLots = true;
192 type = new AreaTypeRoom
193 {
194 owner = this
195 };
196 SetRandomName(num4);
197 if (plate != null)
198 {
199 data.name = plate.areaData.name;
200 if (plate.areaData.type != null)
201 {
203 }
204 data.group = plate.areaData.group;
205 data.atrium = plate.areaData.atrium;
206 data.accessType = plate.areaData.accessType;
207 }
208 }
209
210 public void SetDirty()
211 {
212 dirty = true;
213 EClass._map.rooms.dirtyRooms = true;
214 }
215}
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:122
byte TopHeight
Definition: Cell.cs:139
bool HasWall
Definition: Cell.cs:869
bool HasFullBlockOrWallOrFence
Definition: Cell.cs:856
bool HasFullBlock
Definition: Cell.cs:853
Definition: EClass.cs:6
static Map _map
Definition: EClass.cs:19
Definition: Lot.cs:5
static Lot Void
Definition: Lot.cs:6
int Size
Definition: MapBounds.cs:20
RoomManager rooms
Definition: Map.cs:34
Cell[,] cells
Definition: Map.cs:88
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:210
void AddPoint(Point p)
Definition: Room.cs:46
Dictionary< long, int > roofCount
Definition: Room.cs:27
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
void Clean()
Definition: Room.cs:65
int mz
Definition: Room.cs:11
Lot lot
Definition: Room.cs:21
virtual bool IsWall
Definition: TileType.cs:145
virtual bool IsFence
Definition: TileType.cs:179
AreaData areaData