Beispiel #1
0
IASW_Room_Details *CRoom::GetAdjacentRoom( int nExit )
{
	int nExitX, nExitY;
	if ( GetExitPosition( m_pRoomTemplate, m_iPosX, m_iPosY, nExit, &nExitX, &nExitY ) )
	{
		return m_pMapLayout->GetRoom( nExitX, nExitY );
	}

	return NULL;
}
Beispiel #2
0
void BuildOpenExitList( const CRoomCandidate &roomCandidate, const CMapLayout *pMapLayout, CUtlVector< CExit > *pNewExitList )
{
    Assert( pMapLayout );
    const CRoomTemplate *pTemplate = roomCandidate.m_pRoomTemplate;
    for ( int i = 0; i < pTemplate->m_Exits.Count(); ++ i )
    {
        int nExitX, nExitY;
        if ( GetExitPosition( pTemplate, roomCandidate.m_iXPos, roomCandidate.m_iYPos, i, &nExitX, &nExitY ) )
        {
            if ( !pMapLayout->GetRoom( nExitX, nExitY ) )
            {
                pNewExitList->AddToTail( CExit( nExitX, nExitY, pTemplate->m_Exits[i]->m_ExitDirection, pTemplate->m_Exits[i]->m_szExitTag, NULL, false ) );
            }
        }
    }
}
// This function adds an open exit for every un-mated exit in the given room.
// The exits are added to the grid tile where a new room would connect
// (e.g., a north exit from a room tile at (x, y) is actually added to location (x, y+1)
void CLayoutSystem::AddOpenExitsFromRoom( CRoom *pRoom )
{
	const CRoomTemplate *pTemplate = pRoom->m_pRoomTemplate;

	// Go through each exit in the room.
	for ( int i = 0; i < pTemplate->m_Exits.Count(); ++ i )
	{
		const CRoomTemplateExit *pExit = pTemplate->m_Exits[i];
		int nExitX, nExitY;
		if ( GetExitPosition( pTemplate, pRoom->m_iPosX, pRoom->m_iPosY, i, &nExitX, &nExitY ) )
		{
			// If no room exists where the exit interface goes, then consider the exit open.
			// NOTE: this function assumes that the caller has already verified that the template fits, which means
			// that if a room exists where this exit goes, it must be a matching exit (and thus not open).
			if ( !m_pMapLayout->GetRoom( nExitX, nExitY ) )
			{
				AddOpenExit( pRoom, nExitX, nExitY, pExit->m_ExitDirection, pExit->m_szExitTag, pExit->m_bChokepointGrowSource );
			}
		}
	}
}