本文整理汇总了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;
}
示例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;
}
示例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
}
示例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);
}
}
}
}