10 #include "../IniFile.h"
46 LOGWARNING(
"PieceStructures generator: File %s is intended for use in \"%s\", rather than piece structures. Loading the file, but the generator may behave unexpectedly.",
68 return std::make_shared<cPrefabStructure>(a_GridX, a_GridZ, a_OriginX, a_OriginZ, std::move(OutPieces),
m_HeightGen);
136 for (
const auto & Structure : Structures)
138 auto FileName = fmt::format(FMT_STRING(
"Prefabs{0}PieceStructures{0}{1}.cubeset"),
cFile::PathSeparator(), Structure);
141 FileName.append(
".gz");
144 LOGWARNING(
"Cannot load PieceStructures cubeset file %s", FileName);
148 auto Gen = std::make_shared<cGen>(
m_Seed, a_BiomeGen, a_HeightGen, a_SeaLevel, Structure);
149 if (Gen->LoadFromFile(FileName))
158 LOGWARNING(
"The PieceStructures generator was asked to generate \"%s\", but none of the prefabs are valid.", a_Prefabs);
172 Gen->GenFinish(a_Chunk);
std::vector< cPlacedPiecePtr > cPlacedPieces
void LOGWARNING(std::string_view a_Format, const Args &... args)
AStringVector StringSplitAndTrim(const AString &str, const AString &delim)
Split the string at any of the listed delimiters and trim each value.
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
The interface that a biome generator must implement A biome generator takes chunk coords on input and...
The interface that is used to query terrain height from the shape generator.
Generates structures in a semi-random grid.
std::shared_ptr< cStructure > cStructurePtr
cGridStructGen(int a_Seed, int a_GridSizeX, int a_GridSizeZ, int a_MaxOffsetX, int a_MaxOffsetZ, int a_MaxStructureSizeX, int a_MaxStructureSizeZ, size_t a_MaxCacheSize)
int m_Seed
Seed for generating grid offsets and also available for descendants.
void SetGeneratorParams(const AStringMap &a_GeneratorParams)
Sets the generator params based on the dictionary passed in.
void PlacePieces(int a_BlockX, int a_BlockZ, int a_MaxDepth, cPlacedPieces &a_OutPieces)
Generates a placement for pieces at the specified coords.
Represents a single piece.
Represents a single piece that has been placed to specific coords in the world.
cBiomeGen & m_BiomeGen
The underlying biome generator that defines whether the structure is created or not.
std::vector< cFreeConnector > cFreeConnectors
AString m_Name
The name that is used for reporting.
cGen(int a_Seed, cBiomeGen &a_BiomeGen, cTerrainHeightGen &a_HeightGen, int a_SeaLevel, const AString &a_Name)
int m_MaxDepth
Maximum depth of the generated piece tree.
cPrefabPiecePool m_PiecePool
All available prefabs.
cTerrainHeightGen & m_HeightGen
The underlying height generator, used to position the prefabs crossing chunk borders if they are set ...
std::vector< cConnection > cConnections
virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override
Create a new structure at the specified gridpoint.
bool LoadFromFile(const AString &a_FileName)
Loads the piecepool from a file.
int m_SeaLevel
The world's sea level, if available.
The type used for storing a connection from one piece to another, while building the piece tree.
cPiece::cConnector m_Connector
cConnection(cPiece &a_Piece, cPiece::cConnector &a_Connector, int a_NumCCWRotations, int a_Weight)
The type used for storing a pool of connectors that will be attempted to expand by another piece.
cPiece::cConnector m_Connector
cFreeConnector(cPlacedPiece *a_Piece, const cPiece::cConnector &a_Connector)
int m_Seed
The seed for the random number generator.
cPieceStructuresGen(int a_Seed)
cGenPtrs m_Gens
The individual structure generators, one per piecepool.
virtual void GenFinish(cChunkDesc &a_ChunkDesc) override
bool Initialize(const AString &a_Prefabs, int a_SeaLevel, cBiomeGen &a_BiomeGen, cTerrainHeightGen &a_HeightGen)
Initializes the generator based on the specified prefab sets.
bool LoadFromFile(const AString &a_FileName, bool a_LogWarnings)
Loads the pieces from the specified file.
const AStringMap & GetAllMetadata(void) const
void AssignGens(int a_Seed, cBiomeGen &a_BiomeGen, cTerrainHeightGen &a_HeightGen, int a_SeaLevel)
Called when the piece pool is assigned to a generator, so that the individual starting pieces' vertic...
const AString & GetIntendedUse(void) const
static char PathSeparator()
static bool IsFile(const AString &a_Path)
Returns true if the specified path is a regular file.