Changed village road generation to use multiple prefabs.
This commit is contained in:
parent
f5fdbdaf29
commit
34e5f0c164
@ -3691,10 +3691,10 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] =
|
|||||||
/* 3 */ "bbbb",
|
/* 3 */ "bbbb",
|
||||||
|
|
||||||
// Connectors:
|
// Connectors:
|
||||||
"1: 1, 9, 3: 3\n" /* Type 1, direction Z+ */
|
"2: 1, 9, 3: 3\n" /* Type 2, direction Z+ */
|
||||||
"1: 2, 9, 0: 2\n" /* Type 1, direction Z- */
|
"2: 2, 9, 0: 2\n" /* Type 2, direction Z- */
|
||||||
"1: 0, 9, 1: 4\n" /* Type 1, direction X- */
|
"2: 0, 9, 1: 4\n" /* Type 2, direction X- */
|
||||||
"1: 3, 9, 2: 5\n" /* Type 1, direction X+ */,
|
"2: 3, 9, 2: 5\n" /* Type 2, direction X+ */,
|
||||||
|
|
||||||
// AllowedRotations:
|
// AllowedRotations:
|
||||||
7, /* 1, 2, 3 CCW rotation allowed */
|
7, /* 1, 2, 3 CCW rotation allowed */
|
||||||
|
@ -1853,10 +1853,10 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] =
|
|||||||
/* 3 */ "bbbb",
|
/* 3 */ "bbbb",
|
||||||
|
|
||||||
// Connectors:
|
// Connectors:
|
||||||
"1: 2, 8, 0: 2\n" /* Type 1, direction Z- */
|
"2: 2, 8, 0: 2\n" /* Type 2, direction Z- */
|
||||||
"1: 0, 8, 1: 4\n" /* Type 1, direction X- */
|
"2: 0, 8, 1: 4\n" /* Type 2, direction X- */
|
||||||
"1: 1, 8, 3: 3\n" /* Type 1, direction Z+ */
|
"2: 1, 8, 3: 3\n" /* Type 2, direction Z+ */
|
||||||
"1: 3, 8, 2: 5\n" /* Type 1, direction X+ */,
|
"2: 3, 8, 2: 5\n" /* Type 2, direction X+ */,
|
||||||
|
|
||||||
// AllowedRotations:
|
// AllowedRotations:
|
||||||
7, /* 1, 2, 3 CCW rotation allowed */
|
7, /* 1, 2, 3 CCW rotation allowed */
|
||||||
|
@ -44,43 +44,42 @@ public:
|
|||||||
) :
|
) :
|
||||||
super(a_PieceDefs, a_NumPieceDefs, a_StartingPieceDefs, a_NumStartingPieceDefs)
|
super(a_PieceDefs, a_NumPieceDefs, a_StartingPieceDefs, a_NumStartingPieceDefs)
|
||||||
{
|
{
|
||||||
// Add the road piece:
|
// Add the road pieces:
|
||||||
cBlockArea BA;
|
for (int len = 19; len < 60; len += 8)
|
||||||
BA.Create(5, 1, 3, cBlockArea::baTypes | cBlockArea::baMetas);
|
{
|
||||||
BA.Fill(cBlockArea::baTypes | cBlockArea::baMetas, E_BLOCK_GRAVEL, 0);
|
cBlockArea BA;
|
||||||
cPrefab * RoadPiece = new cPrefab(BA, 7);
|
BA.Create(len, 1, 3, cBlockArea::baTypes | cBlockArea::baMetas);
|
||||||
RoadPiece->AddConnector(0, 0, 1, BLOCK_FACE_XM, -1);
|
BA.Fill(cBlockArea::baTypes | cBlockArea::baMetas, E_BLOCK_GRAVEL, 0);
|
||||||
RoadPiece->AddConnector(4, 0, 1, BLOCK_FACE_XP, -1);
|
cPrefab * RoadPiece = new cPrefab(BA, 1);
|
||||||
RoadPiece->AddConnector(4, 0, 1, BLOCK_FACE_XP, 1);
|
RoadPiece->AddConnector(0, 0, 1, BLOCK_FACE_XM, -2);
|
||||||
RoadPiece->AddConnector(1, 0, 0, BLOCK_FACE_ZM, 1);
|
RoadPiece->AddConnector(len - 1, 0, 1, BLOCK_FACE_XP, -2);
|
||||||
RoadPiece->AddConnector(3, 0, 0, BLOCK_FACE_ZM, 1);
|
|
||||||
RoadPiece->AddConnector(1, 0, 2, BLOCK_FACE_ZP, 1);
|
// Add the road connectors:
|
||||||
RoadPiece->AddConnector(3, 0, 2, BLOCK_FACE_ZP, 1);
|
for (int x = 1; x < len; x += 8)
|
||||||
RoadPiece->SetAddWeightIfSame(10000);
|
{
|
||||||
m_AllPieces.push_back(RoadPiece);
|
RoadPiece->AddConnector(x, 0, 0, BLOCK_FACE_ZM, 2);
|
||||||
m_PiecesByConnector[-1].push_back(RoadPiece);
|
RoadPiece->AddConnector(x, 0, 2, BLOCK_FACE_ZP, 2);
|
||||||
m_PiecesByConnector[1].push_back(RoadPiece);
|
}
|
||||||
|
|
||||||
|
// Add the buildings connectors:
|
||||||
|
for (int x = 5; x < len; x += 8)
|
||||||
|
{
|
||||||
|
RoadPiece->AddConnector(x, 0, 0, BLOCK_FACE_ZM, 1);
|
||||||
|
RoadPiece->AddConnector(x, 0, 2, BLOCK_FACE_ZP, 1);
|
||||||
|
}
|
||||||
|
m_AllPieces.push_back(RoadPiece);
|
||||||
|
m_PiecesByConnector[-2].push_back(RoadPiece);
|
||||||
|
m_PiecesByConnector[1].push_back(RoadPiece);
|
||||||
|
m_PiecesByConnector[2].push_back(RoadPiece);
|
||||||
|
} // for len - roads of varying length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// cPrefabPiecePool overrides:
|
// cPrefabPiecePool overrides:
|
||||||
virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override
|
virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override
|
||||||
{
|
{
|
||||||
// Only roads are allowed to connect to the well:
|
// Roads cannot branch T-wise (appending -2 connector to a +2 connector):
|
||||||
if ((a_PlacedPiece.GetDepth() == 0) && (a_NewPiece.GetSize().y != 1))
|
if ((a_ExistingConnector.m_Type == 2) && (a_PlacedPiece.GetDepth() > 0))
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Roads cannot branch T-wise:
|
|
||||||
if (
|
|
||||||
(a_PlacedPiece.GetPiece().GetSize().y == 1) && // Connecting to a road
|
|
||||||
(
|
|
||||||
(a_ExistingConnector.m_Direction == BLOCK_FACE_ZP) ||
|
|
||||||
(a_ExistingConnector.m_Direction == BLOCK_FACE_ZM)
|
|
||||||
) && // Through the long-edge connector
|
|
||||||
(a_NewPiece.GetSize().y == 1) // And the new piece is a road
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user