Exemple #1
0
	// cPrefabPiecePool overrides:
	virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override
	{
		// Roads cannot branch T-wise (appending -2 connector to a +2 connector on a 1-high piece):
		if ((a_ExistingConnector.m_Type == 2) && (a_PlacedPiece.GetDepth() > 0) && (a_PlacedPiece.GetPiece().GetSize().y == 1))
		{
			return 0;
		}
		
		return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector);
	}
Exemple #2
0
int cPrefab::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector) const
{
	// Use the default or per-depth weight:
	cDepthWeight::const_iterator itr = m_DepthWeight.find(a_PlacedPiece.GetDepth() + 1);
	int res = (itr == m_DepthWeight.end()) ? m_DefaultWeight : itr->second;
	
	// If the piece is the same as the parent, apply the m_AddWeightIfSame modifier:
	const cPiece * ParentPiece = &a_PlacedPiece.GetPiece();
	const cPiece * ThisPiece = this;
	if (ThisPiece == ParentPiece)
	{
		res += m_AddWeightIfSame;
	}
	return res;
}