Elin Modding Docs Doc
Loading...
Searching...
No Matches
GenRoom.cs
1using System;
2using Dungen;
3using UnityEngine;
4
5// Token: 0x0200066F RID: 1647
6public class GenRoom : GenBounds
7{
8 // Token: 0x17000D17 RID: 3351
9 // (get) Token: 0x06002E31 RID: 11825 RVA: 0x00104974 File Offset: 0x00102B74
10 public int Index
11 {
12 get
13 {
14 return this.x + this.y * this.Size;
15 }
16 }
17
18 // Token: 0x17000D18 RID: 3352
19 // (get) Token: 0x06002E32 RID: 11826 RVA: 0x0010498A File Offset: 0x00102B8A
20 public virtual bool PopulateCluster
21 {
22 get
23 {
24 return true;
25 }
26 }
27
28 // Token: 0x17000D19 RID: 3353
29 // (get) Token: 0x06002E33 RID: 11827 RVA: 0x0010498D File Offset: 0x00102B8D
30 public virtual bool IsBigRoom
31 {
32 get
33 {
34 return false;
35 }
36 }
37
38 // Token: 0x06002E34 RID: 11828 RVA: 0x00104990 File Offset: 0x00102B90
39 public void Init(Dungen.Room room)
40 {
41 this.x = room.x + 1;
42 this.y = room.y + 1;
43 this.width = room.width;
44 this.height = room.height;
45 this.Size = this.width * this.height;
46 }
47
48 // Token: 0x06002E35 RID: 11829 RVA: 0x001049E4 File Offset: 0x00102BE4
49 public void Init(int _x, int _y, int w, int h)
50 {
51 this.x = _x;
52 this.y = _y;
53 this.width = w;
54 this.height = h;
55 this.Size = this.width * this.height;
56 }
57
58 // Token: 0x06002E36 RID: 11830 RVA: 0x00104A18 File Offset: 0x00102C18
59 public void Populate()
60 {
61 PartialMap partialMap = base.TryAddMapPiece(MapPiece.Type.Any, -1f, null, null);
62 this.OnPopulate();
63 BiomeProfile biome = this.zone.biome;
64 if (biome.style.lights.Count > 0 && (partialMap == null || !partialMap.result.hasLight))
65 {
66 foreach (BiomeProfile.Cluster.ItemThing itemThing in biome.style.lights)
67 {
68 if (Rand.Range(0f, 1f) <= itemThing.chance)
69 {
70 Thing thing = ThingGen.Create(itemThing.id, -1, -1);
71 Point point = new Point();
72 int i = 0;
73 while (i < 100)
74 {
75 if (!thing.TileType.UseMountHeight)
76 {
77 int a = Mathf.Min(i / 3 + 2, this.width / 2);
78 int a2 = Mathf.Min(i / 3 + 2, this.height / 2);
79 point.Set(this.x + this.width / 2 + EClass.rnd(a) - EClass.rnd(a), this.y + this.height / 2 + EClass.rnd(a2) - EClass.rnd(a2));
80 goto IL_1E0;
81 }
82 point.Set(this.x + EClass.rnd(this.width), this.y + EClass.rnd(this.height));
83 global::Cell cell = point.cell;
84 if (!cell.Left.hasDoor && !cell.Right.hasDoor && !cell.Front.hasDoor && !cell.Back.hasDoor)
85 {
86 if (cell.Left.HasBlock || cell.Right.HasBlock || cell.Front.HasBlock || cell.Back.HasBlock)
87 {
88 goto IL_1E0;
89 }
90 }
91 IL_23F:
92 i++;
93 continue;
94 IL_1E0:
95 if (!point.cell.blocked && !point.HasBlock && !point.HasObj && point.Installed == null)
96 {
97 int desiredDir = thing.TileType.GetDesiredDir(point, 0);
98 if (desiredDir != -1)
99 {
100 thing.dir = desiredDir;
101 }
102 this.zone.AddCard(thing, point).Install();
103 break;
104 }
105 goto IL_23F;
106 }
107 break;
108 }
109 }
110 }
111 if (this.PopulateCluster)
112 {
113 Point point2 = new Point();
114 for (int j = this.x; j < this.x + this.width; j++)
115 {
116 for (int k = this.y; k < this.y + this.height; k++)
117 {
118 point2.Set(j, k);
119 if (!point2.cell.isModified && !point2.cell.blocked)
120 {
121 biome.Populate(point2, true);
122 }
123 }
124 }
125 }
126 }
127
128 // Token: 0x06002E37 RID: 11831 RVA: 0x00104D30 File Offset: 0x00102F30
129 public void SpawnMob(Point p)
130 {
131 if (EClass.rnd(100) > 55 + this.zone.DangerLv * 3)
132 {
133 return;
134 }
135 this.zone.SpawnMob(p, null);
136 }
137
138 // Token: 0x06002E38 RID: 11832 RVA: 0x00104D5C File Offset: 0x00102F5C
139 public virtual void OnPopulate()
140 {
141 for (int i = 0; i < EClass.rnd(3 + this.Size / 8) + 1; i++)
142 {
143 this.SetRandomPoint(delegate(Point p)
144 {
145 int num = EClass.rnd(7);
146 if (num > 1)
147 {
148 if (num != 2)
149 {
150 this.SpawnMob(p);
151 }
152 else
153 {
154 if (EClass.rnd(5) != 0)
155 {
156 this.map.SetObj(p.x, p.z, GenRoom.ListWrecks.RandomItem<int>(), 1, 0);
157 return;
158 }
159 this.map.SetObj(p.x, p.z, 82, 1, 0);
160 if (EClass.rnd(2) == 0)
161 {
162 this.map.ApplyBackerObj(p, -1);
163 return;
164 }
165 }
166 }
167 else if (this.zone.biome.spawn.thing.Count > 0)
168 {
169 Thing thing = ThingGen.CreateFromFilter(this.zone.biome.spawn.GetRandomThingId(), EClass._zone.DangerLv);
170 if (thing != null)
171 {
172 this.zone.AddCard(thing, p);
173 return;
174 }
175 }
176 });
177 }
178 if (this.Size > 25)
179 {
180 for (int j = 0; j < this.Size / 25 + EClass.rnd(this.Size / 25); j++)
181 {
182 this.SetRandomPoint(delegate(Point p)
183 {
184 if (EClass.rnd(3) == 0)
185 {
186 Thing thing = ThingGen.CreateFromFilter(this.zone.biome.spawn.GetRandomThingId(), EClass._zone.DangerLv);
187 if (thing != null)
188 {
189 this.zone.AddCard(thing, p);
190 return;
191 }
192 }
193 else
194 {
195 this.SpawnMob(p);
196 }
197 });
198 }
199 }
200 }
201
202 // Token: 0x06002E39 RID: 11833 RVA: 0x00104DD8 File Offset: 0x00102FD8
203 public void Fill()
204 {
205 BiomeProfile.TileFloor floor = this.group.floor;
206 BiomeProfile.TileBlock block = this.group.block;
207 for (int i = this.x; i < this.x + this.width; i++)
208 {
209 for (int j = this.y; j < this.y + this.height; j++)
210 {
211 if (this.map.cells[i, j]._block != 0)
212 {
213 base.SetBlock(i, j, block.mat, block.id, EClass.rnd(EClass.rnd(4) + 1));
214 }
215 base.SetFloor(i, j, floor.mat, floor.id, EClass.rnd(EClass.rnd(8) + 1));
216 }
217 }
218 }
219
220 // Token: 0x06002E3A RID: 11834 RVA: 0x00104E98 File Offset: 0x00103098
221 public void SetRandomPoint(Action<Point> action)
222 {
223 int a = Mathf.Max(this.width - 2, 1);
224 int a2 = Mathf.Max(this.height - 2, 1);
225 for (int i = 0; i < 100; i++)
226 {
227 this._p.x = this.x + 1 + EClass.rnd(a);
228 this._p.z = this.y + 1 + EClass.rnd(a2);
229 this._c = this.map.cells[this._p.x, this._p.z];
230 if (!this._c.blocked && !this._c.HasBlock && !this._p.HasThing && !this._p.HasChara)
231 {
232 action(this._p);
233 return;
234 }
235 }
236 }
237
238 // Token: 0x06002E3B RID: 11835 RVA: 0x00104F78 File Offset: 0x00103178
239 public void SetRandomPointCentered(Action<Point> action)
240 {
241 int a = Mathf.Max(this.width / 2 - 1, 1);
242 int a2 = Mathf.Max(this.height / 2 - 1, 1);
243 for (int i = 0; i < 100; i++)
244 {
245 this._p.x = this.x + this.width / 2 + EClass.rnd(EClass.rnd(a) + 1) - EClass.rnd(EClass.rnd(a) + 1);
246 this._p.z = this.y + this.height / 2 + EClass.rnd(EClass.rnd(a2) + 1) - EClass.rnd(EClass.rnd(a2) + 1);
247 this._c = this.map.cells[this._p.x, this._p.z];
248 if (!this._c.blocked && !this._c.HasBlock && !this._p.HasThing && !this._p.HasChara)
249 {
250 action(this._p);
251 return;
252 }
253 }
254 }
255
256 // Token: 0x04001A3E RID: 6718
257 public BiomeProfile.TileGroup group;
258
259 // Token: 0x04001A3F RID: 6719
260 public MapGenDungen gen;
261
262 // Token: 0x04001A40 RID: 6720
263 public static int[] ListWrecks = new int[]
264 {
265 34,
266 46,
267 83,
268 85,
269 86,
270 87
271 };
272
273 // Token: 0x04001A41 RID: 6721
274 private Point _p = new Point();
275
276 // Token: 0x04001A42 RID: 6722
277 private global::Cell _c;
278}
Definition Point.cs:11
Definition Thing.cs:10