mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-08-02 16:01:16 +00:00
chore: format Minecraft.World
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2,95 +2,115 @@
|
||||
|
||||
#include "StructurePiece.h"
|
||||
|
||||
class MineShaftPieces
|
||||
{
|
||||
class MineShaftPieces {
|
||||
private:
|
||||
static const int DEFAULT_SHAFT_WIDTH = 3;
|
||||
static const int DEFAULT_SHAFT_HEIGHT = 3;
|
||||
static const int DEFAULT_SHAFT_LENGTH = 5;
|
||||
static const int DEFAULT_SHAFT_WIDTH = 3;
|
||||
static const int DEFAULT_SHAFT_HEIGHT = 3;
|
||||
static const int DEFAULT_SHAFT_LENGTH = 5;
|
||||
|
||||
static const int MAX_DEPTH = 8; // 1.2.3 change
|
||||
static const int MAX_DEPTH = 8; // 1.2.3 change
|
||||
|
||||
static StructurePiece *createRandomShaftPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
static StructurePiece *generateAndAddPiece(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
static StructurePiece* createRandomShaftPiece(
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int genDepth);
|
||||
static StructurePiece* generateAndAddPiece(
|
||||
StructurePiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY, int footZ, int direction,
|
||||
int depth);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class MineShaftRoom : public StructurePiece
|
||||
{
|
||||
private:
|
||||
std::list<BoundingBox *> childEntranceBoxes;
|
||||
class MineShaftRoom : public StructurePiece {
|
||||
private:
|
||||
std::list<BoundingBox*> childEntranceBoxes;
|
||||
|
||||
public:
|
||||
MineShaftRoom(int genDepth, Random *random, int west, int north);
|
||||
~MineShaftRoom();
|
||||
public:
|
||||
MineShaftRoom(int genDepth, Random* random, int west, int north);
|
||||
~MineShaftRoom();
|
||||
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
};
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class MineShaftCorridor : public StructurePiece
|
||||
{
|
||||
private:
|
||||
bool hasRails; // was final
|
||||
bool spiderCorridor; // was final
|
||||
bool hasPlacedSpider;
|
||||
int numSections;
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class MineShaftCorridor : public StructurePiece {
|
||||
private:
|
||||
bool hasRails; // was final
|
||||
bool spiderCorridor; // was final
|
||||
bool hasPlacedSpider;
|
||||
int numSections;
|
||||
|
||||
public:
|
||||
MineShaftCorridor(int genDepth, Random *random, BoundingBox *corridorBox, int direction);
|
||||
public:
|
||||
MineShaftCorridor(int genDepth, Random* random,
|
||||
BoundingBox* corridorBox, int direction);
|
||||
|
||||
static BoundingBox *findCorridorSize(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
};
|
||||
static BoundingBox* findCorridorSize(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX,
|
||||
int footY, int footZ,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class MineShaftCrossing : public StructurePiece
|
||||
{
|
||||
private:
|
||||
const int direction;
|
||||
const bool isTwoFloored;
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class MineShaftCrossing : public StructurePiece {
|
||||
private:
|
||||
const int direction;
|
||||
const bool isTwoFloored;
|
||||
|
||||
public:
|
||||
MineShaftCrossing(int genDepth, Random *random, BoundingBox *crossingBox, int direction);
|
||||
public:
|
||||
MineShaftCrossing(int genDepth, Random* random,
|
||||
BoundingBox* crossingBox, int direction);
|
||||
|
||||
static BoundingBox *findCrossing(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
};
|
||||
static BoundingBox* findCrossing(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class MineShaftStairs : public StructurePiece
|
||||
{
|
||||
public:
|
||||
MineShaftStairs(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class MineShaftStairs : public StructurePiece {
|
||||
public:
|
||||
MineShaftStairs(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
|
||||
static BoundingBox *findStairs(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
static BoundingBox* findStairs(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/* @formatter:off */
|
||||
/* @formatter:off */
|
||||
private:
|
||||
static WeighedTreasureArray smallTreasureItems;
|
||||
/* @formatter:on */
|
||||
static WeighedTreasureArray smallTreasureItems;
|
||||
/* @formatter:on */
|
||||
|
||||
public:
|
||||
static void staticCtor();
|
||||
|
||||
static void staticCtor();
|
||||
};
|
||||
@@ -1,13 +1,16 @@
|
||||
#include "../../Platform/stdafx.h"
|
||||
#include "../../Headers/net.minecraft.world.level.levelgen.structure.h"
|
||||
|
||||
MineShaftStart::MineShaftStart(Level *level, Random *random, int chunkX, int chunkZ)
|
||||
{
|
||||
// 4jcraft added to unsigned
|
||||
MineShaftPieces::MineShaftRoom *mineShaftRoom = new MineShaftPieces::MineShaftRoom(0, random, ((unsigned) chunkX << 4) + 2, ((unsigned) chunkZ << 4) + 2);
|
||||
pieces.push_back(mineShaftRoom);
|
||||
mineShaftRoom->addChildren(mineShaftRoom, &pieces, random);
|
||||
MineShaftStart::MineShaftStart(Level* level, Random* random, int chunkX,
|
||||
int chunkZ) {
|
||||
// 4jcraft added to unsigned
|
||||
MineShaftPieces::MineShaftRoom* mineShaftRoom =
|
||||
new MineShaftPieces::MineShaftRoom(0, random,
|
||||
((unsigned)chunkX << 4) + 2,
|
||||
((unsigned)chunkZ << 4) + 2);
|
||||
pieces.push_back(mineShaftRoom);
|
||||
mineShaftRoom->addChildren(mineShaftRoom, &pieces, random);
|
||||
|
||||
calculateBoundingBox();
|
||||
moveBelowSeaLevel(level, random, 10);
|
||||
calculateBoundingBox();
|
||||
moveBelowSeaLevel(level, random, 10);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
#include "StructureStart.h"
|
||||
|
||||
class MineShaftStart : public StructureStart
|
||||
{
|
||||
class MineShaftStart : public StructureStart {
|
||||
public:
|
||||
MineShaftStart(Level *level, Random *random, int chunkX, int chunkZ);
|
||||
MineShaftStart(Level* level, Random* random, int chunkX, int chunkZ);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,343 +1,449 @@
|
||||
#pragma once
|
||||
#include "StructurePiece.h"
|
||||
|
||||
class NetherBridgePieces
|
||||
{
|
||||
class NetherBridgePieces {
|
||||
private:
|
||||
static const int MAX_DEPTH = 30;
|
||||
static const int MAX_DEPTH = 30;
|
||||
// the dungeon starts at 64 and traverses downwards to this point
|
||||
static const int LOWEST_Y_POSITION = 10;
|
||||
|
||||
// 4J - added to replace use of Class<? extends NetherBridgePiece> within this class
|
||||
enum EPieceClass
|
||||
{
|
||||
EPieceClass_BridgeStraight,
|
||||
EPieceClass_BridgeEndFiller,
|
||||
EPieceClass_BridgeCrossing,
|
||||
EPieceClass_RoomCrossing,
|
||||
EPieceClass_StairsRoom,
|
||||
EPieceClass_MonsterThrone,
|
||||
EPieceClass_CastleEntrance,
|
||||
EPieceClass_CastleStalkRoom,
|
||||
EPieceClass_CastleSmallCorridorPiece,
|
||||
EPieceClass_CastleSmallCorridorCrossingPiece,
|
||||
EPieceClass_CastleSmallCorridorRightTurnPiece,
|
||||
EPieceClass_CastleSmallCorridorLeftTurnPiece,
|
||||
EPieceClass_CastleCorridorStairsPiece,
|
||||
EPieceClass_CastleCorridorTBalconyPiece
|
||||
};
|
||||
// 4J - added to replace use of Class<? extends NetherBridgePiece> within
|
||||
// this class
|
||||
enum EPieceClass {
|
||||
EPieceClass_BridgeStraight,
|
||||
EPieceClass_BridgeEndFiller,
|
||||
EPieceClass_BridgeCrossing,
|
||||
EPieceClass_RoomCrossing,
|
||||
EPieceClass_StairsRoom,
|
||||
EPieceClass_MonsterThrone,
|
||||
EPieceClass_CastleEntrance,
|
||||
EPieceClass_CastleStalkRoom,
|
||||
EPieceClass_CastleSmallCorridorPiece,
|
||||
EPieceClass_CastleSmallCorridorCrossingPiece,
|
||||
EPieceClass_CastleSmallCorridorRightTurnPiece,
|
||||
EPieceClass_CastleSmallCorridorLeftTurnPiece,
|
||||
EPieceClass_CastleCorridorStairsPiece,
|
||||
EPieceClass_CastleCorridorTBalconyPiece
|
||||
};
|
||||
|
||||
class PieceWeight
|
||||
{
|
||||
public:
|
||||
class PieceWeight {
|
||||
public:
|
||||
EPieceClass pieceClass;
|
||||
const int weight;
|
||||
int placeCount;
|
||||
int maxPlaceCount;
|
||||
bool allowInRow;
|
||||
|
||||
PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount, bool allowInRow);
|
||||
PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount,
|
||||
bool allowInRow);
|
||||
PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount);
|
||||
bool doPlace(int depth);
|
||||
bool isValid();
|
||||
};
|
||||
|
||||
static const int BRIDGE_PIECEWEIGHTS_COUNT = 6;
|
||||
static const int CASTLE_PIECEWEIGHTS_COUNT = 7;
|
||||
static NetherBridgePieces::PieceWeight *bridgePieceWeights[BRIDGE_PIECEWEIGHTS_COUNT];
|
||||
static NetherBridgePieces::PieceWeight *castlePieceWeights[CASTLE_PIECEWEIGHTS_COUNT];
|
||||
static const int BRIDGE_PIECEWEIGHTS_COUNT = 6;
|
||||
static const int CASTLE_PIECEWEIGHTS_COUNT = 7;
|
||||
static NetherBridgePieces::PieceWeight*
|
||||
bridgePieceWeights[BRIDGE_PIECEWEIGHTS_COUNT];
|
||||
static NetherBridgePieces::PieceWeight*
|
||||
castlePieceWeights[CASTLE_PIECEWEIGHTS_COUNT];
|
||||
|
||||
private:
|
||||
class NetherBridgePiece;
|
||||
static NetherBridgePiece *findAndCreateBridgePieceFactory(NetherBridgePieces::PieceWeight *piece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
class NetherBridgePiece;
|
||||
static NetherBridgePiece* findAndCreateBridgePieceFactory(
|
||||
NetherBridgePieces::PieceWeight* piece,
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int depth);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class StartPiece;
|
||||
class StartPiece;
|
||||
|
||||
private:
|
||||
class NetherBridgePiece : public StructurePiece {
|
||||
protected:
|
||||
NetherBridgePiece(int genDepth);
|
||||
|
||||
class NetherBridgePiece : public StructurePiece
|
||||
{
|
||||
protected:
|
||||
NetherBridgePiece(int genDepth);
|
||||
private:
|
||||
int updatePieceWeight(std::list<PieceWeight *> *currentPieces);
|
||||
private:
|
||||
int updatePieceWeight(std::list<PieceWeight*>* currentPieces);
|
||||
|
||||
NetherBridgePiece *generatePiece(StartPiece *startPiece, std::list<NetherBridgePieces::PieceWeight *> *currentPieces, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
StructurePiece *generateAndAddPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth, bool isCastle);
|
||||
protected:
|
||||
StructurePiece *generateChildForward(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int xOff, int yOff, bool isCastle);
|
||||
StructurePiece *generateChildLeft(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int yOff, int zOff, bool isCastle);
|
||||
StructurePiece *generateChildRight(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int yOff, int zOff, bool isCastle);
|
||||
|
||||
static bool isOkBox(BoundingBox *box, StartPiece *startRoom); // 4J added startRoom param
|
||||
void generateLightPost(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z, int xOff, int zOff);
|
||||
|
||||
void generateLightPostFacingRight(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
|
||||
void generateLightPostFacingLeft(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
|
||||
void generateLightPostFacingUp(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
|
||||
void generateLightPostFacingDown(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
|
||||
NetherBridgePiece* generatePiece(
|
||||
StartPiece* startPiece,
|
||||
std::list<NetherBridgePieces::PieceWeight*>* currentPieces,
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int depth);
|
||||
StructurePiece* generateAndAddPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX,
|
||||
int footY, int footZ, int direction,
|
||||
int depth, bool isCastle);
|
||||
|
||||
protected:
|
||||
StructurePiece* generateChildForward(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int xOff, int yOff,
|
||||
bool isCastle);
|
||||
StructurePiece* generateChildLeft(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int yOff, int zOff,
|
||||
bool isCastle);
|
||||
StructurePiece* generateChildRight(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int yOff, int zOff,
|
||||
bool isCastle);
|
||||
|
||||
static bool isOkBox(BoundingBox* box,
|
||||
StartPiece* startRoom); // 4J added startRoom param
|
||||
void generateLightPost(Level* level, Random* random,
|
||||
BoundingBox* chunkBB, int x, int y, int z,
|
||||
int xOff, int zOff);
|
||||
|
||||
void generateLightPostFacingRight(Level* level, Random* random,
|
||||
BoundingBox* chunkBB, int x, int y,
|
||||
int z);
|
||||
void generateLightPostFacingLeft(Level* level, Random* random,
|
||||
BoundingBox* chunkBB, int x, int y,
|
||||
int z);
|
||||
void generateLightPostFacingUp(Level* level, Random* random,
|
||||
BoundingBox* chunkBB, int x, int y,
|
||||
int z);
|
||||
void generateLightPostFacingDown(Level* level, Random* random,
|
||||
BoundingBox* chunkBB, int x, int y,
|
||||
int z);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class BridgeStraight : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
class BridgeStraight : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 10;
|
||||
static const int depth = 19;
|
||||
|
||||
public:
|
||||
BridgeStraight(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static BridgeStraight *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
BridgeStraight(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static BridgeStraight* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
class BridgeEndFiller : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
class BridgeEndFiller : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 10;
|
||||
static const int depth = 8;
|
||||
|
||||
int selfSeed;
|
||||
|
||||
public:
|
||||
BridgeEndFiller(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
static BridgeEndFiller *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
BridgeEndFiller(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
static BridgeEndFiller* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX,
|
||||
int footY, int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
class BridgeCrossing : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 19;
|
||||
class BridgeCrossing : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 19;
|
||||
static const int height = 10;
|
||||
static const int depth = 19;
|
||||
|
||||
public:
|
||||
BridgeCrossing(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
protected:
|
||||
BridgeCrossing(Random *random, int west, int north);
|
||||
public:
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static BridgeCrossing *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
BridgeCrossing(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
|
||||
protected:
|
||||
BridgeCrossing(Random* random, int west, int north);
|
||||
|
||||
public:
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static BridgeCrossing* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class StartPiece : public BridgeCrossing
|
||||
{
|
||||
class StartPiece : public BridgeCrossing {
|
||||
public:
|
||||
bool isLibraryAdded;
|
||||
PieceWeight* previousPiece;
|
||||
Level* m_level;
|
||||
|
||||
public:
|
||||
bool isLibraryAdded;
|
||||
PieceWeight *previousPiece;
|
||||
Level *m_level;
|
||||
|
||||
std::list<PieceWeight *> availableBridgePieces;
|
||||
std::list<PieceWeight *> availableCastlePieces;
|
||||
std::list<PieceWeight*> availableBridgePieces;
|
||||
std::list<PieceWeight*> availableCastlePieces;
|
||||
|
||||
// this queue is used so that the addChildren calls are
|
||||
// called in a random order
|
||||
std::vector<StructurePiece *> pendingChildren;
|
||||
|
||||
StartPiece(Random *random, int west, int north, Level *level); // 4J Added level param
|
||||
std::vector<StructurePiece*> pendingChildren;
|
||||
|
||||
StartPiece(Random* random, int west, int north,
|
||||
Level* level); // 4J Added level param
|
||||
};
|
||||
|
||||
private:
|
||||
class RoomCrossing : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 7;
|
||||
class RoomCrossing : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 7;
|
||||
static const int height = 9;
|
||||
static const int depth = 7;
|
||||
|
||||
public:
|
||||
RoomCrossing(int genDepth, Random *random, BoundingBox *box, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static RoomCrossing *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
RoomCrossing(int genDepth, Random* random, BoundingBox* box,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static RoomCrossing* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
class StairsRoom : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 7;
|
||||
class StairsRoom : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 7;
|
||||
static const int height = 11;
|
||||
static const int depth = 7;
|
||||
|
||||
public:
|
||||
StairsRoom(int genDepth, Random *random, BoundingBox *box, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static StairsRoom *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
StairsRoom(int genDepth, Random* random, BoundingBox* box,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static StairsRoom* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
class MonsterThrone : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 7;
|
||||
class MonsterThrone : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 7;
|
||||
static const int height = 8;
|
||||
static const int depth = 9;
|
||||
|
||||
bool hasPlacedMobSpawner;
|
||||
|
||||
public:
|
||||
MonsterThrone(int genDepth, Random *random, BoundingBox *box, int direction);
|
||||
static MonsterThrone *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
MonsterThrone(int genDepth, Random* random, BoundingBox* box,
|
||||
int direction);
|
||||
static MonsterThrone* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleEntrance : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 13;
|
||||
static const int height = 14;
|
||||
static const int depth = 13;
|
||||
public:
|
||||
CastleEntrance(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static CastleEntrance *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleStalkRoom : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
class CastleEntrance : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 13;
|
||||
static const int height = 14;
|
||||
static const int depth = 13;
|
||||
|
||||
public:
|
||||
CastleStalkRoom(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static CastleStalkRoom *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
CastleEntrance(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static CastleEntrance* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleSmallCorridorPiece : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
class CastleStalkRoom : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 13;
|
||||
static const int height = 14;
|
||||
static const int depth = 13;
|
||||
|
||||
public:
|
||||
CastleStalkRoom(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static CastleStalkRoom* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX,
|
||||
int footY, int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleSmallCorridorPiece : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 7;
|
||||
static const int depth = 5;
|
||||
|
||||
public:
|
||||
CastleSmallCorridorPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static CastleSmallCorridorPiece *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
CastleSmallCorridorPiece(int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static CastleSmallCorridorPiece* createPiece(
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleSmallCorridorCrossingPiece : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
class CastleSmallCorridorCrossingPiece : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 7;
|
||||
static const int depth = 5;
|
||||
|
||||
public:
|
||||
CastleSmallCorridorCrossingPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static CastleSmallCorridorCrossingPiece *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
CastleSmallCorridorCrossingPiece(int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static CastleSmallCorridorCrossingPiece* createPiece(
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleSmallCorridorRightTurnPiece : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 7;
|
||||
static const int depth = 5;
|
||||
|
||||
public:
|
||||
CastleSmallCorridorRightTurnPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static CastleSmallCorridorRightTurnPiece *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
class CastleSmallCorridorRightTurnPiece : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 7;
|
||||
static const int depth = 5;
|
||||
|
||||
public:
|
||||
CastleSmallCorridorRightTurnPiece(int genDepth, Random* random,
|
||||
BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static CastleSmallCorridorRightTurnPiece* createPiece(
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleSmallCorridorLeftTurnPiece : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 7;
|
||||
static const int depth = 5;
|
||||
class CastleSmallCorridorLeftTurnPiece : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 7;
|
||||
static const int depth = 5;
|
||||
|
||||
public:
|
||||
CastleSmallCorridorLeftTurnPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static CastleSmallCorridorLeftTurnPiece *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
CastleSmallCorridorLeftTurnPiece(int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static CastleSmallCorridorLeftTurnPiece* createPiece(
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleCorridorStairsPiece : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 14;
|
||||
static const int depth = 10;
|
||||
|
||||
public:
|
||||
CastleCorridorStairsPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static CastleCorridorStairsPiece *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
class CastleCorridorStairsPiece : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 14;
|
||||
static const int depth = 10;
|
||||
|
||||
public:
|
||||
CastleCorridorStairsPiece(int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static CastleCorridorStairsPiece* createPiece(
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CastleCorridorTBalconyPiece : public NetherBridgePiece
|
||||
{
|
||||
private:
|
||||
class CastleCorridorTBalconyPiece : public NetherBridgePiece {
|
||||
private:
|
||||
static const int width = 9;
|
||||
static const int height = 7;
|
||||
static const int depth = 9;
|
||||
|
||||
public:
|
||||
CastleCorridorTBalconyPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static CastleCorridorTBalconyPiece *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
CastleCorridorTBalconyPiece(int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static CastleCorridorTBalconyPiece* createPiece(
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,66 +2,64 @@
|
||||
|
||||
#include "StructurePiece.h"
|
||||
|
||||
class ScatteredFeaturePieces
|
||||
{
|
||||
class ScatteredFeaturePieces {
|
||||
private:
|
||||
class ScatteredFeaturePiece : public StructurePiece
|
||||
{
|
||||
protected:
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
class ScatteredFeaturePiece : public StructurePiece {
|
||||
protected:
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
|
||||
int heightPosition;
|
||||
int heightPosition;
|
||||
|
||||
ScatteredFeaturePiece(Random *random, int west, int floor, int north, int width, int height, int depth);
|
||||
ScatteredFeaturePiece(Random* random, int west, int floor, int north,
|
||||
int width, int height, int depth);
|
||||
|
||||
bool updateAverageGroundHeight(Level *level, BoundingBox *chunkBB, int offset);
|
||||
};
|
||||
bool updateAverageGroundHeight(Level* level, BoundingBox* chunkBB,
|
||||
int offset);
|
||||
};
|
||||
|
||||
public:
|
||||
class DesertPyramidPiece : public ScatteredFeaturePiece
|
||||
{
|
||||
public:
|
||||
static const int TREASURE_ITEMS_COUNT = 6;
|
||||
private:
|
||||
bool hasPlacedChest[4];
|
||||
static WeighedTreasure *treasureItems[TREASURE_ITEMS_COUNT];
|
||||
class DesertPyramidPiece : public ScatteredFeaturePiece {
|
||||
public:
|
||||
static const int TREASURE_ITEMS_COUNT = 6;
|
||||
|
||||
public:
|
||||
DesertPyramidPiece(Random *random, int west, int north);
|
||||
private:
|
||||
bool hasPlacedChest[4];
|
||||
static WeighedTreasure* treasureItems[TREASURE_ITEMS_COUNT];
|
||||
|
||||
bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
DesertPyramidPiece(Random* random, int west, int north);
|
||||
|
||||
};
|
||||
bool postProcess(Level* level, Random* random, BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
class JunglePyramidPiece : public ScatteredFeaturePiece
|
||||
{
|
||||
public:
|
||||
static const int TREASURE_ITEMS_COUNT = 6;
|
||||
static const int DISPENSER_ITEMS_COUNT = 1;
|
||||
private:
|
||||
bool placedMainChest;
|
||||
bool placedHiddenChest;
|
||||
bool placedTrap1;
|
||||
bool placedTrap2;
|
||||
class JunglePyramidPiece : public ScatteredFeaturePiece {
|
||||
public:
|
||||
static const int TREASURE_ITEMS_COUNT = 6;
|
||||
static const int DISPENSER_ITEMS_COUNT = 1;
|
||||
|
||||
static WeighedTreasure *treasureItems[TREASURE_ITEMS_COUNT];
|
||||
static WeighedTreasure *dispenserItems[DISPENSER_ITEMS_COUNT];
|
||||
private:
|
||||
bool placedMainChest;
|
||||
bool placedHiddenChest;
|
||||
bool placedTrap1;
|
||||
bool placedTrap2;
|
||||
|
||||
public:
|
||||
JunglePyramidPiece(Random *random, int west, int north);
|
||||
static WeighedTreasure* treasureItems[TREASURE_ITEMS_COUNT];
|
||||
static WeighedTreasure* dispenserItems[DISPENSER_ITEMS_COUNT];
|
||||
|
||||
bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
JunglePyramidPiece(Random* random, int west, int north);
|
||||
|
||||
private:
|
||||
class MossStoneSelector : public BlockSelector
|
||||
{
|
||||
public:
|
||||
void next(Random *random, int worldX, int worldY, int worldZ, bool isEdge);
|
||||
};
|
||||
bool postProcess(Level* level, Random* random, BoundingBox* chunkBB);
|
||||
|
||||
static MossStoneSelector stoneSelector;
|
||||
private:
|
||||
class MossStoneSelector : public BlockSelector {
|
||||
public:
|
||||
void next(Random* random, int worldX, int worldY, int worldZ,
|
||||
bool isEdge);
|
||||
};
|
||||
|
||||
};
|
||||
static MossStoneSelector stoneSelector;
|
||||
};
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,396 +1,472 @@
|
||||
#pragma once
|
||||
#include "StructurePiece.h"
|
||||
|
||||
class StrongholdPieces
|
||||
{
|
||||
|
||||
class StrongholdPieces {
|
||||
private:
|
||||
static const int SMALL_DOOR_WIDTH = 3;
|
||||
static const int SMALL_DOOR_WIDTH = 3;
|
||||
static const int SMALL_DOOR_HEIGHT = 3;
|
||||
|
||||
static const int MAX_DEPTH = 50;
|
||||
// the dungeon starts at 64 and traverses downwards to this point
|
||||
static const int LOWEST_Y_POSITION = 10;
|
||||
static const bool CHECK_AIR;
|
||||
static const bool CHECK_AIR;
|
||||
|
||||
// 4J - added to replace use of Class<? extends StrongholdPiece> within this class
|
||||
enum EPieceClass
|
||||
{
|
||||
EPieceClass_NULL,
|
||||
EPieceClass_Straight,
|
||||
EPieceClass_PrisonHall,
|
||||
EPieceClass_LeftTurn,
|
||||
EPieceClass_RightTurn,
|
||||
EPieceClass_RoomCrossing,
|
||||
EPieceClass_StraightStairsDown,
|
||||
EPieceClass_StairsDown,
|
||||
EPieceClass_FiveCrossing,
|
||||
EPieceClass_ChestCorridor,
|
||||
EPieceClass_Library,
|
||||
EPieceClass_PortalRoom
|
||||
};
|
||||
|
||||
class PieceWeight
|
||||
{
|
||||
public:
|
||||
EPieceClass pieceClass; // 4J - was Class<? extends StrongholdPiece>
|
||||
const int weight;
|
||||
int placeCount;
|
||||
int maxPlaceCount;
|
||||
|
||||
PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount);
|
||||
virtual ~PieceWeight(){}
|
||||
virtual bool doPlace(int depth);
|
||||
bool isValid();
|
||||
// 4J - added to replace use of Class<? extends StrongholdPiece> within this
|
||||
// class
|
||||
enum EPieceClass {
|
||||
EPieceClass_NULL,
|
||||
EPieceClass_Straight,
|
||||
EPieceClass_PrisonHall,
|
||||
EPieceClass_LeftTurn,
|
||||
EPieceClass_RightTurn,
|
||||
EPieceClass_RoomCrossing,
|
||||
EPieceClass_StraightStairsDown,
|
||||
EPieceClass_StairsDown,
|
||||
EPieceClass_FiveCrossing,
|
||||
EPieceClass_ChestCorridor,
|
||||
EPieceClass_Library,
|
||||
EPieceClass_PortalRoom
|
||||
};
|
||||
|
||||
// 4J - added, java uses a local specialisation of these classes when instancing to achieve the same thing
|
||||
class PieceWeight_Library : public PieceWeight
|
||||
{
|
||||
public:
|
||||
PieceWeight_Library(EPieceClass pieceClass, int weight, int maxPlaceCount) : PieceWeight(pieceClass, weight, maxPlaceCount) {}
|
||||
virtual bool doPlace(int depth) { return PieceWeight::doPlace(depth) && depth > 4; }
|
||||
};
|
||||
class PieceWeight {
|
||||
public:
|
||||
EPieceClass pieceClass; // 4J - was Class<? extends StrongholdPiece>
|
||||
const int weight;
|
||||
int placeCount;
|
||||
int maxPlaceCount;
|
||||
|
||||
class PieceWeight_PortalRoom : public PieceWeight
|
||||
{
|
||||
public:
|
||||
PieceWeight_PortalRoom(EPieceClass pieceClass, int weight, int maxPlaceCount) : PieceWeight(pieceClass, weight, maxPlaceCount) {}
|
||||
virtual bool doPlace(int depth) { return PieceWeight::doPlace(depth) && depth > 5; }
|
||||
};
|
||||
PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount);
|
||||
virtual ~PieceWeight() {}
|
||||
virtual bool doPlace(int depth);
|
||||
bool isValid();
|
||||
};
|
||||
|
||||
static std::list<PieceWeight *> currentPieces;
|
||||
static EPieceClass imposedPiece;
|
||||
// 4J - added, java uses a local specialisation of these classes when
|
||||
// instancing to achieve the same thing
|
||||
class PieceWeight_Library : public PieceWeight {
|
||||
public:
|
||||
PieceWeight_Library(EPieceClass pieceClass, int weight,
|
||||
int maxPlaceCount)
|
||||
: PieceWeight(pieceClass, weight, maxPlaceCount) {}
|
||||
virtual bool doPlace(int depth) {
|
||||
return PieceWeight::doPlace(depth) && depth > 4;
|
||||
}
|
||||
};
|
||||
|
||||
class PieceWeight_PortalRoom : public PieceWeight {
|
||||
public:
|
||||
PieceWeight_PortalRoom(EPieceClass pieceClass, int weight,
|
||||
int maxPlaceCount)
|
||||
: PieceWeight(pieceClass, weight, maxPlaceCount) {}
|
||||
virtual bool doPlace(int depth) {
|
||||
return PieceWeight::doPlace(depth) && depth > 5;
|
||||
}
|
||||
};
|
||||
|
||||
static std::list<PieceWeight*> currentPieces;
|
||||
static EPieceClass imposedPiece;
|
||||
static int totalWeight;
|
||||
|
||||
public:
|
||||
static void resetPieces();
|
||||
class StartPiece;
|
||||
private:
|
||||
class StrongholdPiece;
|
||||
static bool updatePieceWeight();
|
||||
static StrongholdPiece *findAndCreatePieceFactory(EPieceClass pieceClass, std::list<StructurePiece*> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
static StrongholdPiece *generatePieceFromSmallDoor(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
static StructurePiece *generateAndAddPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
static void resetPieces();
|
||||
class StartPiece;
|
||||
|
||||
private:
|
||||
class StrongholdPiece;
|
||||
static bool updatePieceWeight();
|
||||
static StrongholdPiece* findAndCreatePieceFactory(
|
||||
EPieceClass pieceClass, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY, int footZ, int direction,
|
||||
int depth);
|
||||
static StrongholdPiece* generatePieceFromSmallDoor(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY, int footZ, int direction,
|
||||
int depth);
|
||||
static StructurePiece* generateAndAddPiece(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY, int footZ, int direction,
|
||||
int depth);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
private:
|
||||
class StrongholdPiece : public StructurePiece
|
||||
{
|
||||
class StrongholdPiece : public StructurePiece {
|
||||
protected:
|
||||
StrongholdPiece(int genDepth);
|
||||
|
||||
protected:
|
||||
StrongholdPiece(int genDepth);
|
||||
|
||||
enum SmallDoorType
|
||||
{
|
||||
OPENING, WOOD_DOOR, GRATES, IRON_DOOR,
|
||||
enum SmallDoorType {
|
||||
OPENING,
|
||||
WOOD_DOOR,
|
||||
GRATES,
|
||||
IRON_DOOR,
|
||||
};
|
||||
|
||||
void generateSmallDoor(Level *level, Random *random, BoundingBox *chunkBB, SmallDoorType doorType, int footX, int footY, int footZ);
|
||||
SmallDoorType randomSmallDoor(Random *random);
|
||||
StructurePiece *generateSmallDoorChildForward(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int xOff, int yOff);
|
||||
StructurePiece *generateSmallDoorChildLeft(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int yOff, int zOff);
|
||||
StructurePiece *generateSmallDoorChildRight(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int yOff, int zOff);
|
||||
|
||||
static bool isOkBox(BoundingBox *box, StartPiece *startRoom); // 4J added startRoom param
|
||||
void generateSmallDoor(Level* level, Random* random,
|
||||
BoundingBox* chunkBB, SmallDoorType doorType,
|
||||
int footX, int footY, int footZ);
|
||||
SmallDoorType randomSmallDoor(Random* random);
|
||||
StructurePiece* generateSmallDoorChildForward(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int xOff, int yOff);
|
||||
StructurePiece* generateSmallDoorChildLeft(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int yOff, int zOff);
|
||||
StructurePiece* generateSmallDoorChildRight(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int yOff, int zOff);
|
||||
|
||||
static bool isOkBox(BoundingBox* box,
|
||||
StartPiece* startRoom); // 4J added startRoom param
|
||||
};
|
||||
|
||||
/**
|
||||
* Corridor pieces that connects unconnected ends.
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class FillerCorridor : public StrongholdPiece
|
||||
{
|
||||
private:
|
||||
const int steps;
|
||||
|
||||
public:
|
||||
FillerCorridor(int genDepth, Random *random, BoundingBox *corridorBox, int direction);
|
||||
|
||||
static BoundingBox *findPieceBox(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class StairsDown : public StrongholdPiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 11;
|
||||
static const int depth = 5;
|
||||
|
||||
const bool isSource;
|
||||
const SmallDoorType entryDoor;
|
||||
class FillerCorridor : public StrongholdPiece {
|
||||
private:
|
||||
const int steps;
|
||||
|
||||
public:
|
||||
StairsDown(int genDepth, Random *random, int west, int north);
|
||||
StairsDown(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
public:
|
||||
FillerCorridor(int genDepth, Random* random, BoundingBox* corridorBox,
|
||||
int direction);
|
||||
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static StairsDown *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
static BoundingBox* findPieceBox(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class StairsDown : public StrongholdPiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 11;
|
||||
static const int depth = 5;
|
||||
|
||||
const bool isSource;
|
||||
const SmallDoorType entryDoor;
|
||||
|
||||
public:
|
||||
StairsDown(int genDepth, Random* random, int west, int north);
|
||||
StairsDown(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static StairsDown* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class PortalRoom;
|
||||
class PortalRoom;
|
||||
|
||||
class StartPiece : public StairsDown
|
||||
{
|
||||
public:
|
||||
bool isLibraryAdded;
|
||||
PieceWeight *previousPiece;
|
||||
PortalRoom *portalRoomPiece;
|
||||
Level *m_level; // 4J added
|
||||
class StartPiece : public StairsDown {
|
||||
public:
|
||||
bool isLibraryAdded;
|
||||
PieceWeight* previousPiece;
|
||||
PortalRoom* portalRoomPiece;
|
||||
Level* m_level; // 4J added
|
||||
|
||||
// this queue is used so that the addChildren calls are
|
||||
// called in a random order
|
||||
std::vector<StructurePiece *> pendingChildren;
|
||||
std::vector<StructurePiece*> pendingChildren;
|
||||
|
||||
StartPiece(int genDepth, Random *random, int west, int north, Level *level); // 4J Added level param
|
||||
virtual TilePos *getLocatorPosition();
|
||||
StartPiece(int genDepth, Random* random, int west, int north,
|
||||
Level* level); // 4J Added level param
|
||||
virtual TilePos* getLocatorPosition();
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class Straight : public StrongholdPiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 5;
|
||||
static const int depth = 7;
|
||||
class Straight : public StrongholdPiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 5;
|
||||
static const int depth = 7;
|
||||
|
||||
const SmallDoorType entryDoor;
|
||||
const bool leftChild;
|
||||
const bool rightChild;
|
||||
|
||||
public:
|
||||
Straight(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static Straight *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
const SmallDoorType entryDoor;
|
||||
const bool leftChild;
|
||||
const bool rightChild;
|
||||
|
||||
public:
|
||||
Straight(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static Straight* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class ChestCorridor : public StrongholdPiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
class ChestCorridor : public StrongholdPiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 5;
|
||||
static const int depth = 7;
|
||||
static const int TREASURE_ITEMS_COUNT = 14;
|
||||
static WeighedTreasure *treasureItems[TREASURE_ITEMS_COUNT];
|
||||
static const int TREASURE_ITEMS_COUNT = 14;
|
||||
static WeighedTreasure* treasureItems[TREASURE_ITEMS_COUNT];
|
||||
|
||||
const SmallDoorType entryDoor;
|
||||
boolean hasPlacedChest;
|
||||
|
||||
public:
|
||||
ChestCorridor(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static ChestCorridor *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
ChestCorridor(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static ChestCorridor* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class StraightStairsDown : public StrongholdPiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 11;
|
||||
static const int depth = 8;
|
||||
class StraightStairsDown : public StrongholdPiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 11;
|
||||
static const int depth = 8;
|
||||
|
||||
const SmallDoorType entryDoor;
|
||||
const SmallDoorType entryDoor;
|
||||
|
||||
public:
|
||||
StraightStairsDown(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static StraightStairsDown *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
StraightStairsDown(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static StraightStairsDown* createPiece(
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class LeftTurn : public StrongholdPiece
|
||||
{
|
||||
class LeftTurn : public StrongholdPiece {
|
||||
protected:
|
||||
static const int width = 5;
|
||||
static const int height = 5;
|
||||
static const int depth = 5;
|
||||
|
||||
protected:
|
||||
static const int width = 5;
|
||||
static const int height = 5;
|
||||
static const int depth = 5;
|
||||
const SmallDoorType entryDoor;
|
||||
|
||||
const SmallDoorType entryDoor;
|
||||
|
||||
public:
|
||||
LeftTurn(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static LeftTurn *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
LeftTurn(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static LeftTurn* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class RightTurn : public LeftTurn
|
||||
{
|
||||
public:
|
||||
RightTurn(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
};
|
||||
class RightTurn : public LeftTurn {
|
||||
public:
|
||||
RightTurn(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class RoomCrossing : public StrongholdPiece
|
||||
{
|
||||
private:
|
||||
static const int SMALL_TREASURE_ITEMS_COUNT = 7; // 4J added
|
||||
static WeighedTreasure *smallTreasureItems[SMALL_TREASURE_ITEMS_COUNT];
|
||||
class RoomCrossing : public StrongholdPiece {
|
||||
private:
|
||||
static const int SMALL_TREASURE_ITEMS_COUNT = 7; // 4J added
|
||||
static WeighedTreasure* smallTreasureItems[SMALL_TREASURE_ITEMS_COUNT];
|
||||
|
||||
protected:
|
||||
static const int width = 11;
|
||||
static const int height = 7;
|
||||
static const int depth = 11;
|
||||
protected:
|
||||
static const int width = 11;
|
||||
static const int height = 7;
|
||||
static const int depth = 11;
|
||||
|
||||
protected:
|
||||
const SmallDoorType entryDoor;
|
||||
protected:
|
||||
const SmallDoorType entryDoor;
|
||||
const int type;
|
||||
public:
|
||||
RoomCrossing(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static RoomCrossing *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
|
||||
public:
|
||||
RoomCrossing(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static RoomCrossing* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class PrisonHall : public StrongholdPiece
|
||||
{
|
||||
protected:
|
||||
static const int width = 9;
|
||||
static const int height = 5;
|
||||
static const int depth = 11;
|
||||
class PrisonHall : public StrongholdPiece {
|
||||
protected:
|
||||
static const int width = 9;
|
||||
static const int height = 5;
|
||||
static const int depth = 11;
|
||||
|
||||
const SmallDoorType entryDoor;
|
||||
|
||||
public:
|
||||
PrisonHall(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static PrisonHall *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
PrisonHall(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static PrisonHall* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class Library : public StrongholdPiece
|
||||
{
|
||||
private:
|
||||
static const int LIBRARY_TREASURE_ITEMS_COUNT = 4; // 4J added
|
||||
static WeighedTreasure *libraryTreasureItems[LIBRARY_TREASURE_ITEMS_COUNT];
|
||||
class Library : public StrongholdPiece {
|
||||
private:
|
||||
static const int LIBRARY_TREASURE_ITEMS_COUNT = 4; // 4J added
|
||||
static WeighedTreasure*
|
||||
libraryTreasureItems[LIBRARY_TREASURE_ITEMS_COUNT];
|
||||
|
||||
protected:
|
||||
static const int width = 14;
|
||||
static const int height = 6;
|
||||
static const int tallHeight = 11;
|
||||
static const int depth = 15;
|
||||
protected:
|
||||
static const int width = 14;
|
||||
static const int height = 6;
|
||||
static const int tallHeight = 11;
|
||||
static const int depth = 15;
|
||||
|
||||
const SmallDoorType entryDoor;
|
||||
private:
|
||||
const bool isTall;
|
||||
|
||||
public:
|
||||
Library(int genDepth, Random *random, BoundingBox *roomBox, int direction);
|
||||
static Library *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
private:
|
||||
const bool isTall;
|
||||
|
||||
public:
|
||||
Library(int genDepth, Random* random, BoundingBox* roomBox,
|
||||
int direction);
|
||||
static Library* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class FiveCrossing : public StrongholdPiece
|
||||
{
|
||||
protected:
|
||||
static const int width = 10;
|
||||
class FiveCrossing : public StrongholdPiece {
|
||||
protected:
|
||||
static const int width = 10;
|
||||
static const int height = 9;
|
||||
static const int depth = 11;
|
||||
|
||||
const SmallDoorType entryDoor;
|
||||
|
||||
private:
|
||||
bool leftLow, leftHigh, rightLow, rightHigh;
|
||||
private:
|
||||
bool leftLow, leftHigh, rightLow, rightHigh;
|
||||
|
||||
public:
|
||||
FiveCrossing(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static FiveCrossing *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
FiveCrossing(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static FiveCrossing* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class PortalRoom : public StrongholdPiece
|
||||
{
|
||||
protected:
|
||||
static const int width = 11;
|
||||
class PortalRoom : public StrongholdPiece {
|
||||
protected:
|
||||
static const int width = 11;
|
||||
static const int height = 8;
|
||||
static const int depth = 16;
|
||||
|
||||
private:
|
||||
bool hasPlacedMobSpawner;
|
||||
private:
|
||||
bool hasPlacedMobSpawner;
|
||||
|
||||
public:
|
||||
PortalRoom(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static PortalRoom *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
PortalRoom(int genDepth, Random* random, BoundingBox* stairsBox,
|
||||
int direction);
|
||||
void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces, Random* random);
|
||||
static PortalRoom* createPiece(std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
bool postProcess(Level* level, Random* random, BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
class SmoothStoneSelector : public StructurePiece::BlockSelector
|
||||
{
|
||||
public:
|
||||
virtual void next(Random *random, int worldX, int worldY, int worldZ, bool isEdge);
|
||||
class SmoothStoneSelector : public StructurePiece::BlockSelector {
|
||||
public:
|
||||
virtual void next(Random* random, int worldX, int worldY, int worldZ,
|
||||
bool isEdge);
|
||||
};
|
||||
|
||||
static const SmoothStoneSelector *smoothStoneSelector;
|
||||
static const SmoothStoneSelector* smoothStoneSelector;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ class ChestTileEntity;
|
||||
class TilePos;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* A structure piece is a construction or room, located somewhere in the world
|
||||
* with a given orientatino (out of Direction.java). Structure pieces have a
|
||||
* bounding box that says where the piece is located and its bounds, and the
|
||||
@@ -37,59 +37,67 @@ class TilePos;
|
||||
* box. Failing to check this will cause the level generator to create new
|
||||
* chunks, leading to infinite loops and other errors.
|
||||
*/
|
||||
class StructurePiece
|
||||
{
|
||||
class StructurePiece {
|
||||
public:
|
||||
class BlockSelector
|
||||
{
|
||||
|
||||
protected:
|
||||
int nextId;
|
||||
class BlockSelector {
|
||||
protected:
|
||||
int nextId;
|
||||
int nextData;
|
||||
|
||||
public:
|
||||
virtual void next(Random *random, int worldX, int worldY, int worldZ, bool isEdge) {}
|
||||
public:
|
||||
virtual void next(Random* random, int worldX, int worldY, int worldZ,
|
||||
bool isEdge) {}
|
||||
|
||||
virtual int getNextId() { return nextId; }
|
||||
virtual int getNextData() { return nextData; }
|
||||
virtual int getNextId() { return nextId; }
|
||||
virtual int getNextData() { return nextData; }
|
||||
};
|
||||
|
||||
public: // 4J is protected in java, but accessed from VillagePieces, not sure how
|
||||
BoundingBox *boundingBox;
|
||||
public
|
||||
: // 4J is protected in java, but accessed from VillagePieces, not sure how
|
||||
BoundingBox* boundingBox;
|
||||
|
||||
protected:
|
||||
int orientation;
|
||||
int genDepth;
|
||||
int orientation;
|
||||
int genDepth;
|
||||
|
||||
StructurePiece(int genDepth);
|
||||
|
||||
public:
|
||||
virtual ~StructurePiece();
|
||||
virtual ~StructurePiece();
|
||||
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB) = 0;
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB) = 0;
|
||||
|
||||
virtual BoundingBox *getBoundingBox();
|
||||
virtual BoundingBox* getBoundingBox();
|
||||
|
||||
int getGenDepth();
|
||||
|
||||
public:
|
||||
bool isInChunk(ChunkPos *pos);
|
||||
static StructurePiece *findCollisionPiece(std::list<StructurePiece *> *pieces, BoundingBox *box);
|
||||
virtual TilePos *getLocatorPosition();
|
||||
bool isInChunk(ChunkPos* pos);
|
||||
static StructurePiece* findCollisionPiece(
|
||||
std::list<StructurePiece*>* pieces, BoundingBox* box);
|
||||
virtual TilePos* getLocatorPosition();
|
||||
|
||||
protected:
|
||||
bool edgesLiquid(Level *level, BoundingBox *chunkBB);
|
||||
bool edgesLiquid(Level* level, BoundingBox* chunkBB);
|
||||
|
||||
public:
|
||||
// 4J Stu - Made these public to use in game rules
|
||||
int getWorldX(int x, int z);
|
||||
int getWorldY(int y);
|
||||
int getWorldZ(int x, int z);
|
||||
int getOrientationData(int tile, int data);
|
||||
virtual void placeBlock(Level *level, int block, int data, int x, int y, int z, BoundingBox *chunkBB);
|
||||
// 4J Stu - Made these public to use in game rules
|
||||
int getWorldX(int x, int z);
|
||||
int getWorldY(int y);
|
||||
int getWorldZ(int x, int z);
|
||||
int getOrientationData(int tile, int data);
|
||||
virtual void placeBlock(Level* level, int block, int data, int x, int y,
|
||||
int z, BoundingBox* chunkBB);
|
||||
|
||||
/**
|
||||
* The purpose of this method is to wrap the getTile call on Level, in order
|
||||
* to prevent the level from generating chunks that shouldn't be loaded yet.
|
||||
* Returns 0 if the call is out of bounds.
|
||||
*
|
||||
*
|
||||
* @param level
|
||||
* @param x
|
||||
* @param y
|
||||
@@ -97,21 +105,49 @@ public:
|
||||
* @param chunkPosition
|
||||
* @return
|
||||
*/
|
||||
virtual int getBlock(Level *level, int x, int y, int z, BoundingBox *chunkBB);
|
||||
virtual void generateAirBox(Level *level, BoundingBox *chunkBB, int x0, int y0, int z0, int x1, int y1, int z1);
|
||||
virtual void generateBox(Level *level, BoundingBox *chunkBB, int x0, int y0, int z0, int x1, int y1, int z1, int edgeTile, int fillTile, bool skipAir);
|
||||
virtual void generateBox(Level *level, BoundingBox *chunkBB, int x0, int y0, int z0, int x1, int y1, int z1, int edgeTile, int edgeData, int fillTile, int fillData, bool skipAir);
|
||||
virtual void generateBox(Level *level, BoundingBox *chunkBB, BoundingBox *boxBB, int edgeTile, int fillTile, bool skipAir);
|
||||
virtual void generateBox(Level *level, BoundingBox *chunkBB, int x0, int y0, int z0, int x1, int y1, int z1, bool skipAir, Random *random, BlockSelector *selector);
|
||||
virtual void generateBox(Level *level, BoundingBox *chunkBB, BoundingBox *boxBB, bool skipAir, Random *random, BlockSelector *selector);
|
||||
virtual void generateMaybeBox(Level *level, BoundingBox *chunkBB, Random *random, float probability, int x0, int y0, int z0, int x1, int y1, int z1, int edgeTile, int fillTile, bool skipAir);
|
||||
virtual void maybeGenerateBlock(Level *level, BoundingBox *chunkBB, Random *random, float probability, int x, int y, int z, int tile, int data);
|
||||
virtual void generateUpperHalfSphere(Level *level, BoundingBox *chunkBB, int x0, int y0, int z0, int x1, int y1, int z1, int fillTile, bool skipAir);
|
||||
virtual void generateAirColumnUp(Level *level, int x, int startY, int z, BoundingBox *chunkBB);
|
||||
virtual void fillColumnDown(Level *level, int tile, int tileData, int x, int startY, int z, BoundingBox *chunkBB);
|
||||
virtual bool createChest(Level *level, BoundingBox *chunkBB, Random *random, int x, int y, int z, WeighedTreasureArray treasure, int numRolls);
|
||||
virtual bool createDispenser(Level *level, BoundingBox *chunkBB, Random *random, int x, int y, int z, int facing, WeighedTreasureArray items, int numRolls);
|
||||
virtual int getBlock(Level* level, int x, int y, int z,
|
||||
BoundingBox* chunkBB);
|
||||
virtual void generateAirBox(Level* level, BoundingBox* chunkBB, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1);
|
||||
virtual void generateBox(Level* level, BoundingBox* chunkBB, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1, int edgeTile,
|
||||
int fillTile, bool skipAir);
|
||||
virtual void generateBox(Level* level, BoundingBox* chunkBB, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1, int edgeTile,
|
||||
int edgeData, int fillTile, int fillData,
|
||||
bool skipAir);
|
||||
virtual void generateBox(Level* level, BoundingBox* chunkBB,
|
||||
BoundingBox* boxBB, int edgeTile, int fillTile,
|
||||
bool skipAir);
|
||||
virtual void generateBox(Level* level, BoundingBox* chunkBB, int x0, int y0,
|
||||
int z0, int x1, int y1, int z1, bool skipAir,
|
||||
Random* random, BlockSelector* selector);
|
||||
virtual void generateBox(Level* level, BoundingBox* chunkBB,
|
||||
BoundingBox* boxBB, bool skipAir, Random* random,
|
||||
BlockSelector* selector);
|
||||
virtual void generateMaybeBox(Level* level, BoundingBox* chunkBB,
|
||||
Random* random, float probability, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int edgeTile, int fillTile, bool skipAir);
|
||||
virtual void maybeGenerateBlock(Level* level, BoundingBox* chunkBB,
|
||||
Random* random, float probability, int x,
|
||||
int y, int z, int tile, int data);
|
||||
virtual void generateUpperHalfSphere(Level* level, BoundingBox* chunkBB,
|
||||
int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, int fillTile, bool skipAir);
|
||||
virtual void generateAirColumnUp(Level* level, int x, int startY, int z,
|
||||
BoundingBox* chunkBB);
|
||||
virtual void fillColumnDown(Level* level, int tile, int tileData, int x,
|
||||
int startY, int z, BoundingBox* chunkBB);
|
||||
virtual bool createChest(Level* level, BoundingBox* chunkBB, Random* random,
|
||||
int x, int y, int z, WeighedTreasureArray treasure,
|
||||
int numRolls);
|
||||
virtual bool createDispenser(Level* level, BoundingBox* chunkBB,
|
||||
Random* random, int x, int y, int z,
|
||||
int facing, WeighedTreasureArray items,
|
||||
int numRolls);
|
||||
|
||||
protected:
|
||||
void createDoor(Level *level, BoundingBox *chunkBB, Random *random, int x, int y, int z, int orientation);
|
||||
void createDoor(Level* level, BoundingBox* chunkBB, Random* random, int x,
|
||||
int y, int z, int orientation);
|
||||
};
|
||||
|
||||
@@ -4,108 +4,85 @@
|
||||
#include "StructurePiece.h"
|
||||
#include "../../Util/BoundingBox.h"
|
||||
|
||||
|
||||
StructureStart::StructureStart()
|
||||
{
|
||||
boundingBox = NULL; // 4J added initialiser
|
||||
StructureStart::StructureStart() {
|
||||
boundingBox = NULL; // 4J added initialiser
|
||||
}
|
||||
|
||||
StructureStart::~StructureStart()
|
||||
{
|
||||
for(AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ )
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
delete boundingBox;
|
||||
StructureStart::~StructureStart() {
|
||||
for (AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++) {
|
||||
delete (*it);
|
||||
}
|
||||
delete boundingBox;
|
||||
}
|
||||
|
||||
BoundingBox *StructureStart::getBoundingBox()
|
||||
{
|
||||
return boundingBox;
|
||||
}
|
||||
BoundingBox* StructureStart::getBoundingBox() { return boundingBox; }
|
||||
|
||||
std::list<StructurePiece *> *StructureStart::getPieces()
|
||||
{
|
||||
return &pieces;
|
||||
}
|
||||
std::list<StructurePiece*>* StructureStart::getPieces() { return &pieces; }
|
||||
|
||||
void StructureStart::postProcess(Level *level, Random *random, BoundingBox *chunkBB)
|
||||
{
|
||||
AUTO_VAR(it, pieces.begin());
|
||||
void StructureStart::postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB) {
|
||||
AUTO_VAR(it, pieces.begin());
|
||||
|
||||
while( it != pieces.end() )
|
||||
{
|
||||
if( (*it)->getBoundingBox()->intersects(chunkBB) && !(*it)->postProcess(level, random, chunkBB))
|
||||
{
|
||||
while (it != pieces.end()) {
|
||||
if ((*it)->getBoundingBox()->intersects(chunkBB) &&
|
||||
!(*it)->postProcess(level, random, chunkBB)) {
|
||||
// this piece can't be placed, so remove it to avoid future
|
||||
// attempts
|
||||
it = pieces.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
it++;
|
||||
}
|
||||
}
|
||||
it = pieces.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StructureStart::calculateBoundingBox()
|
||||
{
|
||||
void StructureStart::calculateBoundingBox() {
|
||||
boundingBox = BoundingBox::getUnknownBox();
|
||||
|
||||
for( AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ )
|
||||
{
|
||||
StructurePiece *piece = *it;
|
||||
boundingBox->expand(piece->getBoundingBox());
|
||||
}
|
||||
for (AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++) {
|
||||
StructurePiece* piece = *it;
|
||||
boundingBox->expand(piece->getBoundingBox());
|
||||
}
|
||||
}
|
||||
|
||||
void StructureStart::moveBelowSeaLevel(Level *level, Random *random, int offset)
|
||||
{
|
||||
const int MAX_Y = level->seaLevel - offset;
|
||||
void StructureStart::moveBelowSeaLevel(Level* level, Random* random,
|
||||
int offset) {
|
||||
const int MAX_Y = level->seaLevel - offset;
|
||||
|
||||
// set lowest possible position (at bedrock)
|
||||
int y1Pos = boundingBox->getYSpan() + 1;
|
||||
// move up randomly within the available span
|
||||
if (y1Pos < MAX_Y)
|
||||
{
|
||||
if (y1Pos < MAX_Y) {
|
||||
y1Pos += random->nextInt(MAX_Y - y1Pos);
|
||||
}
|
||||
|
||||
// move all bounding boxes
|
||||
int dy = y1Pos - boundingBox->y1;
|
||||
boundingBox->move(0, dy, 0);
|
||||
for( AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ )
|
||||
{
|
||||
StructurePiece *piece = *it;
|
||||
for (AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++) {
|
||||
StructurePiece* piece = *it;
|
||||
piece->getBoundingBox()->move(0, dy, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void StructureStart::moveInsideHeights(Level *level, Random *random, int lowestAllowed, int highestAllowed)
|
||||
{
|
||||
int heightSpan = highestAllowed - lowestAllowed + 1 - boundingBox->getYSpan();
|
||||
void StructureStart::moveInsideHeights(Level* level, Random* random,
|
||||
int lowestAllowed, int highestAllowed) {
|
||||
int heightSpan =
|
||||
highestAllowed - lowestAllowed + 1 - boundingBox->getYSpan();
|
||||
int y0Pos = 1;
|
||||
|
||||
if (heightSpan > 1)
|
||||
{
|
||||
if (heightSpan > 1) {
|
||||
y0Pos = lowestAllowed + random->nextInt(heightSpan);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
y0Pos = lowestAllowed;
|
||||
}
|
||||
|
||||
// move all bounding boxes
|
||||
int dy = y0Pos - boundingBox->y0;
|
||||
boundingBox->move(0, dy, 0);
|
||||
for( AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ )
|
||||
{
|
||||
StructurePiece *piece = *it;
|
||||
for (AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++) {
|
||||
StructurePiece* piece = *it;
|
||||
piece->getBoundingBox()->move(0, dy, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool StructureStart::isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool StructureStart::isValid() { return true; }
|
||||
@@ -2,24 +2,25 @@
|
||||
class StructurePiece;
|
||||
class BoundingBox;
|
||||
|
||||
class StructureStart
|
||||
{
|
||||
|
||||
class StructureStart {
|
||||
protected:
|
||||
std::list<StructurePiece *> pieces;
|
||||
BoundingBox *boundingBox;
|
||||
std::list<StructurePiece*> pieces;
|
||||
BoundingBox* boundingBox;
|
||||
|
||||
StructureStart();
|
||||
public:
|
||||
~StructureStart();
|
||||
BoundingBox *getBoundingBox();
|
||||
std::list<StructurePiece *> *getPieces();
|
||||
void postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
protected:
|
||||
void calculateBoundingBox();
|
||||
void moveBelowSeaLevel(Level *level, Random *random, int offset);
|
||||
void moveInsideHeights(Level *level, Random *random, int lowestAllowed, int highestAllowed);
|
||||
public:
|
||||
bool isValid();
|
||||
|
||||
public:
|
||||
~StructureStart();
|
||||
BoundingBox* getBoundingBox();
|
||||
std::list<StructurePiece*>* getPieces();
|
||||
void postProcess(Level* level, Random* random, BoundingBox* chunkBB);
|
||||
|
||||
protected:
|
||||
void calculateBoundingBox();
|
||||
void moveBelowSeaLevel(Level* level, Random* random, int offset);
|
||||
void moveInsideHeights(Level* level, Random* random, int lowestAllowed,
|
||||
int highestAllowed);
|
||||
|
||||
public:
|
||||
bool isValid();
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "../../Headers/net.minecraft.world.level.levelgen.feature.h"
|
||||
#include "../../Headers/net.minecraft.world.entity.boss.enderdragon.h"
|
||||
|
||||
|
||||
// Spike centre positions, calculated using
|
||||
// for(int i=0;i<8;i++)
|
||||
// {
|
||||
@@ -13,59 +12,58 @@
|
||||
// int z=40* Mth::sin(2*(-PI+(PI/8)*i));
|
||||
// }
|
||||
|
||||
TheEndBiomeDecorator::SPIKE TheEndBiomeDecorator::SpikeValA[8] = {
|
||||
// The chunk that the spike is in has to be the smallest x and z that any
|
||||
// part of it is in a chunk(x,z) will only be post-processed when the chunks
|
||||
// (x+1,z), (x,z+1) and (x+1,z+1) are also loaded
|
||||
|
||||
TheEndBiomeDecorator::SPIKE TheEndBiomeDecorator::SpikeValA[8]=
|
||||
{
|
||||
// The chunk that the spike is in has to be the smallest x and z that any part of it is in
|
||||
// a chunk(x,z) will only be post-processed when the chunks (x+1,z), (x,z+1) and (x+1,z+1) are also loaded
|
||||
|
||||
// first two values are the smallest x and z of the chunk that the feature is in - so the centre point minus the radius
|
||||
{ 32, -16, 40, 0, 2 },// smallest block - 38,-2
|
||||
{ 16, 16, 28, 28, 2 },// smallest block - 26,26
|
||||
{ -16, 32, 0, 40, 2 },// smallest block - -2,38
|
||||
{ -32, 16, -28, 28, 3 },// smallest block - -31,26
|
||||
{ -48, -16, -40, 0, 3 },// smallest block - -43,-3
|
||||
{ -32, -32, -28, -28, 3 },// smallest block - -31,-31
|
||||
{ -16, -48, 0, -40, 4 },// smallest block - -4,-44
|
||||
{ 16, -32, 28, -28, 4 },// smallest block - 24,-32
|
||||
// first two values are the smallest x and z of the chunk that the feature
|
||||
// is in - so the centre point minus the radius
|
||||
{32, -16, 40, 0, 2}, // smallest block - 38,-2
|
||||
{16, 16, 28, 28, 2}, // smallest block - 26,26
|
||||
{-16, 32, 0, 40, 2}, // smallest block - -2,38
|
||||
{-32, 16, -28, 28, 3}, // smallest block - -31,26
|
||||
{-48, -16, -40, 0, 3}, // smallest block - -43,-3
|
||||
{-32, -32, -28, -28, 3}, // smallest block - -31,-31
|
||||
{-16, -48, 0, -40, 4}, // smallest block - -4,-44
|
||||
{16, -32, 28, -28, 4}, // smallest block - 24,-32
|
||||
};
|
||||
|
||||
|
||||
TheEndBiomeDecorator::TheEndBiomeDecorator(Biome *biome) : BiomeDecorator(biome)
|
||||
{
|
||||
spikeFeature = new SpikeFeature(Tile::whiteStone_Id);
|
||||
endPodiumFeature = new EndPodiumFeature(Tile::whiteStone_Id);
|
||||
TheEndBiomeDecorator::TheEndBiomeDecorator(Biome* biome)
|
||||
: BiomeDecorator(biome) {
|
||||
spikeFeature = new SpikeFeature(Tile::whiteStone_Id);
|
||||
endPodiumFeature = new EndPodiumFeature(Tile::whiteStone_Id);
|
||||
}
|
||||
|
||||
void TheEndBiomeDecorator::decorate()
|
||||
{
|
||||
decorateOres();
|
||||
void TheEndBiomeDecorator::decorate() {
|
||||
decorateOres();
|
||||
|
||||
// this will only set the y to the top y of the chunks already processed...
|
||||
int y = level->getTopSolidBlock(xo+8, zo+8);
|
||||
if(y>level->GetHighestY()) level->SetHighestY(y);
|
||||
// this will only set the y to the top y of the chunks already processed...
|
||||
int y = level->getTopSolidBlock(xo + 8, zo + 8);
|
||||
if (y > level->GetHighestY()) level->SetHighestY(y);
|
||||
|
||||
// 4J-PB - editing to place 8 spikes in a circle, with increasing height
|
||||
// 4J-PB - editing to place 8 spikes in a circle, with increasing height
|
||||
|
||||
// are we within the chunk with a spike?
|
||||
for(int i=0;i<8;i++)
|
||||
{
|
||||
if((xo == SpikeValA[i].iChunkX) && (zo == SpikeValA[i].iChunkZ))
|
||||
{
|
||||
// in the right chunk
|
||||
spikeFeature->placeWithIndex(level, random, SpikeValA[i].x, level->GetHighestY(), SpikeValA[i].z,i,SpikeValA[i].radius);
|
||||
}
|
||||
}
|
||||
if (xo == 0 && zo == 0)
|
||||
{
|
||||
std::shared_ptr<EnderDragon> enderDragon = std::shared_ptr<EnderDragon>(new EnderDragon(level));
|
||||
// are we within the chunk with a spike?
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if ((xo == SpikeValA[i].iChunkX) && (zo == SpikeValA[i].iChunkZ)) {
|
||||
// in the right chunk
|
||||
spikeFeature->placeWithIndex(level, random, SpikeValA[i].x,
|
||||
level->GetHighestY(), SpikeValA[i].z,
|
||||
i, SpikeValA[i].radius);
|
||||
}
|
||||
}
|
||||
if (xo == 0 && zo == 0) {
|
||||
std::shared_ptr<EnderDragon> enderDragon =
|
||||
std::shared_ptr<EnderDragon>(new EnderDragon(level));
|
||||
enderDragon->moveTo(0, 128, 0, random->nextFloat() * 360, 0);
|
||||
level->addEntity(enderDragon);
|
||||
}
|
||||
}
|
||||
|
||||
// end podium radius is 4, position is 0,0, so chunk needs to be the -16,-16 one since this guarantees that all chunks required for the podium are loaded
|
||||
if (xo == -16 && zo == -16)
|
||||
{
|
||||
endPodiumFeature->place(level, random, 0, Level::genDepth / 2, 0);
|
||||
// end podium radius is 4, position is 0,0, so chunk needs to be the -16,-16
|
||||
// one since this guarantees that all chunks required for the podium are
|
||||
// loaded
|
||||
if (xo == -16 && zo == -16) {
|
||||
endPodiumFeature->place(level, random, 0, Level::genDepth / 2, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,22 @@
|
||||
#pragma once
|
||||
#include "../Biomes/BiomeDecorator.h"
|
||||
|
||||
class TheEndBiomeDecorator : public BiomeDecorator
|
||||
{
|
||||
class TheEndBiomeDecorator : public BiomeDecorator {
|
||||
public:
|
||||
typedef struct
|
||||
{
|
||||
int iChunkX;
|
||||
int iChunkZ;
|
||||
int x;
|
||||
int z;
|
||||
int radius;
|
||||
}
|
||||
SPIKE;
|
||||
|
||||
TheEndBiomeDecorator(Biome *biome);
|
||||
typedef struct {
|
||||
int iChunkX;
|
||||
int iChunkZ;
|
||||
int x;
|
||||
int z;
|
||||
int radius;
|
||||
} SPIKE;
|
||||
|
||||
TheEndBiomeDecorator(Biome* biome);
|
||||
|
||||
protected:
|
||||
Feature *spikeFeature;
|
||||
Feature *endPodiumFeature;
|
||||
virtual void decorate();
|
||||
Feature* spikeFeature;
|
||||
Feature* endPodiumFeature;
|
||||
virtual void decorate();
|
||||
|
||||
|
||||
static SPIKE SpikeValA[8];
|
||||
static SPIKE SpikeValA[8];
|
||||
};
|
||||
@@ -8,505 +8,449 @@
|
||||
#include "../../Util/BasicTypeContainers.h"
|
||||
#include "Village.h"
|
||||
|
||||
Village::Aggressor::Aggressor(std::shared_ptr<Mob> mob, int timeStamp)
|
||||
{
|
||||
this->mob = mob;
|
||||
this->timeStamp = timeStamp;
|
||||
Village::Aggressor::Aggressor(std::shared_ptr<Mob> mob, int timeStamp) {
|
||||
this->mob = mob;
|
||||
this->timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
Village::Village()
|
||||
{
|
||||
accCenter = new Pos(0, 0, 0);
|
||||
center = new Pos(0, 0, 0);
|
||||
radius = 0;
|
||||
stableSince = 0;
|
||||
_tick = 0;
|
||||
populationSize = 0;
|
||||
golemCount = 0;
|
||||
noBreedTimer = 0;
|
||||
Village::Village() {
|
||||
accCenter = new Pos(0, 0, 0);
|
||||
center = new Pos(0, 0, 0);
|
||||
radius = 0;
|
||||
stableSince = 0;
|
||||
_tick = 0;
|
||||
populationSize = 0;
|
||||
golemCount = 0;
|
||||
noBreedTimer = 0;
|
||||
|
||||
level = NULL;
|
||||
level = NULL;
|
||||
}
|
||||
|
||||
Village::Village(Level *level)
|
||||
{
|
||||
accCenter = new Pos(0, 0, 0);
|
||||
center = new Pos(0, 0, 0);
|
||||
radius = 0;
|
||||
stableSince = 0;
|
||||
_tick = 0;
|
||||
populationSize = 0;
|
||||
golemCount = 0;
|
||||
noBreedTimer = 0;
|
||||
Village::Village(Level* level) {
|
||||
accCenter = new Pos(0, 0, 0);
|
||||
center = new Pos(0, 0, 0);
|
||||
radius = 0;
|
||||
stableSince = 0;
|
||||
_tick = 0;
|
||||
populationSize = 0;
|
||||
golemCount = 0;
|
||||
noBreedTimer = 0;
|
||||
|
||||
this->level = level;
|
||||
this->level = level;
|
||||
}
|
||||
|
||||
Village::~Village()
|
||||
{
|
||||
delete accCenter;
|
||||
delete center;
|
||||
for(AUTO_VAR(it, aggressors.begin()); it != aggressors.end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
Village::~Village() {
|
||||
delete accCenter;
|
||||
delete center;
|
||||
for (AUTO_VAR(it, aggressors.begin()); it != aggressors.end(); ++it) {
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
||||
void Village::setLevel(Level *level)
|
||||
{
|
||||
this->level = level;
|
||||
void Village::setLevel(Level* level) { this->level = level; }
|
||||
|
||||
void Village::tick(int tick) {
|
||||
this->_tick = tick;
|
||||
updateDoors();
|
||||
updateAggressors();
|
||||
if (tick % 20 == 0) countPopulation();
|
||||
if (tick % 30 == 0) countGolem();
|
||||
|
||||
int idealGolemCount = populationSize / 10;
|
||||
if (golemCount < idealGolemCount && doorInfos.size() > 20 &&
|
||||
level->random->nextInt(7000) == 0) {
|
||||
Vec3* spawnPos =
|
||||
findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2);
|
||||
if (spawnPos != NULL) {
|
||||
std::shared_ptr<VillagerGolem> vg =
|
||||
std::shared_ptr<VillagerGolem>(new VillagerGolem(level));
|
||||
vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z);
|
||||
level->addEntity(vg);
|
||||
++golemCount;
|
||||
}
|
||||
}
|
||||
|
||||
// 4J - All commented out in java
|
||||
// for (DoorInfo di : doorInfos) {
|
||||
// level.addParticle("heart", di.getIndoorX() + 0.5,
|
||||
// di.getIndoorY() + .5f, di.getIndoorZ() + 0.5, 0, 1, 0);
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < 8; ++i)
|
||||
// for (int j = 0; j < 8; ++j)
|
||||
// level.addParticle("heart", center.x + 0.5 + i, center.y +
|
||||
// .5f, center.z + 0.5 + j, 0, 1, 0);
|
||||
// for (float i = 0; i < Math.PI * 2; i += 0.1) {
|
||||
// int x = center.x + (int) (Math.cos(i) * radius);
|
||||
// int z = center.z + (int) (Math.sin(i) * radius);
|
||||
// level.addParticle("heart", x, center.y + .5f, z, 0, 1, 0);
|
||||
// }
|
||||
}
|
||||
|
||||
void Village::tick(int tick)
|
||||
{
|
||||
this->_tick = tick;
|
||||
updateDoors();
|
||||
updateAggressors();
|
||||
if (tick % 20 == 0) countPopulation();
|
||||
if (tick % 30 == 0) countGolem();
|
||||
|
||||
int idealGolemCount = populationSize / 10;
|
||||
if (golemCount < idealGolemCount && doorInfos.size() > 20 && level->random->nextInt(7000) == 0)
|
||||
{
|
||||
Vec3 *spawnPos = findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2);
|
||||
if (spawnPos != NULL)
|
||||
{
|
||||
std::shared_ptr<VillagerGolem> vg = std::shared_ptr<VillagerGolem>( new VillagerGolem(level) );
|
||||
vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z);
|
||||
level->addEntity(vg);
|
||||
++golemCount;
|
||||
}
|
||||
}
|
||||
|
||||
// 4J - All commented out in java
|
||||
// for (DoorInfo di : doorInfos) {
|
||||
// level.addParticle("heart", di.getIndoorX() + 0.5, di.getIndoorY() + .5f, di.getIndoorZ() + 0.5, 0, 1, 0);
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < 8; ++i)
|
||||
// for (int j = 0; j < 8; ++j)
|
||||
// level.addParticle("heart", center.x + 0.5 + i, center.y + .5f, center.z + 0.5 + j, 0, 1, 0);
|
||||
// for (float i = 0; i < Math.PI * 2; i += 0.1) {
|
||||
// int x = center.x + (int) (Math.cos(i) * radius);
|
||||
// int z = center.z + (int) (Math.sin(i) * radius);
|
||||
// level.addParticle("heart", x, center.y + .5f, z, 0, 1, 0);
|
||||
// }
|
||||
Vec3* Village::findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz) {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
int xx = x + level->random->nextInt(16) - 8;
|
||||
int yy = y + level->random->nextInt(6) - 3;
|
||||
int zz = z + level->random->nextInt(16) - 8;
|
||||
if (!isInside(xx, yy, zz)) continue;
|
||||
if (canSpawnAt(xx, yy, zz, sx, sy, sz))
|
||||
return Vec3::newTemp(xx, yy, zz);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Vec3 *Village::findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz)
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
int xx = x + level->random->nextInt(16) - 8;
|
||||
int yy = y + level->random->nextInt(6) - 3;
|
||||
int zz = z + level->random->nextInt(16) - 8;
|
||||
if (!isInside(xx, yy, zz)) continue;
|
||||
if (canSpawnAt(xx, yy, zz, sx, sy, sz)) return Vec3::newTemp(xx, yy, zz);
|
||||
}
|
||||
return NULL;
|
||||
bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz) {
|
||||
if (!level->isTopSolidBlocking(x, y - 1, z)) return false;
|
||||
|
||||
int startX = x - sx / 2;
|
||||
int startZ = z - sz / 2;
|
||||
for (int xx = startX; xx < startX + sx; xx++)
|
||||
for (int yy = y; yy < y + sy; yy++)
|
||||
for (int zz = startZ; zz < startZ + sz; zz++)
|
||||
if (level->isSolidBlockingTile(xx, yy, zz)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz)
|
||||
{
|
||||
if (!level->isTopSolidBlocking(x, y - 1, z)) return false;
|
||||
|
||||
int startX = x - sx / 2;
|
||||
int startZ = z - sz / 2;
|
||||
for (int xx = startX; xx < startX + sx; xx++)
|
||||
for (int yy = y; yy < y + sy; yy++)
|
||||
for (int zz = startZ; zz < startZ + sz; zz++)
|
||||
if (level->isSolidBlockingTile(xx, yy, zz)) return false;
|
||||
|
||||
return true;
|
||||
void Village::countGolem() {
|
||||
// Fix - let bots report themselves?
|
||||
std::vector<std::shared_ptr<Entity> >* golems = level->getEntitiesOfClass(
|
||||
typeid(VillagerGolem),
|
||||
AABB::newTemp(center->x - radius, center->y - 4, center->z - radius,
|
||||
center->x + radius, center->y + 4, center->z + radius));
|
||||
golemCount = golems->size();
|
||||
delete golems;
|
||||
}
|
||||
|
||||
void Village::countGolem()
|
||||
{
|
||||
// Fix - let bots report themselves?
|
||||
std::vector<std::shared_ptr<Entity> > *golems = level->getEntitiesOfClass(typeid(VillagerGolem), AABB::newTemp(center->x - radius, center->y - 4, center->z - radius, center->x + radius, center->y + 4, center->z + radius));
|
||||
golemCount = golems->size();
|
||||
delete golems;
|
||||
void Village::countPopulation() {
|
||||
std::vector<std::shared_ptr<Entity> >* villagers =
|
||||
level->getEntitiesOfClass(
|
||||
typeid(Villager),
|
||||
AABB::newTemp(center->x - radius, center->y - 4, center->z - radius,
|
||||
center->x + radius, center->y + 4,
|
||||
center->z + radius));
|
||||
populationSize = villagers->size();
|
||||
delete villagers;
|
||||
|
||||
if (populationSize == 0) {
|
||||
// forget standing
|
||||
playerStanding.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Village::countPopulation()
|
||||
{
|
||||
std::vector<std::shared_ptr<Entity> > *villagers = level->getEntitiesOfClass(typeid(Villager), AABB::newTemp(center->x - radius, center->y - 4, center->z - radius, center->x + radius, center->y + 4, center->z + radius));
|
||||
populationSize = villagers->size();
|
||||
delete villagers;
|
||||
Pos* Village::getCenter() { return center; }
|
||||
|
||||
if (populationSize == 0)
|
||||
{
|
||||
// forget standing
|
||||
playerStanding.clear();
|
||||
}
|
||||
int Village::getRadius() { return radius; }
|
||||
|
||||
int Village::getDoorCount() { return doorInfos.size(); }
|
||||
|
||||
int Village::getStableAge() { return _tick - stableSince; }
|
||||
|
||||
int Village::getPopulationSize() { return populationSize; }
|
||||
|
||||
bool Village::isInside(int xx, int yy, int zz) {
|
||||
return center->distSqr(xx, yy, zz) < radius * radius;
|
||||
}
|
||||
|
||||
Pos *Village::getCenter()
|
||||
{
|
||||
return center;
|
||||
std::vector<std::shared_ptr<DoorInfo> >* Village::getDoorInfos() {
|
||||
return &doorInfos;
|
||||
}
|
||||
|
||||
int Village::getRadius()
|
||||
{
|
||||
return radius;
|
||||
std::shared_ptr<DoorInfo> Village::getClosestDoorInfo(int x, int y, int z) {
|
||||
std::shared_ptr<DoorInfo> closest = nullptr;
|
||||
int closestDistSqr = Integer::MAX_VALUE;
|
||||
// for (DoorInfo dm : doorInfos)
|
||||
for (AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it) {
|
||||
std::shared_ptr<DoorInfo> dm = *it;
|
||||
int distSqr = dm->distanceToSqr(x, y, z);
|
||||
if (distSqr < closestDistSqr) {
|
||||
closest = dm;
|
||||
closestDistSqr = distSqr;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
int Village::getDoorCount()
|
||||
{
|
||||
return doorInfos.size();
|
||||
std::shared_ptr<DoorInfo> Village::getBestDoorInfo(int x, int y, int z) {
|
||||
std::shared_ptr<DoorInfo> closest = nullptr;
|
||||
int closestDist = Integer::MAX_VALUE;
|
||||
// for (DoorInfo dm : doorInfos)
|
||||
for (AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it) {
|
||||
std::shared_ptr<DoorInfo> dm = *it;
|
||||
|
||||
int distSqr = dm->distanceToSqr(x, y, z);
|
||||
if (distSqr > 16 * 16)
|
||||
distSqr *= 1000;
|
||||
else
|
||||
distSqr = dm->getBookingsCount();
|
||||
|
||||
if (distSqr < closestDist) {
|
||||
closest = dm;
|
||||
closestDist = distSqr;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
int Village::getStableAge()
|
||||
{
|
||||
return _tick - stableSince;
|
||||
bool Village::hasDoorInfo(int x, int y, int z) {
|
||||
return getDoorInfo(x, y, z) != NULL;
|
||||
}
|
||||
|
||||
int Village::getPopulationSize()
|
||||
{
|
||||
return populationSize;
|
||||
std::shared_ptr<DoorInfo> Village::getDoorInfo(int x, int y, int z) {
|
||||
if (center->distSqr(x, y, z) > radius * radius) return nullptr;
|
||||
// for (DoorInfo di : doorInfos)
|
||||
for (AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it) {
|
||||
std::shared_ptr<DoorInfo> di = *it;
|
||||
if (di->x == x && di->z == z && abs(di->y - y) <= 1) return di;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Village::isInside(int xx, int yy, int zz)
|
||||
{
|
||||
return center->distSqr(xx, yy, zz) < radius * radius;
|
||||
void Village::addDoorInfo(std::shared_ptr<DoorInfo> di) {
|
||||
doorInfos.push_back(di);
|
||||
accCenter->x += di->x;
|
||||
accCenter->y += di->y;
|
||||
accCenter->z += di->z;
|
||||
calcInfo();
|
||||
stableSince = di->timeStamp;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<DoorInfo> > *Village::getDoorInfos()
|
||||
{
|
||||
return &doorInfos;
|
||||
bool Village::canRemove() { return doorInfos.empty(); }
|
||||
|
||||
void Village::addAggressor(std::shared_ptr<Mob> mob) {
|
||||
// for (Aggressor a : aggressors)
|
||||
for (AUTO_VAR(it, aggressors.begin()); it != aggressors.end(); ++it) {
|
||||
Aggressor* a = *it;
|
||||
if (a->mob == mob) {
|
||||
a->timeStamp = _tick;
|
||||
return;
|
||||
}
|
||||
}
|
||||
aggressors.push_back(new Aggressor(mob, _tick));
|
||||
}
|
||||
|
||||
std::shared_ptr<DoorInfo> Village::getClosestDoorInfo(int x, int y, int z)
|
||||
{
|
||||
std::shared_ptr<DoorInfo> closest = nullptr;
|
||||
int closestDistSqr = Integer::MAX_VALUE;
|
||||
//for (DoorInfo dm : doorInfos)
|
||||
for(AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<DoorInfo> dm = *it;
|
||||
int distSqr = dm->distanceToSqr(x, y, z);
|
||||
if (distSqr < closestDistSqr)
|
||||
{
|
||||
closest = dm;
|
||||
closestDistSqr = distSqr;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
std::shared_ptr<Mob> Village::getClosestAggressor(std::shared_ptr<Mob> from) {
|
||||
double closestSqr = Double::MAX_VALUE;
|
||||
Aggressor* closest = NULL;
|
||||
// for (int i = 0; i < aggressors.size(); ++i)
|
||||
for (AUTO_VAR(it, aggressors.begin()); it != aggressors.end(); ++it) {
|
||||
Aggressor* a = *it; // aggressors.get(i);
|
||||
double distSqr = a->mob->distanceToSqr(from);
|
||||
if (distSqr > closestSqr) continue;
|
||||
closest = a;
|
||||
closestSqr = distSqr;
|
||||
}
|
||||
return closest != NULL ? closest->mob : nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<DoorInfo>Village::getBestDoorInfo(int x, int y, int z)
|
||||
std::shared_ptr<Player> Village::getClosestBadStandingPlayer(
|
||||
std::shared_ptr<Mob>
|
||||
from) // 4J Stu - Should be LivingEntity when we add that
|
||||
{
|
||||
std::shared_ptr<DoorInfo> closest = nullptr;
|
||||
int closestDist = Integer::MAX_VALUE;
|
||||
//for (DoorInfo dm : doorInfos)
|
||||
for(AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<DoorInfo>dm = *it;
|
||||
double closestSqr = Double::MAX_VALUE;
|
||||
std::shared_ptr<Player> closest = nullptr;
|
||||
|
||||
int distSqr = dm->distanceToSqr(x, y, z);
|
||||
if (distSqr > 16 * 16) distSqr *= 1000;
|
||||
else distSqr = dm->getBookingsCount();
|
||||
// for (String player : playerStanding.keySet())
|
||||
for (AUTO_VAR(it, playerStanding.begin()); it != playerStanding.end();
|
||||
++it) {
|
||||
std::wstring player = it->first;
|
||||
if (isVeryBadStanding(player)) {
|
||||
std::shared_ptr<Player> mob = level->getPlayerByName(player);
|
||||
if (mob != NULL) {
|
||||
double distSqr = mob->distanceToSqr(from);
|
||||
if (distSqr > closestSqr) continue;
|
||||
closest = mob;
|
||||
closestSqr = distSqr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (distSqr < closestDist)
|
||||
{
|
||||
closest = dm;
|
||||
closestDist = distSqr;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
return closest;
|
||||
}
|
||||
|
||||
bool Village::hasDoorInfo(int x, int y, int z)
|
||||
{
|
||||
return getDoorInfo(x, y, z) != NULL;
|
||||
void Village::updateAggressors() {
|
||||
// for (Iterator<Aggressor> it = aggressors.iterator(); it.hasNext();)
|
||||
for (AUTO_VAR(it, aggressors.begin()); it != aggressors.end();) {
|
||||
Aggressor* a = *it; // it.next();
|
||||
if (!a->mob->isAlive() || abs(_tick - a->timeStamp) > 300) {
|
||||
delete *it;
|
||||
it = aggressors.erase(it);
|
||||
// it.remove();
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<DoorInfo>Village::getDoorInfo(int x, int y, int z)
|
||||
{
|
||||
if (center->distSqr(x, y, z) > radius * radius) return nullptr;
|
||||
//for (DoorInfo di : doorInfos)
|
||||
for(AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<DoorInfo> di = *it;
|
||||
if (di->x == x && di->z == z && abs(di->y - y) <= 1) return di;
|
||||
}
|
||||
return nullptr;
|
||||
void Village::updateDoors() {
|
||||
bool removed = false;
|
||||
bool resetBookings = level->random->nextInt(50) == 0;
|
||||
// for (Iterator<DoorInfo> it = doorInfos.iterator(); it.hasNext();)
|
||||
for (AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end();) {
|
||||
std::shared_ptr<DoorInfo> dm = *it; // it.next();
|
||||
if (resetBookings) dm->resetBookingCount();
|
||||
if (!isDoor(dm->x, dm->y, dm->z) || abs(_tick - dm->timeStamp) > 1200) {
|
||||
accCenter->x -= dm->x;
|
||||
accCenter->y -= dm->y;
|
||||
accCenter->z -= dm->z;
|
||||
removed = true;
|
||||
dm->removed = true;
|
||||
|
||||
it = doorInfos.erase(it);
|
||||
// it.remove();
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
if (removed) calcInfo();
|
||||
}
|
||||
|
||||
void Village::addDoorInfo(std::shared_ptr<DoorInfo> di)
|
||||
{
|
||||
doorInfos.push_back(di);
|
||||
accCenter->x += di->x;
|
||||
accCenter->y += di->y;
|
||||
accCenter->z += di->z;
|
||||
calcInfo();
|
||||
stableSince = di->timeStamp;
|
||||
bool Village::isDoor(int x, int y, int z) {
|
||||
int tileId = level->getTile(x, y, z);
|
||||
if (tileId <= 0) return false;
|
||||
return tileId == Tile::door_wood_Id;
|
||||
}
|
||||
|
||||
bool Village::canRemove()
|
||||
{
|
||||
return doorInfos.empty();
|
||||
void Village::calcInfo() {
|
||||
int s = doorInfos.size();
|
||||
if (s == 0) {
|
||||
center->set(0, 0, 0);
|
||||
radius = 0;
|
||||
return;
|
||||
}
|
||||
center->set(accCenter->x / s, accCenter->y / s, accCenter->z / s);
|
||||
int maxRadiusSqr = 0;
|
||||
// for (DoorInfo dm : doorInfos)
|
||||
for (AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it) {
|
||||
std::shared_ptr<DoorInfo> dm = *it;
|
||||
maxRadiusSqr = std::max(
|
||||
dm->distanceToSqr(center->x, center->y, center->z), maxRadiusSqr);
|
||||
}
|
||||
int doorDist =
|
||||
Villages::MaxDoorDist; // Take into local int for PS4 as max takes a
|
||||
// reference to the const int there and then
|
||||
// needs the value to exist for the linker
|
||||
radius = std::max(doorDist, (int)sqrt((float)maxRadiusSqr) + 1);
|
||||
}
|
||||
|
||||
void Village::addAggressor(std::shared_ptr<Mob> mob)
|
||||
{
|
||||
//for (Aggressor a : aggressors)
|
||||
for(AUTO_VAR(it, aggressors.begin()); it != aggressors.end(); ++it)
|
||||
{
|
||||
Aggressor *a = *it;
|
||||
if (a->mob == mob)
|
||||
{
|
||||
a->timeStamp = _tick;
|
||||
return;
|
||||
}
|
||||
}
|
||||
aggressors.push_back(new Aggressor(mob, _tick));
|
||||
int Village::getStanding(const std::wstring& playerName) {
|
||||
AUTO_VAR(it, playerStanding.find(playerName));
|
||||
if (it != playerStanding.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<Mob> Village::getClosestAggressor(std::shared_ptr<Mob> from)
|
||||
{
|
||||
double closestSqr = Double::MAX_VALUE;
|
||||
Aggressor *closest = NULL;
|
||||
//for (int i = 0; i < aggressors.size(); ++i)
|
||||
for(AUTO_VAR(it, aggressors.begin()); it != aggressors.end(); ++it)
|
||||
{
|
||||
Aggressor *a = *it; //aggressors.get(i);
|
||||
double distSqr = a->mob->distanceToSqr(from);
|
||||
if (distSqr > closestSqr) continue;
|
||||
closest = a;
|
||||
closestSqr = distSqr;
|
||||
}
|
||||
return closest != NULL ? closest->mob : nullptr;
|
||||
int Village::modifyStanding(const std::wstring& playerName, int delta) {
|
||||
int current = getStanding(playerName);
|
||||
int newValue = Mth::clamp(current + delta, -30, 10);
|
||||
playerStanding.insert(std::pair<std::wstring, int>(playerName, newValue));
|
||||
return newValue;
|
||||
}
|
||||
|
||||
std::shared_ptr<Player> Village::getClosestBadStandingPlayer(std::shared_ptr<Mob> from) // 4J Stu - Should be LivingEntity when we add that
|
||||
{
|
||||
double closestSqr = Double::MAX_VALUE;
|
||||
std::shared_ptr<Player> closest = nullptr;
|
||||
|
||||
//for (String player : playerStanding.keySet())
|
||||
for(AUTO_VAR(it,playerStanding.begin()); it != playerStanding.end(); ++it)
|
||||
{
|
||||
std::wstring player = it->first;
|
||||
if (isVeryBadStanding(player))
|
||||
{
|
||||
std::shared_ptr<Player> mob = level->getPlayerByName(player);
|
||||
if (mob != NULL)
|
||||
{
|
||||
double distSqr = mob->distanceToSqr(from);
|
||||
if (distSqr > closestSqr) continue;
|
||||
closest = mob;
|
||||
closestSqr = distSqr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return closest;
|
||||
bool Village::isGoodStanding(const std::wstring& playerName) {
|
||||
return getStanding(playerName) >= 0;
|
||||
}
|
||||
|
||||
void Village::updateAggressors()
|
||||
{
|
||||
//for (Iterator<Aggressor> it = aggressors.iterator(); it.hasNext();)
|
||||
for(AUTO_VAR(it, aggressors.begin()); it != aggressors.end();)
|
||||
{
|
||||
Aggressor *a = *it; //it.next();
|
||||
if (!a->mob->isAlive() || abs(_tick - a->timeStamp) > 300)
|
||||
{
|
||||
delete *it;
|
||||
it = aggressors.erase(it);
|
||||
//it.remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
bool Village::isBadStanding(const std::wstring& playerName) {
|
||||
return getStanding(playerName) <= -5;
|
||||
}
|
||||
|
||||
void Village::updateDoors()
|
||||
{
|
||||
bool removed = false;
|
||||
bool resetBookings = level->random->nextInt(50) == 0;
|
||||
//for (Iterator<DoorInfo> it = doorInfos.iterator(); it.hasNext();)
|
||||
for(AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end();)
|
||||
{
|
||||
std::shared_ptr<DoorInfo> dm = *it; //it.next();
|
||||
if (resetBookings) dm->resetBookingCount();
|
||||
if (!isDoor(dm->x, dm->y, dm->z) || abs(_tick - dm->timeStamp) > 1200)
|
||||
{
|
||||
accCenter->x -= dm->x;
|
||||
accCenter->y -= dm->y;
|
||||
accCenter->z -= dm->z;
|
||||
removed = true;
|
||||
dm->removed = true;
|
||||
|
||||
it = doorInfos.erase(it);
|
||||
//it.remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
if (removed) calcInfo();
|
||||
bool Village::isVeryBadStanding(const std::wstring playerName) {
|
||||
return getStanding(playerName) <= -15;
|
||||
}
|
||||
|
||||
bool Village::isDoor(int x, int y, int z)
|
||||
{
|
||||
int tileId = level->getTile(x, y, z);
|
||||
if (tileId <= 0) return false;
|
||||
return tileId == Tile::door_wood_Id;
|
||||
void Village::readAdditionalSaveData(CompoundTag* tag) {
|
||||
populationSize = tag->getInt(L"PopSize");
|
||||
radius = tag->getInt(L"Radius");
|
||||
golemCount = tag->getInt(L"Golems");
|
||||
stableSince = tag->getInt(L"Stable");
|
||||
_tick = tag->getInt(L"Tick");
|
||||
noBreedTimer = tag->getInt(L"MTick");
|
||||
center->x = tag->getInt(L"CX");
|
||||
center->y = tag->getInt(L"CY");
|
||||
center->z = tag->getInt(L"CZ");
|
||||
accCenter->x = tag->getInt(L"ACX");
|
||||
accCenter->y = tag->getInt(L"ACY");
|
||||
accCenter->z = tag->getInt(L"ACZ");
|
||||
|
||||
ListTag<CompoundTag>* doorTags =
|
||||
(ListTag<CompoundTag>*)tag->getList(L"Doors");
|
||||
for (int i = 0; i < doorTags->size(); i++) {
|
||||
CompoundTag* dTag = doorTags->get(i);
|
||||
|
||||
std::shared_ptr<DoorInfo> door = std::shared_ptr<DoorInfo>(new DoorInfo(
|
||||
dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"),
|
||||
dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS")));
|
||||
doorInfos.push_back(door);
|
||||
}
|
||||
|
||||
ListTag<CompoundTag>* playerTags =
|
||||
(ListTag<CompoundTag>*)tag->getList(L"Players");
|
||||
for (int i = 0; i < playerTags->size(); i++) {
|
||||
CompoundTag* pTag = playerTags->get(i);
|
||||
playerStanding.insert(std::pair<std::wstring, int>(
|
||||
pTag->getString(L"Name"), pTag->getInt(L"S")));
|
||||
}
|
||||
}
|
||||
|
||||
void Village::calcInfo()
|
||||
{
|
||||
int s = doorInfos.size();
|
||||
if (s == 0)
|
||||
{
|
||||
center->set(0, 0, 0);
|
||||
radius = 0;
|
||||
return;
|
||||
}
|
||||
center->set(accCenter->x / s, accCenter->y / s, accCenter->z / s);
|
||||
int maxRadiusSqr = 0;
|
||||
//for (DoorInfo dm : doorInfos)
|
||||
for(AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<DoorInfo> dm = *it;
|
||||
maxRadiusSqr = std::max(dm->distanceToSqr(center->x, center->y, center->z), maxRadiusSqr);
|
||||
}
|
||||
int doorDist= Villages::MaxDoorDist; // Take into local int for PS4 as max takes a reference to the const int there and then needs the value to exist for the linker
|
||||
radius = std::max(doorDist, (int) sqrt((float)maxRadiusSqr) + 1);
|
||||
void Village::addAdditonalSaveData(CompoundTag* tag) {
|
||||
tag->putInt(L"PopSize", populationSize);
|
||||
tag->putInt(L"Radius", radius);
|
||||
tag->putInt(L"Golems", golemCount);
|
||||
tag->putInt(L"Stable", stableSince);
|
||||
tag->putInt(L"Tick", _tick);
|
||||
tag->putInt(L"MTick", noBreedTimer);
|
||||
tag->putInt(L"CX", center->x);
|
||||
tag->putInt(L"CY", center->y);
|
||||
tag->putInt(L"CZ", center->z);
|
||||
tag->putInt(L"ACX", accCenter->x);
|
||||
tag->putInt(L"ACY", accCenter->y);
|
||||
tag->putInt(L"ACZ", accCenter->z);
|
||||
|
||||
ListTag<CompoundTag>* doorTags = new ListTag<CompoundTag>(L"Doors");
|
||||
// for (DoorInfo dm : doorInfos)
|
||||
for (AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it) {
|
||||
std::shared_ptr<DoorInfo> dm = *it;
|
||||
CompoundTag* doorTag = new CompoundTag(L"Door");
|
||||
doorTag->putInt(L"X", dm->x);
|
||||
doorTag->putInt(L"Y", dm->y);
|
||||
doorTag->putInt(L"Z", dm->z);
|
||||
doorTag->putInt(L"IDX", dm->insideDx);
|
||||
doorTag->putInt(L"IDZ", dm->insideDz);
|
||||
doorTag->putInt(L"TS", dm->timeStamp);
|
||||
doorTags->add(doorTag);
|
||||
}
|
||||
tag->put(L"Doors", doorTags);
|
||||
|
||||
ListTag<CompoundTag>* playerTags = new ListTag<CompoundTag>(L"Players");
|
||||
// for (String player : playerStanding.keySet())
|
||||
for (AUTO_VAR(it, playerStanding.begin()); it != playerStanding.end();
|
||||
++it) {
|
||||
std::wstring player = it->first;
|
||||
CompoundTag* playerTag = new CompoundTag(player);
|
||||
playerTag->putString(L"Name", player);
|
||||
playerTag->putInt(L"S", it->second);
|
||||
playerTags->add(playerTag);
|
||||
}
|
||||
tag->put(L"Players", playerTags);
|
||||
}
|
||||
|
||||
int Village::getStanding(const std::wstring &playerName)
|
||||
{
|
||||
AUTO_VAR(it,playerStanding.find(playerName));
|
||||
if (it != playerStanding.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return 0;
|
||||
void Village::resetNoBreedTimer() { noBreedTimer = _tick; }
|
||||
|
||||
bool Village::isBreedTimerOk() {
|
||||
// prevent new villagers if a villager was killed by a mob within 3
|
||||
// minutes
|
||||
return noBreedTimer == 0 ||
|
||||
(_tick - noBreedTimer) >=
|
||||
(SharedConstants::TICKS_PER_SECOND * 60 * 3);
|
||||
}
|
||||
|
||||
int Village::modifyStanding(const std::wstring &playerName, int delta)
|
||||
{
|
||||
int current = getStanding(playerName);
|
||||
int newValue = Mth::clamp(current + delta, -30, 10);
|
||||
playerStanding.insert(std::pair<std::wstring,int>(playerName, newValue));
|
||||
return newValue;
|
||||
}
|
||||
|
||||
bool Village::isGoodStanding(const std::wstring &playerName)
|
||||
{
|
||||
return getStanding(playerName) >= 0;
|
||||
}
|
||||
|
||||
bool Village::isBadStanding(const std::wstring &playerName)
|
||||
{
|
||||
return getStanding(playerName) <= -5;
|
||||
}
|
||||
|
||||
bool Village::isVeryBadStanding(const std::wstring playerName)
|
||||
{
|
||||
return getStanding(playerName) <= -15;
|
||||
}
|
||||
|
||||
void Village::readAdditionalSaveData(CompoundTag *tag)
|
||||
{
|
||||
populationSize = tag->getInt(L"PopSize");
|
||||
radius = tag->getInt(L"Radius");
|
||||
golemCount = tag->getInt(L"Golems");
|
||||
stableSince = tag->getInt(L"Stable");
|
||||
_tick = tag->getInt(L"Tick");
|
||||
noBreedTimer = tag->getInt(L"MTick");
|
||||
center->x = tag->getInt(L"CX");
|
||||
center->y = tag->getInt(L"CY");
|
||||
center->z = tag->getInt(L"CZ");
|
||||
accCenter->x = tag->getInt(L"ACX");
|
||||
accCenter->y = tag->getInt(L"ACY");
|
||||
accCenter->z = tag->getInt(L"ACZ");
|
||||
|
||||
ListTag<CompoundTag> *doorTags = (ListTag<CompoundTag> *) tag->getList(L"Doors");
|
||||
for (int i = 0; i < doorTags->size(); i++)
|
||||
{
|
||||
CompoundTag *dTag = doorTags->get(i);
|
||||
|
||||
std::shared_ptr<DoorInfo> door = std::shared_ptr<DoorInfo>(new DoorInfo(dTag->getInt(L"X"), dTag->getInt(L"Y"), dTag->getInt(L"Z"), dTag->getInt(L"IDX"), dTag->getInt(L"IDZ"), dTag->getInt(L"TS")));
|
||||
doorInfos.push_back(door);
|
||||
}
|
||||
|
||||
ListTag<CompoundTag> *playerTags = (ListTag<CompoundTag> *) tag->getList(L"Players");
|
||||
for (int i = 0; i < playerTags->size(); i++)
|
||||
{
|
||||
CompoundTag *pTag = playerTags->get(i);
|
||||
playerStanding.insert(std::pair<std::wstring,int>(pTag->getString(L"Name"), pTag->getInt(L"S")));
|
||||
}
|
||||
}
|
||||
|
||||
void Village::addAdditonalSaveData(CompoundTag *tag)
|
||||
{
|
||||
tag->putInt(L"PopSize", populationSize);
|
||||
tag->putInt(L"Radius", radius);
|
||||
tag->putInt(L"Golems", golemCount);
|
||||
tag->putInt(L"Stable", stableSince);
|
||||
tag->putInt(L"Tick", _tick);
|
||||
tag->putInt(L"MTick", noBreedTimer);
|
||||
tag->putInt(L"CX", center->x);
|
||||
tag->putInt(L"CY", center->y);
|
||||
tag->putInt(L"CZ", center->z);
|
||||
tag->putInt(L"ACX", accCenter->x);
|
||||
tag->putInt(L"ACY", accCenter->y);
|
||||
tag->putInt(L"ACZ", accCenter->z);
|
||||
|
||||
ListTag<CompoundTag> *doorTags = new ListTag<CompoundTag>(L"Doors");
|
||||
//for (DoorInfo dm : doorInfos)
|
||||
for(AUTO_VAR(it,doorInfos.begin()); it != doorInfos.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<DoorInfo> dm = *it;
|
||||
CompoundTag *doorTag = new CompoundTag(L"Door");
|
||||
doorTag->putInt(L"X", dm->x);
|
||||
doorTag->putInt(L"Y", dm->y);
|
||||
doorTag->putInt(L"Z", dm->z);
|
||||
doorTag->putInt(L"IDX", dm->insideDx);
|
||||
doorTag->putInt(L"IDZ", dm->insideDz);
|
||||
doorTag->putInt(L"TS", dm->timeStamp);
|
||||
doorTags->add(doorTag);
|
||||
}
|
||||
tag->put(L"Doors", doorTags);
|
||||
|
||||
ListTag<CompoundTag> *playerTags = new ListTag<CompoundTag>(L"Players");
|
||||
//for (String player : playerStanding.keySet())
|
||||
for(AUTO_VAR(it, playerStanding.begin()); it != playerStanding.end(); ++it)
|
||||
{
|
||||
std::wstring player = it->first;
|
||||
CompoundTag *playerTag = new CompoundTag(player);
|
||||
playerTag->putString(L"Name", player);
|
||||
playerTag->putInt(L"S", it->second);
|
||||
playerTags->add(playerTag);
|
||||
}
|
||||
tag->put(L"Players", playerTags);
|
||||
|
||||
}
|
||||
|
||||
void Village::resetNoBreedTimer()
|
||||
{
|
||||
noBreedTimer = _tick;
|
||||
}
|
||||
|
||||
bool Village::isBreedTimerOk()
|
||||
{
|
||||
// prevent new villagers if a villager was killed by a mob within 3
|
||||
// minutes
|
||||
return noBreedTimer == 0 || (_tick - noBreedTimer) >= (SharedConstants::TICKS_PER_SECOND * 60 * 3);
|
||||
}
|
||||
|
||||
void Village::rewardAllPlayers(int amount)
|
||||
{
|
||||
//for (String player : playerStanding.keySet())
|
||||
for(AUTO_VAR(it, playerStanding.begin()); it != playerStanding.end(); ++it)
|
||||
{
|
||||
modifyStanding(it->first, amount);
|
||||
}
|
||||
void Village::rewardAllPlayers(int amount) {
|
||||
// for (String player : playerStanding.keySet())
|
||||
for (AUTO_VAR(it, playerStanding.begin()); it != playerStanding.end();
|
||||
++it) {
|
||||
modifyStanding(it->first, amount);
|
||||
}
|
||||
}
|
||||
@@ -1,81 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
class Village
|
||||
{
|
||||
class Village {
|
||||
private:
|
||||
Level *level;
|
||||
std::vector<std::shared_ptr<DoorInfo> > doorInfos;
|
||||
Level* level;
|
||||
std::vector<std::shared_ptr<DoorInfo> > doorInfos;
|
||||
|
||||
Pos *accCenter;
|
||||
Pos *center;
|
||||
int radius;
|
||||
int stableSince;
|
||||
int _tick;
|
||||
int populationSize;
|
||||
int noBreedTimer;
|
||||
Pos* accCenter;
|
||||
Pos* center;
|
||||
int radius;
|
||||
int stableSince;
|
||||
int _tick;
|
||||
int populationSize;
|
||||
int noBreedTimer;
|
||||
|
||||
std::unordered_map<std::wstring, int> playerStanding;
|
||||
std::unordered_map<std::wstring, int> playerStanding;
|
||||
|
||||
class Aggressor
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<Mob> mob;
|
||||
int timeStamp;
|
||||
class Aggressor {
|
||||
public:
|
||||
std::shared_ptr<Mob> mob;
|
||||
int timeStamp;
|
||||
|
||||
Aggressor(std::shared_ptr<Mob> mob, int timeStamp);
|
||||
};
|
||||
Aggressor(std::shared_ptr<Mob> mob, int timeStamp);
|
||||
};
|
||||
|
||||
std::vector<Aggressor *> aggressors;
|
||||
int golemCount;
|
||||
std::vector<Aggressor*> aggressors;
|
||||
int golemCount;
|
||||
|
||||
public:
|
||||
Village();
|
||||
Village(Level *level);
|
||||
~Village();
|
||||
Village();
|
||||
Village(Level* level);
|
||||
~Village();
|
||||
|
||||
void setLevel(Level *level);
|
||||
void setLevel(Level* level);
|
||||
|
||||
void tick(int tick);
|
||||
void tick(int tick);
|
||||
|
||||
private:
|
||||
Vec3 *findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz);
|
||||
bool canSpawnAt(int x, int y, int z, int sx, int sy, int sz);
|
||||
void countGolem();
|
||||
void countPopulation();
|
||||
Vec3* findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz);
|
||||
bool canSpawnAt(int x, int y, int z, int sx, int sy, int sz);
|
||||
void countGolem();
|
||||
void countPopulation();
|
||||
|
||||
public:
|
||||
Pos *getCenter();
|
||||
int getRadius();
|
||||
int getDoorCount();
|
||||
int getStableAge();
|
||||
int getPopulationSize();
|
||||
bool isInside(int xx, int yy, int zz);
|
||||
std::vector<std::shared_ptr<DoorInfo> > *getDoorInfos();
|
||||
std::shared_ptr<DoorInfo> getClosestDoorInfo(int x, int y, int z);
|
||||
std::shared_ptr<DoorInfo> getBestDoorInfo(int x, int y, int z);
|
||||
bool hasDoorInfo(int x, int y, int z);
|
||||
std::shared_ptr<DoorInfo> getDoorInfo(int x, int y, int z);
|
||||
void addDoorInfo(std::shared_ptr<DoorInfo> di);
|
||||
bool canRemove();
|
||||
void addAggressor(std::shared_ptr<Mob> mob);
|
||||
std::shared_ptr<Mob> getClosestAggressor(std::shared_ptr<Mob> from);
|
||||
std::shared_ptr<Player> getClosestBadStandingPlayer(std::shared_ptr<Mob> from); // 4J Stu - Should be LivingEntity when we add that
|
||||
Pos* getCenter();
|
||||
int getRadius();
|
||||
int getDoorCount();
|
||||
int getStableAge();
|
||||
int getPopulationSize();
|
||||
bool isInside(int xx, int yy, int zz);
|
||||
std::vector<std::shared_ptr<DoorInfo> >* getDoorInfos();
|
||||
std::shared_ptr<DoorInfo> getClosestDoorInfo(int x, int y, int z);
|
||||
std::shared_ptr<DoorInfo> getBestDoorInfo(int x, int y, int z);
|
||||
bool hasDoorInfo(int x, int y, int z);
|
||||
std::shared_ptr<DoorInfo> getDoorInfo(int x, int y, int z);
|
||||
void addDoorInfo(std::shared_ptr<DoorInfo> di);
|
||||
bool canRemove();
|
||||
void addAggressor(std::shared_ptr<Mob> mob);
|
||||
std::shared_ptr<Mob> getClosestAggressor(std::shared_ptr<Mob> from);
|
||||
std::shared_ptr<Player> getClosestBadStandingPlayer(
|
||||
std::shared_ptr<Mob>
|
||||
from); // 4J Stu - Should be LivingEntity when we add that
|
||||
|
||||
private:
|
||||
void updateAggressors();
|
||||
void updateDoors();
|
||||
bool isDoor(int x, int y, int z);
|
||||
void calcInfo();
|
||||
void updateAggressors();
|
||||
void updateDoors();
|
||||
bool isDoor(int x, int y, int z);
|
||||
void calcInfo();
|
||||
|
||||
public:
|
||||
int getStanding(const std::wstring &playerName);
|
||||
int modifyStanding(const std::wstring &playerName, int delta);
|
||||
bool isGoodStanding(const std::wstring &playerName);
|
||||
bool isBadStanding(const std::wstring &playerName);
|
||||
bool isVeryBadStanding(const std::wstring playerName);
|
||||
void readAdditionalSaveData(CompoundTag *tag);
|
||||
void addAdditonalSaveData(CompoundTag *tag);
|
||||
void resetNoBreedTimer();
|
||||
bool isBreedTimerOk();
|
||||
void rewardAllPlayers(int amount);
|
||||
int getStanding(const std::wstring& playerName);
|
||||
int modifyStanding(const std::wstring& playerName, int delta);
|
||||
bool isGoodStanding(const std::wstring& playerName);
|
||||
bool isBadStanding(const std::wstring& playerName);
|
||||
bool isVeryBadStanding(const std::wstring playerName);
|
||||
void readAdditionalSaveData(CompoundTag* tag);
|
||||
void addAdditonalSaveData(CompoundTag* tag);
|
||||
void resetNoBreedTimer();
|
||||
bool isBreedTimerOk();
|
||||
void rewardAllPlayers(int amount);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,351 +3,427 @@
|
||||
|
||||
class BiomeSource;
|
||||
|
||||
class VillagePieces
|
||||
{
|
||||
|
||||
class VillagePieces {
|
||||
private:
|
||||
static const int MAX_DEPTH = 50;
|
||||
static const int MAX_DEPTH = 50;
|
||||
static const int BASE_ROAD_DEPTH = 3;
|
||||
// the dungeon starts at 64 and traverses downwards to this point
|
||||
static const int LOWEST_Y_POSITION = 10;
|
||||
|
||||
public:
|
||||
static const int SIZE_SMALL = 0;
|
||||
static const int SIZE_BIG = 1;
|
||||
static const int SIZE_BIGGEST = 2;
|
||||
static const int SIZE_SMALL = 0;
|
||||
static const int SIZE_BIG = 1;
|
||||
static const int SIZE_BIGGEST = 2;
|
||||
|
||||
// 4J - added to replace use of Class<? extends VillagePiece> within this class
|
||||
enum EPieceClass
|
||||
{
|
||||
EPieceClass_SimpleHouse,
|
||||
EPieceClass_SmallTemple,
|
||||
EPieceClass_BookHouse,
|
||||
EPieceClass_SmallHut,
|
||||
EPieceClass_PigHouse,
|
||||
EPieceClass_DoubleFarmland,
|
||||
EPieceClass_Farmland,
|
||||
EPieceClass_Smithy,
|
||||
EPieceClass_TwoRoomHouse
|
||||
};
|
||||
// 4J - added to replace use of Class<? extends VillagePiece> within this
|
||||
// class
|
||||
enum EPieceClass {
|
||||
EPieceClass_SimpleHouse,
|
||||
EPieceClass_SmallTemple,
|
||||
EPieceClass_BookHouse,
|
||||
EPieceClass_SmallHut,
|
||||
EPieceClass_PigHouse,
|
||||
EPieceClass_DoubleFarmland,
|
||||
EPieceClass_Farmland,
|
||||
EPieceClass_Smithy,
|
||||
EPieceClass_TwoRoomHouse
|
||||
};
|
||||
|
||||
class PieceWeight {
|
||||
public:
|
||||
EPieceClass pieceClass; // 4J - EPieceClass was Class<? extends VillagePiece>
|
||||
public:
|
||||
EPieceClass
|
||||
pieceClass; // 4J - EPieceClass was Class<? extends VillagePiece>
|
||||
const int weight;
|
||||
int placeCount;
|
||||
int maxPlaceCount;
|
||||
|
||||
PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount); // 4J - EPieceClass was Class<? extends VillagePiece>
|
||||
PieceWeight(EPieceClass pieceClass, int weight,
|
||||
int maxPlaceCount); // 4J - EPieceClass was Class<? extends
|
||||
// VillagePiece>
|
||||
bool doPlace(int depth);
|
||||
bool isValid();
|
||||
};
|
||||
|
||||
static std::list<PieceWeight *> *createPieceSet(Random *random, int villageSize); // 4J - was ArrayList
|
||||
static std::list<PieceWeight*>* createPieceSet(
|
||||
Random* random, int villageSize); // 4J - was ArrayList
|
||||
|
||||
class StartPiece;
|
||||
|
||||
class StartPiece;
|
||||
private:
|
||||
class VillagePiece;
|
||||
static int updatePieceWeight(std::list<PieceWeight *> *currentPieces); // 4J = was array list
|
||||
static VillagePiece *findAndCreatePieceFactory(StartPiece *startPiece, PieceWeight *piece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
static VillagePiece *generatePieceFromSmallDoor(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
static StructurePiece *generateAndAddPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
static StructurePiece *generateAndAddRoadPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
|
||||
|
||||
class VillagePiece;
|
||||
static int updatePieceWeight(
|
||||
std::list<PieceWeight*>* currentPieces); // 4J = was array list
|
||||
static VillagePiece* findAndCreatePieceFactory(
|
||||
StartPiece* startPiece, PieceWeight* piece,
|
||||
std::list<StructurePiece*>* pieces, Random* random, int footX,
|
||||
int footY, int footZ, int direction, int depth);
|
||||
static VillagePiece* generatePieceFromSmallDoor(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY, int footZ, int direction,
|
||||
int depth);
|
||||
static StructurePiece* generateAndAddPiece(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY, int footZ, int direction,
|
||||
int depth);
|
||||
static StructurePiece* generateAndAddRoadPiece(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY, int footZ, int direction,
|
||||
int depth);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
private:
|
||||
class VillagePiece : public StructurePiece
|
||||
{
|
||||
private:
|
||||
int spawnedVillagerCount;
|
||||
protected:
|
||||
StartPiece *startPiece;
|
||||
class VillagePiece : public StructurePiece {
|
||||
private:
|
||||
int spawnedVillagerCount;
|
||||
|
||||
VillagePiece(StartPiece *startPiece, int genDepth);
|
||||
StructurePiece *generateHouseNorthernLeft(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int yOff, int zOff);
|
||||
StructurePiece *generateHouseNorthernRight(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int yOff, int zOff);
|
||||
int getAverageGroundHeight(Level *level, BoundingBox *chunkBB);
|
||||
static bool isOkBox(BoundingBox *box, StartPiece *startRoom); // 4J added startRoom param
|
||||
void spawnVillagers(Level *level, BoundingBox *chunkBB, int x, int y, int z, int count);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
virtual int biomeBlock(int tile, int data);
|
||||
virtual int biomeData(int tile, int data);
|
||||
virtual void placeBlock(Level *level, int block, int data, int x, int y, int z, BoundingBox *chunkBB);
|
||||
virtual void generateBox(Level *level, BoundingBox *chunkBB, int x0, int y0, int z0, int x1, int y1, int z1, int edgeTile, int fillTile, bool skipAir);
|
||||
virtual void fillColumnDown(Level *level, int block, int data, int x, int startY, int z, BoundingBox *chunkBB);
|
||||
protected:
|
||||
StartPiece* startPiece;
|
||||
|
||||
VillagePiece(StartPiece* startPiece, int genDepth);
|
||||
StructurePiece* generateHouseNorthernLeft(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int yOff, int zOff);
|
||||
StructurePiece* generateHouseNorthernRight(
|
||||
StartPiece* startPiece, std::list<StructurePiece*>* pieces,
|
||||
Random* random, int yOff, int zOff);
|
||||
int getAverageGroundHeight(Level* level, BoundingBox* chunkBB);
|
||||
static bool isOkBox(BoundingBox* box,
|
||||
StartPiece* startRoom); // 4J added startRoom param
|
||||
void spawnVillagers(Level* level, BoundingBox* chunkBB, int x, int y,
|
||||
int z, int count);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
virtual int biomeBlock(int tile, int data);
|
||||
virtual int biomeData(int tile, int data);
|
||||
virtual void placeBlock(Level* level, int block, int data, int x, int y,
|
||||
int z, BoundingBox* chunkBB);
|
||||
virtual void generateBox(Level* level, BoundingBox* chunkBB, int x0,
|
||||
int y0, int z0, int x1, int y1, int z1,
|
||||
int edgeTile, int fillTile, bool skipAir);
|
||||
virtual void fillColumnDown(Level* level, int block, int data, int x,
|
||||
int startY, int z, BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class Well : public VillagePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 6;
|
||||
static const int height = 15;
|
||||
static const int depth = 6;
|
||||
|
||||
const bool isSource;
|
||||
int heightPosition;
|
||||
class Well : public VillagePiece {
|
||||
private:
|
||||
static const int width = 6;
|
||||
static const int height = 15;
|
||||
static const int depth = 6;
|
||||
|
||||
public:
|
||||
Well(StartPiece *startPiece, int genDepth, Random *random, int west, int north);
|
||||
const bool isSource;
|
||||
int heightPosition;
|
||||
|
||||
Well(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
//static Well *createPiece(std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
Well(StartPiece* startPiece, int genDepth, Random* random, int west,
|
||||
int north);
|
||||
|
||||
Well(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
// static Well *createPiece(std::list<StructurePiece *> *pieces, Random
|
||||
// *random, int footX, int footY, int footZ, int direction, int
|
||||
// genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class StartPiece : public Well
|
||||
{
|
||||
public:
|
||||
BiomeSource *biomeSource;
|
||||
bool isDesertVillage;
|
||||
class StartPiece : public Well {
|
||||
public:
|
||||
BiomeSource* biomeSource;
|
||||
bool isDesertVillage;
|
||||
|
||||
int villageSize;
|
||||
bool isLibraryAdded;
|
||||
PieceWeight *previousPiece;
|
||||
std::list<PieceWeight *> *pieceSet; // 4J - was ArrayList
|
||||
Level *m_level;
|
||||
int villageSize;
|
||||
bool isLibraryAdded;
|
||||
PieceWeight* previousPiece;
|
||||
std::list<PieceWeight*>* pieceSet; // 4J - was ArrayList
|
||||
Level* m_level;
|
||||
|
||||
// these queues are used so that the addChildren calls are
|
||||
// called in a random order
|
||||
std::vector<StructurePiece *> pendingHouses; // 4J - was ArrayList
|
||||
std::vector<StructurePiece *> pendingRoads; // 4J - was ArrayList
|
||||
|
||||
StartPiece(BiomeSource *biomeSource, int genDepth, Random *random, int west, int north, std::list<PieceWeight *> *pieceSet, int villageSize, Level *level); // 4J Added level param
|
||||
virtual ~StartPiece();
|
||||
|
||||
BiomeSource *getBiomeSource();
|
||||
std::vector<StructurePiece*> pendingHouses; // 4J - was ArrayList
|
||||
std::vector<StructurePiece*> pendingRoads; // 4J - was ArrayList
|
||||
|
||||
StartPiece(BiomeSource* biomeSource, int genDepth, Random* random,
|
||||
int west, int north, std::list<PieceWeight*>* pieceSet,
|
||||
int villageSize, Level* level); // 4J Added level param
|
||||
virtual ~StartPiece();
|
||||
|
||||
BiomeSource* getBiomeSource();
|
||||
};
|
||||
|
||||
public:
|
||||
class VillageRoadPiece : public VillagePiece
|
||||
{
|
||||
protected :
|
||||
VillageRoadPiece(StartPiece *startPiece, int genDepth) : VillagePiece(startPiece, genDepth) {}
|
||||
class VillageRoadPiece : public VillagePiece {
|
||||
protected:
|
||||
VillageRoadPiece(StartPiece* startPiece, int genDepth)
|
||||
: VillagePiece(startPiece, genDepth) {}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class StraightRoad : public VillageRoadPiece
|
||||
{
|
||||
class StraightRoad : public VillageRoadPiece {
|
||||
private:
|
||||
static const int width = 3;
|
||||
int length;
|
||||
|
||||
private:
|
||||
static const int width = 3;
|
||||
int length;
|
||||
public:
|
||||
StraightRoad(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece *startPiece, std::list<StructurePiece *> *pieces, Random *random);
|
||||
static BoundingBox *findPieceBox(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
StraightRoad(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
virtual void addChildren(StructurePiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random);
|
||||
static BoundingBox* findPieceBox(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public:
|
||||
class SimpleHouse : public VillagePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 6;
|
||||
static const int depth = 5;
|
||||
class SimpleHouse : public VillagePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 6;
|
||||
static const int depth = 5;
|
||||
|
||||
private:
|
||||
int heightPosition;
|
||||
const bool hasTerrace;
|
||||
private:
|
||||
int heightPosition;
|
||||
const bool hasTerrace;
|
||||
|
||||
public:
|
||||
SimpleHouse(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
public:
|
||||
static SimpleHouse *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
};
|
||||
public:
|
||||
SimpleHouse(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
|
||||
public:
|
||||
class SmallTemple : public VillagePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 12;
|
||||
static const int depth = 9;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
public:
|
||||
SmallTemple(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
|
||||
static SmallTemple *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
};
|
||||
|
||||
public:
|
||||
class BookHouse : public VillagePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 9;
|
||||
static const int height = 9;
|
||||
static const int depth = 6;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
public:
|
||||
BookHouse(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
|
||||
static BookHouse *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
};
|
||||
|
||||
public:
|
||||
class SmallHut : public VillagePiece
|
||||
{
|
||||
|
||||
private:
|
||||
static const int width = 4;
|
||||
static const int height = 6;
|
||||
static const int depth = 5;
|
||||
|
||||
int heightPosition;
|
||||
const bool lowCeiling;
|
||||
const int tablePlacement;
|
||||
|
||||
public:
|
||||
SmallHut(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
static SmallHut *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
static SimpleHouse* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class PigHouse : public VillagePiece
|
||||
{
|
||||
|
||||
private:
|
||||
static const int width = 9;
|
||||
static const int height = 7;
|
||||
static const int depth = 11;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
public:
|
||||
PigHouse(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
static PigHouse *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
};
|
||||
|
||||
public:
|
||||
class TwoRoomHouse : public VillagePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 9;
|
||||
static const int height = 7;
|
||||
static const int depth = 12;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
public:
|
||||
TwoRoomHouse(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
static TwoRoomHouse *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class Smithy : public VillagePiece
|
||||
{
|
||||
|
||||
private:
|
||||
static const int width = 10;
|
||||
static const int height = 6;
|
||||
static const int depth = 7;
|
||||
class SmallTemple : public VillagePiece {
|
||||
private:
|
||||
static const int width = 5;
|
||||
static const int height = 12;
|
||||
static const int depth = 9;
|
||||
|
||||
int heightPosition;
|
||||
bool hasPlacedChest;
|
||||
|
||||
static WeighedTreasureArray treasureItems;
|
||||
public:
|
||||
SmallTemple(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
|
||||
public:
|
||||
static void staticCtor();
|
||||
|
||||
Smithy(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
static Smithy *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
static SmallTemple* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
};
|
||||
|
||||
public:
|
||||
class Farmland : public VillagePiece
|
||||
{
|
||||
class BookHouse : public VillagePiece {
|
||||
private:
|
||||
static const int width = 9;
|
||||
static const int height = 9;
|
||||
static const int depth = 6;
|
||||
|
||||
private:
|
||||
static const int width = 7;
|
||||
static const int height = 4;
|
||||
static const int depth = 9;
|
||||
|
||||
int heightPosition;
|
||||
int heightPosition;
|
||||
|
||||
int cropsA;
|
||||
int cropsB;
|
||||
public:
|
||||
BookHouse(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
|
||||
int selectCrops(Random *random);
|
||||
|
||||
public:
|
||||
Farmland(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
static Farmland *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
static BookHouse* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
};
|
||||
|
||||
public:
|
||||
class DoubleFarmland : public VillagePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 13;
|
||||
static const int height = 4;
|
||||
static const int depth = 9;
|
||||
|
||||
int heightPosition;
|
||||
class SmallHut : public VillagePiece {
|
||||
private:
|
||||
static const int width = 4;
|
||||
static const int height = 6;
|
||||
static const int depth = 5;
|
||||
|
||||
int cropsA;
|
||||
int cropsB;
|
||||
int cropsC;
|
||||
int cropsD;
|
||||
int heightPosition;
|
||||
const bool lowCeiling;
|
||||
const int tablePlacement;
|
||||
|
||||
int selectCrops(Random *random);
|
||||
|
||||
public:
|
||||
DoubleFarmland(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction);
|
||||
static DoubleFarmland *createPiece(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
SmallHut(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
static SmallHut* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class LightPost : public VillagePiece
|
||||
{
|
||||
private:
|
||||
static const int width = 3;
|
||||
class PigHouse : public VillagePiece {
|
||||
private:
|
||||
static const int width = 9;
|
||||
static const int height = 7;
|
||||
static const int depth = 11;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
public:
|
||||
PigHouse(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
static PigHouse* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
};
|
||||
|
||||
public:
|
||||
class TwoRoomHouse : public VillagePiece {
|
||||
private:
|
||||
static const int width = 9;
|
||||
static const int height = 7;
|
||||
static const int depth = 12;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
public:
|
||||
TwoRoomHouse(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
static TwoRoomHouse* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class Smithy : public VillagePiece {
|
||||
private:
|
||||
static const int width = 10;
|
||||
static const int height = 6;
|
||||
static const int depth = 7;
|
||||
|
||||
int heightPosition;
|
||||
bool hasPlacedChest;
|
||||
|
||||
static WeighedTreasureArray treasureItems;
|
||||
|
||||
public:
|
||||
static void staticCtor();
|
||||
|
||||
Smithy(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
static Smithy* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
virtual int getVillagerProfession(int villagerNumber);
|
||||
};
|
||||
|
||||
public:
|
||||
class Farmland : public VillagePiece {
|
||||
private:
|
||||
static const int width = 7;
|
||||
static const int height = 4;
|
||||
static const int depth = 9;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
int cropsA;
|
||||
int cropsB;
|
||||
|
||||
int selectCrops(Random* random);
|
||||
|
||||
public:
|
||||
Farmland(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
static Farmland* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction, int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class DoubleFarmland : public VillagePiece {
|
||||
private:
|
||||
static const int width = 13;
|
||||
static const int height = 4;
|
||||
static const int depth = 9;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
int cropsA;
|
||||
int cropsB;
|
||||
int cropsC;
|
||||
int cropsD;
|
||||
|
||||
int selectCrops(Random* random);
|
||||
|
||||
public:
|
||||
DoubleFarmland(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* stairsBox, int direction);
|
||||
static DoubleFarmland* createPiece(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction,
|
||||
int genDepth);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
|
||||
public:
|
||||
class LightPost : public VillagePiece {
|
||||
private:
|
||||
static const int width = 3;
|
||||
static const int height = 4;
|
||||
static const int depth = 2;
|
||||
|
||||
int heightPosition;
|
||||
|
||||
public:
|
||||
LightPost(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *box, int direction);
|
||||
static BoundingBox *findPieceBox(StartPiece *startPiece, std::list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction);
|
||||
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
|
||||
public:
|
||||
LightPost(StartPiece* startPiece, int genDepth, Random* random,
|
||||
BoundingBox* box, int direction);
|
||||
static BoundingBox* findPieceBox(StartPiece* startPiece,
|
||||
std::list<StructurePiece*>* pieces,
|
||||
Random* random, int footX, int footY,
|
||||
int footZ, int direction);
|
||||
virtual bool postProcess(Level* level, Random* random,
|
||||
BoundingBox* chunkBB);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -8,246 +8,217 @@
|
||||
|
||||
const std::wstring Villages::VILLAGE_FILE_ID = L"villages";
|
||||
|
||||
Villages::Villages(const std::wstring &id) : SavedData(id)
|
||||
{
|
||||
_tick = 0;
|
||||
level = NULL;
|
||||
Villages::Villages(const std::wstring& id) : SavedData(id) {
|
||||
_tick = 0;
|
||||
level = NULL;
|
||||
}
|
||||
|
||||
Villages::Villages(Level *level) : SavedData(VILLAGE_FILE_ID)
|
||||
{
|
||||
_tick = 0;
|
||||
this->level = level;
|
||||
Villages::Villages(Level* level) : SavedData(VILLAGE_FILE_ID) {
|
||||
_tick = 0;
|
||||
this->level = level;
|
||||
}
|
||||
|
||||
Villages::~Villages()
|
||||
{
|
||||
for(AUTO_VAR(it,queries.begin()); it != queries.end(); ++it) delete *it;
|
||||
Villages::~Villages() {
|
||||
for (AUTO_VAR(it, queries.begin()); it != queries.end(); ++it) delete *it;
|
||||
}
|
||||
|
||||
void Villages::setLevel(Level *level)
|
||||
{
|
||||
this->level = level;
|
||||
void Villages::setLevel(Level* level) {
|
||||
this->level = level;
|
||||
|
||||
//for (Village village : villages)
|
||||
for(AUTO_VAR(it, villages.begin()); it != villages.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<Village> village = *it;
|
||||
village->setLevel(level);
|
||||
}
|
||||
// for (Village village : villages)
|
||||
for (AUTO_VAR(it, villages.begin()); it != villages.end(); ++it) {
|
||||
std::shared_ptr<Village> village = *it;
|
||||
village->setLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
void Villages::queryUpdateAround(int x, int y, int z)
|
||||
{
|
||||
if (queries.size() > 64) return;
|
||||
if (!hasQuery(x, y, z)) queries.push_back(new Pos(x, y, z));
|
||||
void Villages::queryUpdateAround(int x, int y, int z) {
|
||||
if (queries.size() > 64) return;
|
||||
if (!hasQuery(x, y, z)) queries.push_back(new Pos(x, y, z));
|
||||
}
|
||||
|
||||
void Villages::tick()
|
||||
{
|
||||
++_tick;
|
||||
//for (Village village : villages)
|
||||
for(AUTO_VAR(it, villages.begin()); it != villages.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<Village> village = *it;
|
||||
village->tick(_tick);
|
||||
}
|
||||
removeVillages();
|
||||
processNextQuery();
|
||||
cluster();
|
||||
void Villages::tick() {
|
||||
++_tick;
|
||||
// for (Village village : villages)
|
||||
for (AUTO_VAR(it, villages.begin()); it != villages.end(); ++it) {
|
||||
std::shared_ptr<Village> village = *it;
|
||||
village->tick(_tick);
|
||||
}
|
||||
removeVillages();
|
||||
processNextQuery();
|
||||
cluster();
|
||||
|
||||
if ((_tick % 400) == 0)
|
||||
{
|
||||
setDirty();
|
||||
}
|
||||
if ((_tick % 400) == 0) {
|
||||
setDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void Villages::removeVillages()
|
||||
{
|
||||
//for (Iterator<Village> it = villages.iterator(); it.hasNext();)
|
||||
for(AUTO_VAR(it, villages.begin()); it != villages.end(); )
|
||||
{
|
||||
std::shared_ptr<Village> village = *it; //it.next();
|
||||
if (village->canRemove())
|
||||
{
|
||||
it = villages.erase(it);
|
||||
//it.remove();
|
||||
setDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
void Villages::removeVillages() {
|
||||
// for (Iterator<Village> it = villages.iterator(); it.hasNext();)
|
||||
for (AUTO_VAR(it, villages.begin()); it != villages.end();) {
|
||||
std::shared_ptr<Village> village = *it; // it.next();
|
||||
if (village->canRemove()) {
|
||||
it = villages.erase(it);
|
||||
// it.remove();
|
||||
setDirty();
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Village> > *Villages::getVillages()
|
||||
{
|
||||
return &villages;
|
||||
std::vector<std::shared_ptr<Village> >* Villages::getVillages() {
|
||||
return &villages;
|
||||
}
|
||||
|
||||
std::shared_ptr<Village> Villages::getClosestVillage(int x, int y, int z, int maxDist)
|
||||
{
|
||||
std::shared_ptr<Village> closest = nullptr;
|
||||
float closestDistSqr = Float::MAX_VALUE;
|
||||
//for (Village village : villages)
|
||||
for(AUTO_VAR(it, villages.begin()); it != villages.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<Village> village = *it;
|
||||
float distSqr = village->getCenter()->distSqr(x, y, z);
|
||||
if (distSqr >= closestDistSqr) continue;
|
||||
std::shared_ptr<Village> Villages::getClosestVillage(int x, int y, int z,
|
||||
int maxDist) {
|
||||
std::shared_ptr<Village> closest = nullptr;
|
||||
float closestDistSqr = Float::MAX_VALUE;
|
||||
// for (Village village : villages)
|
||||
for (AUTO_VAR(it, villages.begin()); it != villages.end(); ++it) {
|
||||
std::shared_ptr<Village> village = *it;
|
||||
float distSqr = village->getCenter()->distSqr(x, y, z);
|
||||
if (distSqr >= closestDistSqr) continue;
|
||||
|
||||
float requiredDist = maxDist + village->getRadius();
|
||||
if (distSqr > requiredDist * requiredDist) continue;
|
||||
float requiredDist = maxDist + village->getRadius();
|
||||
if (distSqr > requiredDist * requiredDist) continue;
|
||||
|
||||
closest = village;
|
||||
closestDistSqr = distSqr;
|
||||
}
|
||||
return closest;
|
||||
closest = village;
|
||||
closestDistSqr = distSqr;
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
void Villages::processNextQuery()
|
||||
{
|
||||
if (queries.empty()) return;
|
||||
Pos *q = queries.front();
|
||||
queries.pop_front();
|
||||
addDoorInfos(q);
|
||||
delete q;
|
||||
void Villages::processNextQuery() {
|
||||
if (queries.empty()) return;
|
||||
Pos* q = queries.front();
|
||||
queries.pop_front();
|
||||
addDoorInfos(q);
|
||||
delete q;
|
||||
}
|
||||
|
||||
void Villages::cluster()
|
||||
{
|
||||
// note doesn't merge or split existing villages
|
||||
//for (int i = 0; i < unclustered.size(); ++i)
|
||||
for(AUTO_VAR(it, unclustered.begin()); it != unclustered.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<DoorInfo> di = *it; //unclustered.get(i);
|
||||
void Villages::cluster() {
|
||||
// note doesn't merge or split existing villages
|
||||
// for (int i = 0; i < unclustered.size(); ++i)
|
||||
for (AUTO_VAR(it, unclustered.begin()); it != unclustered.end(); ++it) {
|
||||
std::shared_ptr<DoorInfo> di = *it; // unclustered.get(i);
|
||||
|
||||
bool found = false;
|
||||
//for (Village village : villages)
|
||||
for(AUTO_VAR(itV, villages.begin()); itV != villages.end(); ++itV)
|
||||
{
|
||||
std::shared_ptr<Village> village = *itV;
|
||||
int dist = (int) village->getCenter()->distSqr(di->x, di->y, di->z);
|
||||
int radius = MaxDoorDist + village->getRadius();
|
||||
if (dist > radius * radius) continue;
|
||||
village->addDoorInfo(di);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (found) continue;
|
||||
bool found = false;
|
||||
// for (Village village : villages)
|
||||
for (AUTO_VAR(itV, villages.begin()); itV != villages.end(); ++itV) {
|
||||
std::shared_ptr<Village> village = *itV;
|
||||
int dist = (int)village->getCenter()->distSqr(di->x, di->y, di->z);
|
||||
int radius = MaxDoorDist + village->getRadius();
|
||||
if (dist > radius * radius) continue;
|
||||
village->addDoorInfo(di);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (found) continue;
|
||||
|
||||
// create new Village
|
||||
std::shared_ptr<Village> village = std::shared_ptr<Village>(new Village(level));
|
||||
village->addDoorInfo(di);
|
||||
villages.push_back(village);
|
||||
setDirty();
|
||||
}
|
||||
unclustered.clear();
|
||||
// create new Village
|
||||
std::shared_ptr<Village> village =
|
||||
std::shared_ptr<Village>(new Village(level));
|
||||
village->addDoorInfo(di);
|
||||
villages.push_back(village);
|
||||
setDirty();
|
||||
}
|
||||
unclustered.clear();
|
||||
}
|
||||
|
||||
void Villages::addDoorInfos(Pos *pos)
|
||||
{
|
||||
int scanX = 16, scanY = 4, scanZ = 16;
|
||||
for (int xx = pos->x - scanX; xx < pos->x + scanX; xx++)
|
||||
{
|
||||
for (int yy = pos->y - scanY; yy < pos->y + scanY; yy++)
|
||||
{
|
||||
for (int zz = pos->z - scanZ; zz < pos->z + scanZ; zz++)
|
||||
{
|
||||
if (isDoor(xx, yy, zz))
|
||||
{
|
||||
std::shared_ptr<DoorInfo> currentDoor = getDoorInfo(xx, yy, zz);
|
||||
if (currentDoor == NULL) createDoorInfo(xx, yy, zz);
|
||||
else currentDoor->timeStamp = _tick;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void Villages::addDoorInfos(Pos* pos) {
|
||||
int scanX = 16, scanY = 4, scanZ = 16;
|
||||
for (int xx = pos->x - scanX; xx < pos->x + scanX; xx++) {
|
||||
for (int yy = pos->y - scanY; yy < pos->y + scanY; yy++) {
|
||||
for (int zz = pos->z - scanZ; zz < pos->z + scanZ; zz++) {
|
||||
if (isDoor(xx, yy, zz)) {
|
||||
std::shared_ptr<DoorInfo> currentDoor =
|
||||
getDoorInfo(xx, yy, zz);
|
||||
if (currentDoor == NULL)
|
||||
createDoorInfo(xx, yy, zz);
|
||||
else
|
||||
currentDoor->timeStamp = _tick;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<DoorInfo> Villages::getDoorInfo(int x, int y, int z)
|
||||
{
|
||||
//for (DoorInfo di : unclustered)
|
||||
for(AUTO_VAR(it,unclustered.begin()); it != unclustered.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<DoorInfo> di = *it;
|
||||
if (di->x == x && di->z == z && abs(di->y - y) <= 1) return di;
|
||||
}
|
||||
//for (Village v : villages)
|
||||
for(AUTO_VAR(it,villages.begin()); it != villages.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<Village> v = *it;
|
||||
std::shared_ptr<DoorInfo> di = v->getDoorInfo(x, y, z);
|
||||
if (di != NULL) return di;
|
||||
}
|
||||
return nullptr;
|
||||
std::shared_ptr<DoorInfo> Villages::getDoorInfo(int x, int y, int z) {
|
||||
// for (DoorInfo di : unclustered)
|
||||
for (AUTO_VAR(it, unclustered.begin()); it != unclustered.end(); ++it) {
|
||||
std::shared_ptr<DoorInfo> di = *it;
|
||||
if (di->x == x && di->z == z && abs(di->y - y) <= 1) return di;
|
||||
}
|
||||
// for (Village v : villages)
|
||||
for (AUTO_VAR(it, villages.begin()); it != villages.end(); ++it) {
|
||||
std::shared_ptr<Village> v = *it;
|
||||
std::shared_ptr<DoorInfo> di = v->getDoorInfo(x, y, z);
|
||||
if (di != NULL) return di;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Villages::createDoorInfo(int x, int y, int z)
|
||||
{
|
||||
int dir = ((DoorTile *) Tile::door_wood)->getDir(level, x, y, z);
|
||||
if (dir == 0 || dir == 2)
|
||||
{
|
||||
int canSeeX = 0;
|
||||
for (int i = -5; i < 0; ++i)
|
||||
if (level->canSeeSky(x + i, y, z)) canSeeX--;
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
if (level->canSeeSky(x + i, y, z)) canSeeX++;
|
||||
if (canSeeX != 0) unclustered.push_back(std::shared_ptr<DoorInfo>(new DoorInfo(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick)));
|
||||
}
|
||||
else
|
||||
{
|
||||
int canSeeZ = 0;
|
||||
for (int i = -5; i < 0; ++i)
|
||||
if (level->canSeeSky(x, y, z + i)) canSeeZ--;
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
if (level->canSeeSky(x, y, z + i)) canSeeZ++;
|
||||
if (canSeeZ != 0) unclustered.push_back(std::shared_ptr<DoorInfo>(new DoorInfo(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick)));
|
||||
}
|
||||
void Villages::createDoorInfo(int x, int y, int z) {
|
||||
int dir = ((DoorTile*)Tile::door_wood)->getDir(level, x, y, z);
|
||||
if (dir == 0 || dir == 2) {
|
||||
int canSeeX = 0;
|
||||
for (int i = -5; i < 0; ++i)
|
||||
if (level->canSeeSky(x + i, y, z)) canSeeX--;
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
if (level->canSeeSky(x + i, y, z)) canSeeX++;
|
||||
if (canSeeX != 0)
|
||||
unclustered.push_back(std::shared_ptr<DoorInfo>(
|
||||
new DoorInfo(x, y, z, canSeeX > 0 ? -2 : 2, 0, _tick)));
|
||||
} else {
|
||||
int canSeeZ = 0;
|
||||
for (int i = -5; i < 0; ++i)
|
||||
if (level->canSeeSky(x, y, z + i)) canSeeZ--;
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
if (level->canSeeSky(x, y, z + i)) canSeeZ++;
|
||||
if (canSeeZ != 0)
|
||||
unclustered.push_back(std::shared_ptr<DoorInfo>(
|
||||
new DoorInfo(x, y, z, 0, canSeeZ > 0 ? -2 : 2, _tick)));
|
||||
}
|
||||
}
|
||||
|
||||
bool Villages::hasQuery(int x, int y, int z)
|
||||
{
|
||||
//for (Pos pos : queries)
|
||||
for(AUTO_VAR(it, queries.begin()); it != queries.end(); ++it)
|
||||
{
|
||||
Pos *pos = *it;
|
||||
if (pos->x == x && pos->y == y && pos->z == z) return true;
|
||||
}
|
||||
return false;
|
||||
bool Villages::hasQuery(int x, int y, int z) {
|
||||
// for (Pos pos : queries)
|
||||
for (AUTO_VAR(it, queries.begin()); it != queries.end(); ++it) {
|
||||
Pos* pos = *it;
|
||||
if (pos->x == x && pos->y == y && pos->z == z) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Villages::isDoor(int x, int y, int z)
|
||||
{
|
||||
int tileId = level->getTile(x, y, z);
|
||||
return tileId == Tile::door_wood_Id;
|
||||
bool Villages::isDoor(int x, int y, int z) {
|
||||
int tileId = level->getTile(x, y, z);
|
||||
return tileId == Tile::door_wood_Id;
|
||||
}
|
||||
|
||||
void Villages::load(CompoundTag *tag)
|
||||
{
|
||||
_tick = tag->getInt(L"Tick");
|
||||
ListTag<CompoundTag> *villageTags = (ListTag<CompoundTag> *) tag->getList(L"Villages");
|
||||
for (int i = 0; i < villageTags->size(); i++)
|
||||
{
|
||||
CompoundTag *compoundTag = villageTags->get(i);
|
||||
std::shared_ptr<Village> village = std::shared_ptr<Village>(new Village());
|
||||
village->readAdditionalSaveData(compoundTag);
|
||||
villages.push_back(village);
|
||||
}
|
||||
void Villages::load(CompoundTag* tag) {
|
||||
_tick = tag->getInt(L"Tick");
|
||||
ListTag<CompoundTag>* villageTags =
|
||||
(ListTag<CompoundTag>*)tag->getList(L"Villages");
|
||||
for (int i = 0; i < villageTags->size(); i++) {
|
||||
CompoundTag* compoundTag = villageTags->get(i);
|
||||
std::shared_ptr<Village> village =
|
||||
std::shared_ptr<Village>(new Village());
|
||||
village->readAdditionalSaveData(compoundTag);
|
||||
villages.push_back(village);
|
||||
}
|
||||
}
|
||||
|
||||
void Villages::save(CompoundTag *tag)
|
||||
{
|
||||
tag->putInt(L"Tick", _tick);
|
||||
ListTag<CompoundTag> *villageTags = new ListTag<CompoundTag>(L"Villages");
|
||||
//for (Village village : villages)
|
||||
for(AUTO_VAR(it, villages.begin()); it != villages.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<Village> village = *it;
|
||||
CompoundTag *villageTag = new CompoundTag(L"Village");
|
||||
village->addAdditonalSaveData(villageTag);
|
||||
villageTags->add(villageTag);
|
||||
}
|
||||
tag->put(L"Villages", villageTags);
|
||||
void Villages::save(CompoundTag* tag) {
|
||||
tag->putInt(L"Tick", _tick);
|
||||
ListTag<CompoundTag>* villageTags = new ListTag<CompoundTag>(L"Villages");
|
||||
// for (Village village : villages)
|
||||
for (AUTO_VAR(it, villages.begin()); it != villages.end(); ++it) {
|
||||
std::shared_ptr<Village> village = *it;
|
||||
CompoundTag* villageTag = new CompoundTag(L"Village");
|
||||
village->addAdditonalSaveData(villageTag);
|
||||
villageTags->add(villageTag);
|
||||
}
|
||||
tag->put(L"Villages", villageTags);
|
||||
}
|
||||
@@ -2,46 +2,46 @@
|
||||
|
||||
#include "../../Level/Storage/SavedData.h"
|
||||
|
||||
class Villages : public SavedData
|
||||
{
|
||||
class Villages : public SavedData {
|
||||
public:
|
||||
static const std::wstring VILLAGE_FILE_ID;
|
||||
static const std::wstring VILLAGE_FILE_ID;
|
||||
|
||||
static const int MaxDoorDist = 32;
|
||||
static const int MaxDoorDist = 32;
|
||||
|
||||
private:
|
||||
Level *level;
|
||||
std::deque<Pos *> queries;
|
||||
std::vector<std::shared_ptr<DoorInfo> > unclustered;
|
||||
std::vector<std::shared_ptr<Village> > villages;
|
||||
int _tick;
|
||||
Level* level;
|
||||
std::deque<Pos*> queries;
|
||||
std::vector<std::shared_ptr<DoorInfo> > unclustered;
|
||||
std::vector<std::shared_ptr<Village> > villages;
|
||||
int _tick;
|
||||
|
||||
public:
|
||||
Villages(const std::wstring &id);
|
||||
Villages(Level *level);
|
||||
~Villages();
|
||||
Villages(const std::wstring& id);
|
||||
Villages(Level* level);
|
||||
~Villages();
|
||||
|
||||
void setLevel(Level *level);
|
||||
void queryUpdateAround(int x, int y, int z);
|
||||
void tick();
|
||||
void setLevel(Level* level);
|
||||
void queryUpdateAround(int x, int y, int z);
|
||||
void tick();
|
||||
|
||||
private:
|
||||
void removeVillages();
|
||||
void removeVillages();
|
||||
|
||||
public:
|
||||
std::vector<std::shared_ptr<Village> > *getVillages();
|
||||
std::shared_ptr<Village> getClosestVillage(int x, int y, int z, int maxDist);
|
||||
std::vector<std::shared_ptr<Village> >* getVillages();
|
||||
std::shared_ptr<Village> getClosestVillage(int x, int y, int z,
|
||||
int maxDist);
|
||||
|
||||
private:
|
||||
void processNextQuery();
|
||||
void cluster();
|
||||
void addDoorInfos(Pos *pos);
|
||||
std::shared_ptr<DoorInfo>getDoorInfo(int x, int y, int z);
|
||||
void createDoorInfo(int x, int y, int z);
|
||||
bool hasQuery(int x, int y, int z);
|
||||
bool isDoor(int x, int y, int z);
|
||||
void processNextQuery();
|
||||
void cluster();
|
||||
void addDoorInfos(Pos* pos);
|
||||
std::shared_ptr<DoorInfo> getDoorInfo(int x, int y, int z);
|
||||
void createDoorInfo(int x, int y, int z);
|
||||
bool hasQuery(int x, int y, int z);
|
||||
bool isDoor(int x, int y, int z);
|
||||
|
||||
public:
|
||||
void load(CompoundTag *tag);
|
||||
void save(CompoundTag *tag);
|
||||
void load(CompoundTag* tag);
|
||||
void save(CompoundTag* tag);
|
||||
};
|
||||
Reference in New Issue
Block a user