the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2#include "StructurePiece.h"
3
4class NetherBridgePieces
5{
6private:
7 static const int MAX_DEPTH = 30;
8 // the dungeon starts at 64 and traverses downwards to this point
9 static const int LOWEST_Y_POSITION = 10;
10
11 // 4J - added to replace use of Class<? extends NetherBridgePiece> within this class
12 enum EPieceClass
13 {
14 EPieceClass_BridgeStraight,
15 EPieceClass_BridgeEndFiller,
16 EPieceClass_BridgeCrossing,
17 EPieceClass_RoomCrossing,
18 EPieceClass_StairsRoom,
19 EPieceClass_MonsterThrone,
20 EPieceClass_CastleEntrance,
21 EPieceClass_CastleStalkRoom,
22 EPieceClass_CastleSmallCorridorPiece,
23 EPieceClass_CastleSmallCorridorCrossingPiece,
24 EPieceClass_CastleSmallCorridorRightTurnPiece,
25 EPieceClass_CastleSmallCorridorLeftTurnPiece,
26 EPieceClass_CastleCorridorStairsPiece,
27 EPieceClass_CastleCorridorTBalconyPiece
28 };
29
30public:
31 static void loadStatic();
32
33private:
34 class PieceWeight
35 {
36 public:
37 EPieceClass pieceClass;
38 const int weight;
39 int placeCount;
40 int maxPlaceCount;
41 bool allowInRow;
42
43 PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount, bool allowInRow);
44 PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount);
45 bool doPlace(int depth);
46 bool isValid();
47 };
48
49 static const int BRIDGE_PIECEWEIGHTS_COUNT = 6;
50 static const int CASTLE_PIECEWEIGHTS_COUNT = 7;
51 static NetherBridgePieces::PieceWeight *bridgePieceWeights[BRIDGE_PIECEWEIGHTS_COUNT];
52 static NetherBridgePieces::PieceWeight *castlePieceWeights[CASTLE_PIECEWEIGHTS_COUNT];
53
54private:
55 class NetherBridgePiece;
56 static NetherBridgePiece *findAndCreateBridgePieceFactory(NetherBridgePieces::PieceWeight *piece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
57
58 /**
59 *
60 *
61 */
62public:
63 class StartPiece;
64private:
65
66 class NetherBridgePiece : public StructurePiece
67 {
68 protected:
69 static const int FORTRESS_TREASURE_ITEMS_COUNT = 11;
70 static WeighedTreasure *fortressTreasureItems[FORTRESS_TREASURE_ITEMS_COUNT];
71
72 public:
73 NetherBridgePiece();
74
75 protected:
76 NetherBridgePiece(int genDepth);
77
78 virtual void readAdditonalSaveData(CompoundTag *tag);
79 virtual void addAdditonalSaveData(CompoundTag *tag);
80
81 private:
82 int updatePieceWeight(list<PieceWeight *> *currentPieces);
83
84 NetherBridgePiece *generatePiece(StartPiece *startPiece, list<NetherBridgePieces::PieceWeight *> *currentPieces, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
85 StructurePiece *generateAndAddPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth, bool isCastle);
86 protected:
87 StructurePiece *generateChildForward(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int xOff, int yOff, bool isCastle);
88 StructurePiece *generateChildLeft(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff, bool isCastle);
89 StructurePiece *generateChildRight(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff, bool isCastle);
90
91 static bool isOkBox(BoundingBox *box, StartPiece *startRoom); // 4J added startRoom param
92 void generateLightPost(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z, int xOff, int zOff);
93
94 void generateLightPostFacingRight(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
95 void generateLightPostFacingLeft(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
96 void generateLightPostFacingUp(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
97 void generateLightPostFacingDown(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
98 };
99
100 /**
101 *
102 *
103 */
104 class BridgeStraight : public NetherBridgePiece
105 {
106 public:
107 static StructurePiece *Create() { return new BridgeStraight(); }
108 virtual EStructurePiece GetType() { return eStructurePiece_BridgeStraight; }
109
110 private:
111 static const int width = 5;
112 static const int height = 10;
113 static const int depth = 19;
114
115 public:
116 BridgeStraight();
117 BridgeStraight(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
118 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
119 static BridgeStraight *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
120 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
121 };
122
123 class BridgeEndFiller : public NetherBridgePiece
124 {
125 public:
126 static StructurePiece *Create() { return new BridgeEndFiller(); }
127 virtual EStructurePiece GetType() { return eStructurePiece_BridgeEndFiller; }
128
129 private:
130 static const int width = 5;
131 static const int height = 10;
132 static const int depth = 8;
133
134 int selfSeed;
135
136 public:
137 BridgeEndFiller();
138 BridgeEndFiller(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
139
140 static BridgeEndFiller *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
141 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
142
143 protected:
144 void readAdditonalSaveData(CompoundTag *tag);
145 void addAdditonalSaveData(CompoundTag *tag);
146 };
147
148 class BridgeCrossing : public NetherBridgePiece
149 {
150 public:
151 static StructurePiece *Create() { return new BridgeCrossing(); }
152 virtual EStructurePiece GetType() { return eStructurePiece_BridgeCrossing; }
153
154 private:
155 static const int width = 19;
156 static const int height = 10;
157 static const int depth = 19;
158
159 public:
160 BridgeCrossing();
161 BridgeCrossing(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
162 protected:
163 BridgeCrossing(Random *random, int west, int north);
164 public:
165 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
166 static BridgeCrossing *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
167 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
168 };
169
170public:
171 class StartPiece : public BridgeCrossing
172 {
173 public:
174 virtual EStructurePiece GetType() { return eStructurePiece_NetherBridgeStartPiece; }
175
176 public:
177 PieceWeight *previousPiece;
178 Level *m_level;
179
180 list<PieceWeight *> availableBridgePieces;
181 list<PieceWeight *> availableCastlePieces;
182
183 // this queue is used so that the addChildren calls are
184 // called in a random order
185 vector<StructurePiece *> pendingChildren;
186
187 StartPiece();
188 StartPiece(Random *random, int west, int north, Level *level); // 4J Added level param
189
190 protected:
191 virtual void readAdditonalSaveData(CompoundTag *tag);
192 virtual void addAdditonalSaveData(CompoundTag *tag);
193 };
194
195private:
196 class RoomCrossing : public NetherBridgePiece
197 {
198 public:
199 static StructurePiece *Create() { return new RoomCrossing(); }
200 virtual EStructurePiece GetType() { return eStructurePiece_RoomCrossing; }
201
202 private:
203 static const int width = 7;
204 static const int height = 9;
205 static const int depth = 7;
206
207 public:
208 RoomCrossing();
209 RoomCrossing(int genDepth, Random *random, BoundingBox *box, int direction);
210 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
211 static RoomCrossing *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
212 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
213 };
214
215 class StairsRoom : public NetherBridgePiece
216 {
217 public:
218 static StructurePiece *Create() { return new StairsRoom(); }
219 virtual EStructurePiece GetType() { return eStructurePiece_StairsRoom; }
220
221 private:
222 static const int width = 7;
223 static const int height = 11;
224 static const int depth = 7;
225
226 public:
227 StairsRoom();
228 StairsRoom(int genDepth, Random *random, BoundingBox *box, int direction);
229 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
230 static StairsRoom *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
231 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
232 };
233
234 class MonsterThrone : public NetherBridgePiece
235 {
236 public:
237 static StructurePiece *Create() { return new MonsterThrone(); }
238 virtual EStructurePiece GetType() { return eStructurePiece_MonsterThrone; }
239
240 private:
241 static const int width = 7;
242 static const int height = 8;
243 static const int depth = 9;
244
245 bool hasPlacedMobSpawner;
246
247 public:
248 MonsterThrone();
249 MonsterThrone(int genDepth, Random *random, BoundingBox *box, int direction);
250
251 protected:
252 virtual void readAdditonalSaveData(CompoundTag *tag);
253 virtual void addAdditonalSaveData(CompoundTag *tag);
254
255 public:
256 static MonsterThrone *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
257 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
258 };
259
260 /**
261 *
262 *
263 */
264 class CastleEntrance : public NetherBridgePiece
265 {
266 public:
267 static StructurePiece *Create() { return new CastleEntrance(); }
268 virtual EStructurePiece GetType() { return eStructurePiece_CastleEntrance; }
269
270 private:
271 static const int width = 13;
272 static const int height = 14;
273 static const int depth = 13;
274 public:
275 CastleEntrance();
276 CastleEntrance(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
277 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
278 static CastleEntrance *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
279 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
280 };
281
282 /**
283 *
284 *
285 */
286 class CastleStalkRoom : public NetherBridgePiece
287 {
288 public:
289 static StructurePiece *Create() { return new CastleStalkRoom(); }
290 virtual EStructurePiece GetType() { return eStructurePiece_CastleStalkRoom; }
291
292 private:
293 static const int width = 13;
294 static const int height = 14;
295 static const int depth = 13;
296
297 public:
298 CastleStalkRoom();
299 CastleStalkRoom(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
300 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
301 static CastleStalkRoom *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
302 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
303 };
304
305 /**
306 *
307 *
308 */
309 class CastleSmallCorridorPiece : public NetherBridgePiece
310 {
311 public:
312 static StructurePiece *Create() { return new CastleSmallCorridorPiece(); }
313 virtual EStructurePiece GetType() { return eStructurePiece_CastleSmallCorridorPiece; }
314
315 private:
316 static const int width = 5;
317 static const int height = 7;
318 static const int depth = 5;
319
320 public:
321 CastleSmallCorridorPiece();
322 CastleSmallCorridorPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
323 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
324 static CastleSmallCorridorPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
325 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
326 };
327
328 /**
329 *
330 *
331 */
332 class CastleSmallCorridorCrossingPiece : public NetherBridgePiece
333 {
334 public:
335 static StructurePiece *Create() { return new CastleSmallCorridorCrossingPiece(); }
336 virtual EStructurePiece GetType() { return eStructurePiece_CastleSmallCorridorCrossingPiece; }
337
338 private:
339 static const int width = 5;
340 static const int height = 7;
341 static const int depth = 5;
342
343 public:
344 CastleSmallCorridorCrossingPiece();
345 CastleSmallCorridorCrossingPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
346 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
347 static CastleSmallCorridorCrossingPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
348 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
349 };
350
351 /**
352 *
353 *
354 */
355 class CastleSmallCorridorRightTurnPiece : public NetherBridgePiece
356 {
357 public:
358 static StructurePiece *Create() { return new CastleSmallCorridorRightTurnPiece(); }
359 virtual EStructurePiece GetType() { return eStructurePiece_CastleSmallCorridorRightTurnPiece; }
360
361 private:
362 static const int width = 5;
363 static const int height = 7;
364 static const int depth = 5;
365
366 bool isNeedingChest;
367
368 public:
369 CastleSmallCorridorRightTurnPiece();
370 CastleSmallCorridorRightTurnPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
371
372 protected:
373 virtual void readAdditonalSaveData(CompoundTag *tag);
374 virtual void addAdditonalSaveData(CompoundTag *tag);
375
376 public:
377 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
378 static CastleSmallCorridorRightTurnPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
379 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
380
381 };
382
383 /**
384 *
385 *
386 */
387 class CastleSmallCorridorLeftTurnPiece : public NetherBridgePiece
388 {
389 public:
390 static StructurePiece *Create() { return new CastleSmallCorridorLeftTurnPiece(); }
391 virtual EStructurePiece GetType() { return eStructurePiece_CastleSmallCorridorLeftTurnPiece; }
392
393 private:
394 static const int width = 5;
395 static const int height = 7;
396 static const int depth = 5;
397 bool isNeedingChest;
398
399 public:
400 CastleSmallCorridorLeftTurnPiece();
401 CastleSmallCorridorLeftTurnPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
402
403 protected:
404 virtual void readAdditonalSaveData(CompoundTag *tag);
405 virtual void addAdditonalSaveData(CompoundTag *tag);
406
407 public:
408 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
409 static CastleSmallCorridorLeftTurnPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
410 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
411 };
412
413 /**
414 *
415 *
416 */
417 class CastleCorridorStairsPiece : public NetherBridgePiece
418 {
419 public:
420 static StructurePiece *Create() { return new CastleCorridorStairsPiece(); }
421 virtual EStructurePiece GetType() { return eStructurePiece_CastleCorridorStairsPiece; }
422
423 private:
424 static const int width = 5;
425 static const int height = 14;
426 static const int depth = 10;
427
428 public:
429 CastleCorridorStairsPiece();
430 CastleCorridorStairsPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
431 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
432 static CastleCorridorStairsPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
433 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
434
435 };
436
437 /**
438 *
439 *
440 */
441 class CastleCorridorTBalconyPiece : public NetherBridgePiece
442 {
443 public:
444 static StructurePiece *Create() { return new CastleCorridorTBalconyPiece(); }
445 virtual EStructurePiece GetType() { return eStructurePiece_CastleCorridorTBalconyPiece; }
446
447 private:
448 static const int width = 9;
449 static const int height = 7;
450 static const int depth = 9;
451
452 public:
453 CastleCorridorTBalconyPiece();
454 CastleCorridorTBalconyPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
455 virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
456 static CastleCorridorTBalconyPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
457 virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
458 };
459};