Пример #1
0
void GeneratorData::PlaceRoom( RoomDesc const& roomDesc, glm::vec2 pos )
{
    for (int32_t ry = 0; ry < roomDesc.GetCellCount(); ++ry)
    {
        for (int32_t rx = 0; rx < roomDesc.GetCellCount(); ++rx)
        {
            glm::vec2 relPos = glm::vec2( rx, ry );
            glm::vec2 targetPos = pos + relPos;
            if (IsInBounds( targetPos )
                && roomDesc.IsFilled( relPos )
                && !IsFilled( targetPos ))
            {
                auto& cell = GetGCell( targetPos );
                cell.mFilled = true;
                cell.mGRoomDescIndex = mGRoomDescs.size();
                L1( "%d,%d is now filled %d\n", targetPos.x, targetPos.y, cell.mFilled );
            }
        }
    }
    GRoomDesc gRoomDesc;
    gRoomDesc.mRoomCoord = pos;
    gRoomDesc.mRoomDesc = roomDesc;
    gRoomDesc.mRoomDesc.ClearProperties();
    gRoomDesc.mRoomDesc.ClearCellEntrances();
    mGRoomDescs.push_back( gRoomDesc );
    GenerateGraph();
}
Пример #2
0
bool GeneratorData::CanPlaceRoom( RoomDesc const& roomDesc, glm::vec2 pos ) const
{
    for (int32_t ry = 0; ry < roomDesc.GetCellCount(); ++ry)
    {
        for (int32_t rx = 0; rx < roomDesc.GetCellCount(); ++rx)
        {
            glm::vec2 relPos = glm::vec2( rx, ry );
            glm::vec2 targetPos = pos + relPos;
            if (roomDesc.IsFilled( relPos ))
            {
                if (!IsInBounds( targetPos ))
                {
                    L1( "%d,%d is out of bounds\n", targetPos.x, targetPos.y );
                    return false; //cell is out of bounds
                }
                if (IsFilled( targetPos ))
                {
                    L1( "%d,%d is already filled %d\n", targetPos.x, targetPos.x, IsFilled( targetPos ) );
                    return false; //cell is already filled this room cant be placed
                }
            }
        }
    }
    return true;
}
Пример #3
0
bool CColPolygon::DoHitDetection  ( const CVector& vecLastPosition, const CVector& vecNowPosition, float fRadius )
{
    if ( !IsInBounds ( vecNowPosition ) )
        return false;

    bool collides = false;

    int j = m_Points.size() - 1;

    float x = vecNowPosition.fX;
    float y = vecNowPosition.fY;

    for ( unsigned int i = 0; i < m_Points.size(); i++ )
    {
        CVector2D vecPi = m_Points[i];
        CVector2D vecPj = m_Points[j];

        if ( (vecPi.fY < y && vecPj.fY >= y) || (vecPj.fY < y && vecPi.fY >= y) )
        {
            if ( vecPi.fX + ( y - vecPi.fY ) / ( vecPj.fY - vecPi.fY ) * ( vecPj.fX - vecPi.fX ) < x )
            {
                collides = !collides;
            }
        }

        j = i;
    }

    return collides;
}
Пример #4
0
void GeneratorData::AddCellPair( CellPairs_t& cellPairs, glm::vec2 posA, glm::vec2 posB, int32_t room ) const
{
    if (IsInBounds( posB )
        && IsRoomIdentical( posB, room ))
    {
        cellPairs.push_back( CellPair_t( posA, posB ) );
    }
}
Пример #5
0
void IRoom::AddNeighbourCell( glm::vec2 pos )
{
    if (std::find( mNeighbourCells.begin(), mNeighbourCells.end(), pos ) == mNeighbourCells.end()
        && (!IsInBounds(pos) || !mRoomDesc.IsFilled(pos)))
    {
        mNeighbourCells.push_back( pos );
    }

}
Пример #6
0
 void InitializeAI() override
 {
     npc_anubarak_pet_template::InitializeAI();
     CreatureBoundary const* boundary = _instance->GetBossBoundary(DATA_ANUBARAK);
     if (Creature* anubarak = _instance->GetCreature(DATA_ANUBARAK))
     {
         Position jumpTo;
         do
             jumpTo = GetRandomPositionAround(anubarak);
         while (!IsInBounds(jumpTo, boundary));
         me->GetMotionMaster()->MoveJump(jumpTo, 40.0f, 40.0f);
         DoCastSelf(SPELL_ASSASSIN_VISUAL, true);
     }
 }
Пример #7
0
NeighbourRooms_t GeneratorData::GetNeighbourRooms( int32_t roomIndex )
{
    NeighbourRooms_t r;
    auto& roomDesc = mGRoomDescs[roomIndex];
    for (auto& n : GetRoom( roomIndex )->GetNeighbourCells())
    {
        glm::vec2 pos = GetRoomCoord(roomIndex) + n;
        if (IsInBounds( pos ))
        {
            int32_t roomIndex = GetGCell( pos ).mGRoomDescIndex;
            if (std::find( r.begin(), r.end(), roomIndex ) == r.end())
            {
                r.push_back( roomIndex );
            }
        }
    }
    return r;
}
Пример #8
0
// Double version
_inline double GetDoubleAltVal(LPRO object, int ValNum)
{
	if (!IsInBounds(ValNum,0,25))
		return 0;

	// Build 242 or below
//	if (object->rov.rvValuesType[ValNum] == 0)			// Is integer alterable value
//		return (float)object->rov.rvValues[ValNum];	// Convert to float and return
//	if (object->rov.rvValuesType[ValNum] == 2)			// Is float alterable value
//		return *((float*)&object->rov.rvValues[ValNum]);	// Return that float

	// Build 243 or above
	CValue* pValue = &object->rov.rvpValues[ValNum];
	if ( pValue->m_type == TYPE_INT )					// Is integer alterable value
		return (double)pValue->m_long;
	if ( pValue->m_type == TYPE_DOUBLE )
		return pValue->m_double;

	return 0; // should be impossible
}
Пример #9
0
 inline bool IsInBounds(int x, int y) const {
   return IsInBounds(mWidth * y + x);
 }