8 #include "../BlockInfo.h"
9 #include "../FastRandom.h"
10 #include "../BlockEntities/ChestEntity.h"
11 #include "../BlockEntities/MobSpawnerEntity.h"
35 int a_GridX,
int a_GridZ,
36 int a_OriginX,
int a_OriginZ,
37 int a_HalfSizeX,
int a_HalfSizeZ,
41 Super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
43 m_EndX(a_OriginX + a_HalfSizeX),
45 m_EndZ(a_OriginZ + a_HalfSizeZ),
56 int NumPositions = 2 * SizeX + 2 * SizeZ;
57 int FirstChestPos = rnd % NumPositions;
59 int SecondChestPos = (FirstChestPos + 2 + (rnd % (NumPositions - 3))) % NumPositions;
70 else if (MobType <= 50)
105 if (a_PosIdx < a_SizeX)
111 if (a_PosIdx < a_SizeZ)
117 if (a_PosIdx < a_SizeX)
139 for (
int y = a_StartY; y < a_EndY; y++)
141 for (
int z = RelStartZ; z < RelEndZ; z++)
143 for (
int x = RelStartX; x < RelEndX; x++)
167 for (
int y = a_StartY; y < a_EndY; y++)
169 for (
int z = RelStartZ; z < RelEndZ; z++)
171 for (
int x = RelStartX; x < RelEndX; x++)
231 int NumSlots = 3 + ((Noise.
IntNoise3DInt(a_Chest.
x, a_Chest.
y, a_Chest.
z) / 11) % 4);
291 Super(a_Seed + 100, a_GridSize, a_GridSize, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 1024),
292 m_ShapeGen(a_ShapeGen),
293 m_MaxHalfSize((a_MaxSize + 1) / 2),
294 m_MinHalfSize((a_MinSize + 1) / 2),
322 int RelX = a_OriginX, RelY = 0, RelZ = a_OriginZ;
327 int idx = RelX * 256 + RelZ * 16 * 256;
330 if (shape[idx + y] != 0)
@ E_BLOCK_MOSSY_COBBLESTONE
@ E_ITEM_IRON_HORSE_ARMOR
@ E_ITEM_GOLD_HORSE_ARMOR
@ E_ITEM_DIAMOND_HORSE_ARMOR
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
static const int ROOM_HEIGHT
Height, in blocks, of the internal dungeon room open space.
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
T Clamp(T a_Value, T a_Min, T a_Max)
Clamp X to the specified range.
eMonsterType
Identifies individual monster type.
BLOCKTYPE GetBlockType() const
cItemGrid & GetContents(void)
Returns the ItemGrid used for storing the contents.
void SetEntity(eMonsterType a_EntityType)
static bool CanBeTerraformed(BLOCKTYPE Block)
Can a finisher change it?
Constants used throughout the code, useful typedefs and utility functions.
static void AbsoluteToRelative(int &a_X, int &a_Y, int &a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords into relative (chunk + block) coords:
cBlockEntity * GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ)
Returns the block entity at the specified coords.
void SetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
Byte Shape[256 *16 *16]
The datatype used to represent the entire chunk worth of shape.
void SetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
BLOCKTYPE GetBlockType(int a_RelX, int a_RelY, int a_RelZ) const
The interface that a terrain shape generator must implement A terrain shape generator takes chunk coo...
virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape &a_Shape)=0
Generates the shape for the given chunk.
Vector3i m_Chest1
The (absolute) coords of the first chest.
virtual void DrawIntoChunk(cChunkDesc &a_ChunkDesc) override
Draws self into the specified chunk.
void ReplaceCuboid(cChunkDesc &a_ChunkDesc, int a_StartX, int a_StartY, int a_StartZ, int a_EndX, int a_EndY, int a_EndZ, BLOCKTYPE a_DstBlockType)
Fills the specified area of blocks in the chunk with the specified blocktype if they are one of the o...
eMonsterType m_MonsterType
The monster type for the mobspawner entity.
Vector3i DecodeChestCoords(int a_PosIdx, int a_SizeX, int a_SizeZ)
Decodes the position index along the room walls into a proper 2D position for a chest.
int m_FloorHeight
The Y coord of the floor of the room.
cDungeonRoom(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_HalfSizeX, int a_HalfSizeZ, int a_FloorHeight, cNoise &a_Noise)
void ReplaceCuboidRandom(cChunkDesc &a_ChunkDesc, int a_StartX, int a_StartY, int a_StartZ, int a_EndX, int a_EndY, int a_EndZ, BLOCKTYPE a_DstBlockType1, BLOCKTYPE a_DstBlockType2)
Fills the specified area of blocks in the chunk with a random pattern of the specified blocktypes,...
Vector3i m_Chest2
The (absolute) coords of the second chest.
void TryPlaceChest(cChunkDesc &a_ChunkDesc, const Vector3i &a_Chest)
Tries to place a chest at the specified (absolute) coords.
virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override
Create a new structure at the specified gridpoint.
cProbabDistrib m_HeightProbability
The height probability distribution to make the spawners more common in layers 10 - 40,...
cDungeonRoomsFinisher(cTerrainShapeGen &a_ShapeGen, int a_Seed, int a_GridSize, int a_MaxSize, int a_MinSize, const AString &a_HeightDistrib)
Creates a new dungeon room finisher.
cTerrainShapeGen & m_ShapeGen
The shape gen that is used for limiting the rooms' Y coords.
int m_MaxHalfSize
Maximum half-size (from center to wall) of the dungeon room's inner (air) area.
int m_MinHalfSize
Minimum half-size (from center to wall) of the dungeon room's inner (air) area.
Generates structures in a semi-random grid.
std::shared_ptr< cStructure > cStructurePtr
cNoise m_Noise
The noise used for generating grid offsets.
Represents a single structure that occupies the grid point.
Used to store loot probability tables.
void GenerateRandomLootWithBooks(const cLootProbab *a_LootProbabs, size_t a_CountLootProbabs, int a_NumSlots, int a_Seed)
Generates random loot from the specified loot probability table, with a chance of enchanted books add...
int IntNoise3DInt(int a_X, int a_Y, int a_Z) const
int IntNoise2DInt(int a_X, int a_Y) const
bool SetDefString(const AString &a_DefString)
Sets the distribution curve using a definition string; returns true on successful parse.
int MapValue(int a_OrigValue) const
Maps value in range [0, m_Sum] into the range [0, m_MaxValue] using the stored probability.