26 protected override bool OnGenerateTerrain()
29 CS$<>8__locals1.<>4__this =
this;
31 MapGenerator generator = this.zone.Generator;
32 MapData mapData = DunGen.Generate(generator, 0);
33 this.width = mapData.size_X + 2;
34 this.height = mapData.size_Y + 2;
35 base.SetSize(Mathf.Max(
this.width,
this.height), 10);
36 this.map.CreateNew(this.Size,
true);
37 this.map.poiMap.Reset();
38 this.map.SetZone(this.zone);
39 this.map.config.blockHeight =
EClass.core.gameSetting.gen.defaultBlockHeight;
40 CS$<>8__locals1.biome = this.zone.biome;
43 CS$<>8__locals1.biome = CS$<>8__locals1.biome.Instantiate<
BiomeProfile>();
44 CS$<>8__locals1.biome.interior.block.mat =
MATERIAL.GetRandomMaterialFromCategory(this.zone.lv % 50 + 10,
"rock",
EClass.sources.materials.alias[
"granite"]).id;
45 CS$<>8__locals1.biome.interior.block.matSub =
MATERIAL.GetRandomMaterialFromCategory(this.zone.lv % 50 + 10,
"rock",
EClass.sources.materials.alias[
"granite"]).id;
46 CS$<>8__locals1.biome.interior.floor.mat =
MATERIAL.GetRandomMaterialFromCategory(this.zone.lv % 50 + 10,
"rock",
EClass.sources.materials.alias[
"granite"]).id;
47 CS$<>8__locals1.biome.interior.floor.matSub =
MATERIAL.GetRandomMaterialFromCategory(this.zone.lv % 50 + 10,
"rock",
EClass.sources.materials.alias[
"granite"]).id;
48 CS$<>8__locals1.biome.exterior.block.mat =
MATERIAL.GetRandomMaterialFromCategory(this.zone.lv % 50 + 10,
"rock",
EClass.sources.materials.alias[
"granite"]).id;
49 CS$<>8__locals1.biome.exterior.block.matSub =
MATERIAL.GetRandomMaterialFromCategory(this.zone.lv % 50 + 10,
"rock",
EClass.sources.materials.alias[
"granite"]).id;
50 CS$<>8__locals1.biome.exterior.floor.mat =
MATERIAL.GetRandomMaterialFromCategory(this.zone.lv % 50 + 10,
"rock",
EClass.sources.materials.alias[
"granite"]).id;
51 CS$<>8__locals1.biome.exterior.floor.matSub =
MATERIAL.GetRandomMaterialFromCategory(this.zone.lv % 50 + 10,
"rock",
EClass.sources.materials.alias[
"granite"]).id;
55 bool flag = this.zone.lv <= 0;
61 for (
int i = 0; i < mapData.size_X + 2; i++)
63 for (
int j = 0; j < mapData.size_Y + 2; j++)
65 if (i == 0 || j == 0 || i >= mapData.size_X || j >= mapData.size_Y)
67 base.SetFloor(floor, i, j);
68 base.SetBlock(block, i, j);
72 Dungen.Cell cell = mapData.cellsOnMap[i - 1, j - 1];
73 CellType type = cell.type;
75 base.SetFloor(floor, i, j);
76 string name = type.name;
77 if (!(name ==
"Entrance"))
79 if (!(name ==
"Exit"))
81 if (!(name ==
"Door"))
83 if (!(name ==
"Abyss"))
85 if (type.passable == generator.reversePassage)
87 base.SetBlock(block, i, j);
92 base.SetBlock(block, i, j);
95 else if (CS$<>8__locals1.biome.style.doorChance >= Rand.Range(0f, 1f))
97 base.SetBlock(block, i, j);
98 Thing t3 =
ThingGen.Create(CS$<>8__locals1.biome.style.GetIdDoor(), CS$<>8__locals1.biome.style.matDoor, -1);
99 this.zone.AddCard(t3, i, j).Install();
102 else if (this.zone.ShouldMakeExit)
106 Debug.LogError(
"exception: already created exit");
111 Thing thing3 =
ThingGen.Create(
EClass._zone.LockExit ?
"stairs_locked" : CS$<>8__locals1.biome.style.GetIdStairs(!flag), CS$<>8__locals1.biome.style.matStairs, -1);
120 this.zone.AddCard(thing3, i, j).Install();
126 Debug.LogError(
"exception: already created entrance");
131 Thing thing4 =
ThingGen.Create(CS$<>8__locals1.biome.style.GetIdStairs(flag), CS$<>8__locals1.biome.style.matStairs, -1);
140 this.zone.AddCard(thing4, i, j).Install();
142 if (!cell.isRoomCell)
144 CS$<>8__locals1.biome.Populate(point,
false);
151 Debug.LogError(
"exception: Failed to create entrance:");
154 if (this.zone.ShouldMakeExit && !flag3)
156 Debug.LogError(
"exception: Failed to create exist:");
161 thing2.pos.cell._block = 0;
162 thing2.pos.cell.obj = 0;
166 thing.pos.cell._block = 0;
167 thing.pos.cell.obj = 0;
169 CS$<>8__locals1.rooms =
new Dictionary<int, GenRoom>();
170 CS$<>8__locals1.count = 0;
172 foreach (Dungen.Room room in mapData.rooms)
174 if (room.width != 0 && room.height != 0)
181 mapData.rooms.Clear();
183 if (mapData.rooms.Count == 0)
186 genRoomBig.Init(1, 1, this.width - 1, this.height - 1);
187 this.<OnGenerateTerrain>g__SetRoom|3_0(genRoomBig, ref CS$<>8__locals1);
191 foreach (Dungen.Room room2 in mapData.rooms)
193 GenRoom genRoom = this.ChooseRoom();
195 this.<OnGenerateTerrain>g__SetRoom|3_0(genRoom, ref CS$<>8__locals1);
198 this.map.RefreshAllTiles();
199 foreach (
GenRoom genRoom2
in CS$<>8__locals1.rooms.Values)
203 this.zone.OnGenerateRooms(
this);
204 this.map.ReloadRoom();
205 Debug.Log(
string.Concat(
new string[]
208 CS$<>8__locals1.rooms.Count.ToString(),
210 mapData.rooms.Count.ToString(),
212 this.width.ToString(),
214 this.height.ToString()
216 int num2 =
EClass.rnd(this.Size * this.Size / 50 +
EClass.rnd(20)) + 5;
217 num2 = num2 * Mathf.Min(20 + this.zone.DangerLv * 5, 100) / 100;
218 for (
int k = 0; k < num2; k++)
220 point =
EClass._map.GetRandomPoint();
221 if (!point.cell.isModified && !point.HasThing && !point.HasBlock && !point.HasObj)
223 Thing t2 =
ThingGen.CreateFromCategory(
"trap", this.zone.DangerLv);
224 EClass._zone.AddCard(t2, point).Install();
227 this.map.things.ForeachReverse(delegate(
Thing t)
230 if (traitDoor ==
null)
234 if (!traitDoor.IsValid())
236 string str =
"Purging Door:";
237 string name2 = t.Name;
240 Debug.Log(str + name2 + str2 + ((pos !=
null) ? pos.ToString() :
null));
250 MapGenDungen.<OnGenerateTerrain>g__ClearPos|3_2(thing2);
267 private void <OnGenerateTerrain>g__SetRoom|3_0(
GenRoom room, ref
MapGenDungen.<>c__DisplayClass3_0 A_2)
270 room.zone = this.zone;
272 room.group = A_2.biome.interior;
273 A_2.rooms[room.Index] = room;
275 Debug.Log(
string.Concat(
new string[]
278 A_2.count.ToString(),
280 room.width.ToString(),
282 room.height.ToString(),
284 (room !=
null) ? room.ToString() :
null
286 int count = A_2.count;
287 A_2.count = count + 1;
292 internal static void <OnGenerateTerrain>g__ClearPos|3_2(
Thing t)
294 foreach (
Card card
in t.pos.ListCards(
false))
296 if (card != t && card.isThing)
301 t.pos.SetObj(0, 1, 0);
302 t.pos.SetBlock(0, 0);
303 t.pos.cell.height = 0;