12 {
13 DunGen.Init();
15 MapData mapData = DunGen.Generate(generator);
16 width = mapData.size_X + 2;
17 height = mapData.size_Y + 2;
25 {
26 biome = biome.Instantiate();
35 }
38 int idMat = -1;
40 {
43 {
44 idMat = 5;
45 }
46 }
47 bool flag = zone.lv <= 0;
48 bool flag2 = false;
49 bool flag3 = false;
53 for (int i = 0; i < mapData.size_X + 2; i++)
54 {
55 for (int j = 0; j < mapData.size_Y + 2; j++)
56 {
57 if (i == 0 || j == 0 || i >= mapData.size_X || j >= mapData.size_Y)
58 {
61 continue;
62 }
63 Dungen.Cell cell = mapData.cellsOnMap[i - 1, j - 1];
64 CellType type = cell.type;
67 switch (type.name)
68 {
69 case "Entrance":
70 {
71 if (flag2)
72 {
73 Debug.LogError(
"exception: already created entrance");
74 break;
75 }
76 flag2 = true;
78 if (!flag)
79 {
80 thing = thing4;
81 }
82 else
83 {
84 thing2 = thing4;
85 }
87 break;
88 }
89 case "Exit":
90 {
92 {
93 break;
94 }
95 if (flag3)
96 {
97 Debug.LogError(
"exception: already created exit");
98 break;
99 }
100 flag3 = true;
102 if (flag)
103 {
104 thing = thing3;
105 }
106 else
107 {
108 thing2 = thing3;
109 }
111 break;
112 }
113 case "Door":
115 {
119 }
120 break;
121 case "Abyss":
123 break;
124 default:
125 if (type.passable == generator.reversePassage)
126 {
128 }
129 break;
130 }
131 if (!cell.isRoomCell)
132 {
134 }
135 }
136 }
137 if (!flag2)
138 {
139 Debug.LogError(
"exception: Failed to create entrance:");
140 return false;
141 }
143 {
144 Debug.LogError(
"exception: Failed to create exist:");
145 return false;
146 }
147 if (thing2 != null)
148 {
149 thing2.pos.cell._block = 0;
150 thing2.pos.cell.obj = 0;
151 }
152 if (thing != null)
153 {
154 thing.pos.cell._block = 0;
155 thing.pos.cell.obj = 0;
156 }
157 Dictionary<int, GenRoom> rooms = new Dictionary<int, GenRoom>();
158 int count = 0;
159 int num = 0;
160 foreach (Dungen.Room room in mapData.rooms)
161 {
162 if (room.width != 0 && room.height != 0)
163 {
164 num++;
165 }
166 }
167 if (num == 0)
168 {
169 mapData.rooms.Clear();
170 }
171 if (mapData.rooms.Count == 0)
172 {
175 SetRoom(genRoomBig);
176 }
177 else
178 {
179 foreach (Dungen.Room room2 in mapData.rooms)
180 {
183 SetRoom(genRoom);
184 }
185 }
187 foreach (
GenRoom value
in rooms.Values)
188 {
190 }
193 Debug.Log(
"Dungen: room:" + rooms.Count +
"/" + mapData.rooms.Count +
" width:" +
width +
" height:" +
height);
195 num2 = num2 * Mathf.Min(20 +
zone.
DangerLv * 5, 100) / 100;
197 {
198 num2 /= 5;
199 }
200 for (int k = 0; k < num2; k++)
201 {
204 {
207 }
208 }
210 {
212 int tries = 3;
214 {
215 int id = ((EClass.rnd(3) == 0) ? 108 : 105);
216 foreach (Point point2 in r.points)
217 {
218 if (!point2.cell.isModified && !point2.HasThing && !point2.HasBlock && !point2.HasObj)
219 {
220 map.SetObj(point2.x, point2.z, id);
221 int num3 = 3;
222 if (EClass.rnd(6) == 0)
223 {
224 num3++;
225 }
226 point2.growth.SetStage(num3);
227 }
228 }
229 return false;
230 });
231 }
233 {
235 {
236 Debug.Log("Purging Door:" + t.Name + "/" + t.pos);
237 t.Destroy();
238 }
239 });
240 if (thing != null)
241 {
242 ClearPos(thing);
243 }
244 if (thing2 != null)
245 {
246 ClearPos(thing2);
247 }
248 return true;
249 static void ClearPos(
Thing t)
250 {
252 {
254 {
256 }
257 }
260 t.pos.cell.height = 0;
261 }
263 {
266 room.gen = this;
268 rooms[room.
Index] = room;
270 Debug.Log(
"Room" + count +
" " + room.
width +
"*" + room.
height +
" " + room);
271 count++;
272 }
273 }
void SetSize(int size, int _poiSize)
string GetIdStairs(bool upstairs)
void Populate(Point point, bool interior=false)
static Crawler Create(string id)
bool CrawlUntil(Map map, Func< Point > onStart, int tries, Func< Result, bool > canComplete, Action onFail=null)
static SourceManager sources
void SetBlock(BiomeProfile.Tile t, int x, int z, int idMat=-1)
void SetFloor(BiomeProfile.Tile t, int x, int z)
void Init(Dungen.Room room)
static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string cat, SourceMaterial.Row fallback)
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
void CreateNew(int size, bool setReference=true)
void SetObj(int id=0, int value=1, int dir=0)
List< Card > ListCards(bool includeMasked=false)
Point Set(int _x, int _z)
void SetBlock(int idMat=0, int idBlock=0)
static int Range(int min, int max)
static Thing CreateFromCategory(string idCat, int lv=-1)
static Thing Create(string id, int idMat=-1, int lv=-1)
bool IsValid(bool shouldLookGood=true)
virtual bool ShouldMakeExit
virtual void OnGenerateRooms(BaseMapGen gen)
Card AddCard(Card t, Point point)