当前位置: 首页>>代码示例>>C++>>正文


C++ Memory::GetSector方法代码示例

本文整理汇总了C++中Memory::GetSector方法的典型用法代码示例。如果您正苦于以下问题:C++ Memory::GetSector方法的具体用法?C++ Memory::GetSector怎么用?C++ Memory::GetSector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memory的用法示例。


在下文中一共展示了Memory::GetSector方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindRandomMemory

Tribe::Memory* Tribe::FindRandomMemory(const char* name, const csVector3 &pos, const iSector* sector, float range, float* foundRange)
{
    csArray<Memory*> nearby;
    csArray<float> dist;

    float minRange = range*range;    // Working with Squared values
    if(range == -1) minRange = -1;   // -1*-1 = 1, will use -1 later

    csList<Memory*>::Iterator it(memories);
    while(it.HasNext())
    {
        Memory* memory = it.Next();

        if(memory->name == name && memory->npc == NULL)
        {
            float dist2 = npcclient->GetWorld()->Distance(pos,sector,memory->pos,memory->GetSector());

            if(minRange < 0 || dist2 < minRange)
            {
                nearby.Push(memory);
                dist.Push(dist2);
            }
        }
    }

    if(nearby.GetSize()>0)   // found one or more closer than range
    {
        size_t pick = psGetRandom((uint32)nearby.GetSize());

        if(foundRange) *foundRange = sqrt(dist[pick]);

        return nearby[pick];
    }
    return NULL;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例2: FindNearestMemory

Tribe::Memory* Tribe::FindNearestMemory(const char* name, const csVector3 &pos, const iSector* sector, float range, float* foundRange)
{
    Memory* nearest = NULL;

    float minRange = range*range;    // Working with Squared values
    if(range == -1) minRange = -1;   // -1*-1 = 1, will use -1 later

    csList<Memory*>::Iterator it(memories);
    while(it.HasNext())
    {
        Memory* memory = it.Next();

        if(memory->name == name && memory->npc == NULL)
        {
            float dist2 = npcclient->GetWorld()->Distance(pos,sector,memory->pos,memory->GetSector());

            if(minRange < 0 || dist2 < minRange)
            {
                minRange = dist2;
                nearest = memory;
            }
        }
    }

    if(nearest && foundRange)   // found closest one
    {
        *foundRange = sqrt(minRange);
    }

    return nearest;
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例3: FindMemory

Tribe::Memory* Tribe::FindMemory(csString name,const csVector3 &pos, iSector* sector, float radius)
{
    csList<Memory*>::Iterator it(memories);
    while(it.HasNext())
    {
        Memory* memory = it.Next();
        if(memory->name == name && memory->GetSector() == sector && memory->npc == NULL)
        {
            float dist = (memory->pos - pos).Norm();
            if(dist <= radius)
            {
                return memory;
            }
        }
    }
    return NULL; // Found nothing
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例4: ShareMemories

void Tribe::ShareMemories(NPC* npc)
{
    csList<Memory*>::Iterator it(memories);
    while(it.HasNext())
    {
        Memory* memory = it.Next();
        if(memory->npc == npc)
        {
            if(FindMemory(memory->name,memory->pos,memory->GetSector(),memory->radius))
            {
                // Tribe know this so delete the memory.
                memories.Delete(it);
                delete memory;
            }
            else
            {
                memory->npc = NULL; // Remove private indicator.
                SaveMemory(memory);
            }
        }
    }
}
开发者ID:,项目名称:,代码行数:22,代码来源:


注:本文中的Memory::GetSector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。