Exemple #1
0
void ETHBucketManager::GetIntersectingEntities(const Vector2 &point, ETHEntityArray &outVector, const bool screenSpace, const ETHSceneProperties& props)
{
    ETHEntityArray temp;
    const Vector2 v2Bucket(ETHBucketManager::GetBucket(point, GetBucketSize()));
    GetEntitiesAroundBucket(v2Bucket, temp);

    for (unsigned int t=0; t<temp.size(); t++)
    {
        ETHEntityProperties::VIEW_RECT rect = temp[t]->GetScreenRect(props);

        if (!screenSpace)
        {
            const Vector2 cameraPos = m_provider->GetVideo()->GetCameraPos();
            rect.max += cameraPos;
            rect.min += cameraPos;
        }

        if (point.x < rect.min.x)
            continue;
        if (point.y < rect.min.y)
            continue;
        if (point.x > rect.max.x)
            continue;
        if (point.y > rect.max.y)
            continue;
        outVector.push_back(temp[t]);
    }
}
Exemple #2
0
void ETHBucketManager::GetVisibleEntities(ETHEntityArray &outVector)
{
    std::list<Vector2> bucketList;
    GetIntersectingBuckets(bucketList, m_provider->GetVideo()->GetCameraPos(),
                           m_provider->GetVideo()->GetScreenSizeF(), IsDrawingBorderBuckets(), IsDrawingBorderBuckets());

    // Loop through all visible Buckets
    for (std::list<Vector2>::iterator bucketPositionIter = bucketList.begin();
            bucketPositionIter != bucketList.end(); ++bucketPositionIter)
    {
        ETHBucketMap::const_iterator bucketIter = Find(*bucketPositionIter);

        if (bucketIter == GetLastBucket())
            continue;

        const ETHEntityList& entityList = bucketIter->second;
        if (entityList.empty())
            continue;

        ETHEntityList::const_iterator iEnd = entityList.end();
        for (ETHEntityList::const_iterator iter = entityList.begin(); iter != iEnd; ++iter)
        {
            outVector.push_back(*iter);
        }
    }
}
Exemple #3
0
void ETHBucketManager::GetEntityArray(ETHEntityArray &outVector)
{
    for (ETHBucketMap::iterator bucketIter = GetFirstBucket(); bucketIter != GetLastBucket(); ++bucketIter)
    {
        ETHEntityList& entityList = bucketIter->second;
        ETHEntityList::const_iterator iEnd = entityList.end();
        for (ETHEntityList::iterator iter = entityList.begin(); iter != iEnd; ++iter)
        {
            outVector.push_back(*iter);
        }
    }
}
Exemple #4
0
void ETHBucketManager::GetEntityArrayFromBucket(const Vector2 &bucket, ETHEntityArray &outVector, const ETHEntityChooser& chooser)
{
    ETHBucketMap::iterator bucketIter = Find(bucket);
    if (bucketIter == GetLastBucket())
        return;

    ETHEntityList& entityList = bucketIter->second;
    ETHEntityList::const_iterator iEnd = entityList.end();
    for (ETHEntityList::iterator iter = entityList.begin(); iter != iEnd; ++iter)
    {
        if (chooser.Choose(*iter))
            outVector.push_back(*iter);
    }
}
Exemple #5
0
void ETHBucketManager::GetEntityArrayByName(const str_type::string& name, ETHEntityArray &outVector)
{
    for (ETHBucketMap::iterator bucketIter = GetFirstBucket(); bucketIter != GetLastBucket(); ++bucketIter)
    {
        ETHEntityList& entityList = bucketIter->second;
        ETHEntityList::const_iterator iEnd = entityList.end();
        for (ETHEntityList::iterator iter = entityList.begin(); iter != iEnd; ++iter)
        {
            ETHSpriteEntity *pEntity = *iter;
            if (pEntity->GetEntityName() == name)
            {
                outVector.push_back(pEntity);
            }
        }
    }
}