本文整理汇总了C++中SortedVector类的典型用法代码示例。如果您正苦于以下问题:C++ SortedVector类的具体用法?C++ SortedVector怎么用?C++ SortedVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SortedVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Vector<CreatureObject*> TurretDataComponent::getAvailableTargets(bool aggroOnly) {
Vector<CreatureObject*> targets;
ManagedReference<TangibleObject*> turret = cast<TangibleObject*>(getParent());
if (turret == NULL)
return targets;
CloseObjectsVector* vec = (CloseObjectsVector*)turret->getCloseObjects();
SortedVector<QuadTreeEntry*> closeObjects;
vec->safeCopyTo(closeObjects);
int targetTotal = 0;
for (int i = 0; i < closeObjects.size(); ++i) {
CreatureObject* creo = cast<CreatureObject*>(closeObjects.get(i));
if (creo != NULL && checkTarget(creo, turret, aggroOnly)) {
targets.add(creo);
}
}
return targets;
}
示例2: zoneLocker
int SceneObjectImplementation::inRangeObjects(unsigned int gameObjectType, float range) {
if (getZone() == NULL)
return 0;
int numberOfObjects = 0;
Locker zoneLocker(getZone());
SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects;
int maxInRangeObjectCount = 0;
if (closeobjects == NULL) {
info("Null closeobjects vector in SceneObjectImplementation::inRangeObjects", true);
zone->getInRangeObjects(getPositionX(), getPositionY(), range, &closeSceneObjects, true);
maxInRangeObjectCount = closeSceneObjects.size();
} else
maxInRangeObjectCount = closeobjects->size();
for (int i = 0; i < maxInRangeObjectCount; ++i) {
SceneObject* scno;
if (closeobjects != NULL)
scno = cast<SceneObject*>( closeobjects->get(i).get());
else
scno = cast<SceneObject*>(closeSceneObjects.get(i).get());
if (scno->isInRange(_this.get(), range) && scno->getGameObjectType() == gameObjectType)
++numberOfObjects;
}
return numberOfObjects;
}
示例3: targetPos
Reference<SceneObject*> PlanetManagerImplementation::findObjectTooCloseToDecoration(float x, float y, float margin) {
SortedVector<ManagedReference<QuadTreeEntry* > > closeObjects;
Vector3 targetPos(x, y,0);
zone->getInRangeObjects(x, y, 256, &closeObjects, true);
for (int i = 0; i < closeObjects.size(); ++i) {
ManagedReference<SceneObject*> obj = cast<SceneObject*>(closeObjects.get(i).get());
if(obj == NULL || obj->isCreatureObject() || obj->getObjectTemplate() == NULL)
continue;
Vector3 objVec(obj->getPositionX(), obj->getPositionY(),0);
int squaredDistance = (obj->getObjectTemplate()->getNoBuildRadius() + margin) * (obj->getObjectTemplate()->getNoBuildRadius() + margin);
if(objVec.squaredDistanceTo(targetPos) < squaredDistance){
return obj;
}
if(obj->isStructureObject() && StructureManager::instance()->isInStructureFootprint(cast<StructureObject*>(obj.get()), x, y, margin) ){
return obj;
}
}
return NULL;
}
示例4: isBuildingPermittedAt
bool PlanetManagerImplementation::isBuildingPermittedAt(float x, float y, SceneObject* object, float margin) {
SortedVector<ManagedReference<ActiveArea* > > activeAreas;
Vector3 targetPos(x, y, zone->getHeight(x, y));
zone->getInRangeActiveAreas(x, y, &activeAreas, true);
for (int i = 0; i < activeAreas.size(); ++i) {
ActiveArea* area = activeAreas.get(i);
if (area->isNoBuildArea()) {
return false;
}
}
if (isInObjectsNoBuildZone(x, y, margin)) {
return false;
}
if (isInWater(targetPos.getX(), targetPos.getY())) {
return false;
}
if (isInRangeWithPoi(targetPos.getX(), targetPos.getY(), 150))
return false;
return true;
}
示例5: isBuildingPermittedAt
bool PlanetManagerImplementation::isBuildingPermittedAt(float x, float y, SceneObject* object, float margin) {
SortedVector<ActiveArea*> activeAreas;
Vector3 targetPos(x, y, 0);
if (!zone->isWithinBoundaries(targetPos))
return false;
//targetPos.setZ(zone->getHeight(x, y)); not needed
zone->getInRangeActiveAreas(x, y, &activeAreas, true);
for (int i = 0; i < activeAreas.size(); ++i) {
ActiveArea* area = activeAreas.get(i);
if (area->isNoBuildArea()) {
return false;
}
}
if (isInObjectsNoBuildZone(x, y, margin)) {
return false;
}
if (isInWater(x, y)) {
return false;
}
if (isInRangeWithPoi(x, y, 150))
return false;
return true;
}
示例6: isInObjectsNoBuildZone
bool PlanetManagerImplementation::isInObjectsNoBuildZone(float x, float y, float extraMargin) {
SortedVector<ManagedReference<QuadTreeEntry* > > closeObjects;
Vector3 targetPos(x, y, zone->getHeight(x, y));
zone->getInRangeObjects(x, y, 512, &closeObjects, true);
for (int i = 0; i < closeObjects.size(); ++i) {
SceneObject* obj = cast<SceneObject*>(closeObjects.get(i).get());
SharedObjectTemplate* objectTemplate = obj->getObjectTemplate();
if (objectTemplate != NULL) {
float radius = objectTemplate->getNoBuildRadius();
// Only check objects with an actual NoBuildRadius
if (radius > 0) {
// Add margin to check
radius += extraMargin;
Vector3 objWorldPos = obj->getWorldPosition();
if (objWorldPos.squaredDistanceTo(targetPos) < radius * radius) {
return true;
}
}
}
}
return false;
}
示例7: isCampingPermittedAt
bool PlanetManagerImplementation::isCampingPermittedAt(float x, float y, float margin) {
SortedVector<ManagedReference<ActiveArea* > > activeAreas;
Vector3 targetPos(x, y, zone->getHeight(x, y));
zone->getInRangeActiveAreas(x, y, &activeAreas, true);
for (int i = 0; i < activeAreas.size(); ++i) {
ActiveArea* area = activeAreas.get(i);
// Skip areas explicitly marked as camping allowed
if (area->isCampingPermitted()) {
continue;
}
// Honor no-build after checking for areas that camping is explicitly allowed
if (area->isNoBuildArea()) {
return false;
}
}
if (isInWater(x, y)) {
return false;
}
if (isInRangeWithPoi(x, y, 150))
return false;
return true;
}
示例8: getParent
ManagedWeakReference<SceneObject*> SceneObjectImplementation::getRootParent() {
ManagedReference<SceneObject*> grandParent = getParent();
ManagedReference<SceneObject*> tempParent = NULL;
if (grandParent == NULL)
return NULL;
#ifdef DEBUG_GETROOT_PARENT
SortedVector<ManagedReference<SceneObject*> > parents;
parents.setNoDuplicateInsertPlan();
#endif
while ((tempParent = grandParent->getParent()) != NULL && grandParent != asSceneObject()) {
grandParent = tempParent;
#ifdef DEBUG_GETROOT_PARENT
if (parents.contains(grandParent))
return NULL;
else
parents.put(grandParent);
#endif
}
if (grandParent == asSceneObject())
return NULL;
ManagedWeakReference<SceneObject*> weak = grandParent.get();
return weak;
}
示例9: getZone
void InstallationObjectImplementation::broadcastMessage(BasePacket* message, bool sendSelf) {
Zone* zone = getZone();
if (zone == NULL)
return;
Locker zoneLocker(zone);
SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects;
zone->getInRangeObjects(getPositionX(), getPositionY(), 512, &closeSceneObjects, false);
for (int i = 0; i < closeSceneObjects.size(); ++i) {
ManagedReference<SceneObject*> scno = cast<SceneObject*>( closeSceneObjects.get(i).get());
if (!sendSelf && scno == _this.get())
continue;
if(!scno->isPlayerCreature())
continue;
CreatureObject* creo = cast<CreatureObject*>( scno.get());
if(isOnAdminList(creo))
scno->sendMessage(message->clone());
}
delete message;
}
示例10: getInRangeActiveAreas
int ZoneImplementation::getInRangeActiveAreas(float x, float y, float range, SortedVector<ManagedReference<ActiveArea*> >* objects, bool readLockZone) {
//Locker locker(_this.getReferenceUnsafeStaticCast());
bool readlock = readLockZone && !_this.getReferenceUnsafeStaticCast()->isLockedByCurrentThread();
//_this.getReferenceUnsafeStaticCast()->rlock(readlock);
Zone* thisZone = _this.getReferenceUnsafeStaticCast();
try {
thisZone->rlock(readlock);
SortedVector<ManagedReference<QuadTreeEntry*> > entryObjects;
regionTree->inRange(x, y, range, entryObjects);
thisZone->runlock(readlock);
for (int i = 0; i < entryObjects.size(); ++i) {
ActiveArea* obj = dynamic_cast<ActiveArea*>(entryObjects.get(i).get());
objects->put(obj);
}
}catch (...) {
// _this.getReferenceUnsafeStaticCast()->runlock(readlock);
throw;
}
// _this.getReferenceUnsafeStaticCast()->runlock(readlock);
return objects->size();
}
示例11: UpdateTable
void TableWidget::UpdateTable()
{
SortedVector<int> xdividers;
SortedVector<int> ydividers;
const cell_t *p = &*_columns.begin();
const cell_t *q = &*_columns.end();
if (p!=q) while( ++p!=q )
{
xdividers.Insert( p->position + _frame_left );
}
p = &*_rows.begin();
q = &*_rows.end();
if (p!=q) while( ++p!=q )
{
ydividers.Insert( p->position + _frame_top );
}
//_sp_skin->SetSize( Dim2i(_w,_h) );
_sp_skin->SetSize( Dim2i( GetWidth(), GetHeight()) );
_sp_skin->SetVDividers(xdividers);
_sp_skin->SetHDividers(ydividers);
_need_update = false;
OnTableUpdate.Send();
}
示例12: _lock
void JukeboxImplementation::notifyInsertToZone(Zone* zone) {
ManagedReference<Jukebox*> jbox = _this.getReferenceUnsafeStaticCast();
Locker _lock(jbox);
createChildObjects();
ManagedReference<JukeboxObserver*> observer = new JukeboxObserver(jbox);
jbox->registerObserver(ObserverEventType::PARENTCHANGED, observer);
ManagedReference<SceneObject*> obj = jbox->getRootParent().get();
if (obj == NULL || !obj->isStructureObject())
setRadius(100);
else
setRadius(30);
SortedVector<ManagedReference<SceneObject*> >* children = jbox->getChildObjects();
for (int i = 0; i < children->size(); ++i) {
ManagedReference<SceneObject*> child = children->get(i);
if (child != NULL && child->isActiveArea()) {
ManagedReference<ActiveArea*> area = cast<ActiveArea*>(child.get());
area->registerObserver(ObserverEventType::ENTEREDAREA, observer);
area->registerObserver(ObserverEventType::EXITEDAREA, observer);
}
}
}
示例13: setRadius
void JukeboxImplementation::setRadius(float newRadius) {
ManagedReference<Jukebox*> jbox = _this.getReferenceUnsafeStaticCast();
SortedVector<ManagedReference<SceneObject*> >* children = jbox->getChildObjects();
if (newRadius == radius)
return;
if (children == NULL)
return;
radius = newRadius;
for (int i = 0; i < children->size(); ++i) {
ManagedReference<SceneObject*> child = children->get(i);
if (child != NULL && child->isActiveArea()) {
ManagedReference<ActiveArea*> area = cast<ActiveArea*>(child.get());
Locker clocker(area, jbox);
area->setRadius(newRadius);
return;
}
}
}
示例14: getInRangeParkingGarage
SceneObject* StructureManager::getInRangeParkingGarage(SceneObject* obj, int range) {
ManagedReference<Zone*> zone = obj->getZone();
if (zone == NULL)
return NULL;
SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects;
CloseObjectsVector* closeObjectsVector = (CloseObjectsVector*) obj->getCloseObjects();
if (closeObjectsVector == NULL) {
zone->getInRangeObjects(obj->getPositionX(), obj->getPositionY(), 128, &closeSceneObjects, true);
} else {
closeObjectsVector->safeCopyTo(closeSceneObjects);
}
for (int i = 0; i < closeSceneObjects.size(); ++i) {
SceneObject* scno = cast<SceneObject*>(closeSceneObjects.get(i).get());
if (scno == obj)
continue;
if (scno->isGarage() && scno->isInRange(obj, range))
return scno;
}
return NULL;
}
示例15: locker
int StructurePermissionList::togglePermission(const String& listName, const String& playerName, bool caseSensitive) {
Locker locker(&lock);
if(playerName == ownerName)
return CANTCHANGEOWNER;
if (!permissionLists.contains(listName))
return LISTNOTFOUND;
SortedVector<String>* list = &permissionLists.get(listName);
String name = "";
if (caseSensitive)
name = playerName;
else
name = playerName.toLowerCase();
//If they exist, remove them.
if (list->contains(name)) {
list->drop(name);
return REVOKED;
}
list->put(name);
return GRANTED;
}