本文整理汇总了C++中ManagedReference::enqueueExitEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ ManagedReference::enqueueExitEvent方法的具体用法?C++ ManagedReference::enqueueExitEvent怎么用?C++ ManagedReference::enqueueExitEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManagedReference
的用法示例。
在下文中一共展示了ManagedReference::enqueueExitEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: destroyObjectFromWorld
//.........这里部分代码省略.........
ManagedReference<Zone*> rootZone = sceneObject->getZone();
ManagedReference<Zone*> zone = sceneObject->getLocalZone();
if (par != NULL) {
uint64 parentID = sceneObject->getParentID();
par->removeObject(sceneObject, NULL, false);
if (par->isCellObject()) {
ManagedReference<BuildingObject*> build = cast<BuildingObject*>(par->getParent().get().get());
if (build != NULL) {
CreatureObject* creature = cast<CreatureObject*>(sceneObject);
if (creature != NULL)
build->onExit(creature, parentID);
}
}
sceneObject->notifyObservers(ObserverEventType::OBJECTREMOVEDFROMZONE, sceneObject, 0);
} else if (zone != NULL) {
zone->removeObject(sceneObject, NULL, false);
}
if (rootZone != NULL) {
Locker locker(rootZone);
if (!sceneObject->isActiveArea())
rootZone->remove(sceneObject);
rootZone->dropSceneObject(sceneObject);
SharedBuildingObjectTemplate* objtemplate = dynamic_cast<SharedBuildingObjectTemplate*>(sceneObject->getObjectTemplate());
if (objtemplate != NULL) {
String modFile = objtemplate->getTerrainModificationFile();
if (!modFile.isEmpty()) {
rootZone->getPlanetManager()->getTerrainManager()->removeTerrainModification(sceneObject->getObjectID());
}
}
locker.release();
SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects;
CloseObjectsVector* closeobjects = (CloseObjectsVector*) sceneObject->getCloseObjects();
if (closeobjects != NULL) {
try {
closeobjects->safeCopyTo(closeSceneObjects);
while (closeSceneObjects.size() > 0) {
ManagedReference<QuadTreeEntry*> obj = closeSceneObjects.get(0);
if (obj != NULL && obj != sceneObject && obj->getCloseObjects() != NULL)
obj->removeInRangeObject(sceneObject);
sceneObject->removeInRangeObject((int) 0);
closeSceneObjects.remove((int) 0);
}
closeobjects->removeAll();
} catch (...) {
}
} else {
SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects;
sceneObject->info("Null closeobjects vector in ZoneComponent::destroyObjectFromWorld", true);
rootZone->getInRangeObjects(sceneObject->getPositionX(), sceneObject->getPositionY(), 512, &closeSceneObjects, false);
for (int i = 0; i < closeSceneObjects.size(); ++i) {
QuadTreeEntry* obj = closeSceneObjects.get(i);
if (obj != sceneObject && obj->getCloseObjects() != NULL)
obj->removeInRangeObject(sceneObject);
}
}
// rootZone->dropSceneObject(sceneObject);
// locker.release();
Vector<ManagedReference<ActiveArea*> >* activeAreas = sceneObject->getActiveAreas();
while (activeAreas->size() > 0) {
Locker _alocker(sceneObject->getContainerLock());
ManagedReference<ActiveArea*> area = activeAreas->get(0);
activeAreas->remove(0);
_alocker.release();
area->enqueueExitEvent(sceneObject);
}
}
}
示例2: removeObject
bool ZoneContainerComponent::removeObject(SceneObject* sceneObject, SceneObject* object, SceneObject* destination, bool notifyClient) {
Zone* zone = dynamic_cast<Zone*>(sceneObject);
if (object->isActiveArea())
return removeActiveArea(zone, dynamic_cast<ActiveArea*>(object));
ManagedReference<SceneObject*> parent = object->getParent();
//SortedVector<ManagedReference<SceneObject*> >* notifiedSentObjects = sceneObject->getNotifiedSentObjects();
try {
Locker locker(object);
if (zone == NULL)
return false;
object->info("removing from zone");
Locker zoneLocker(zone);
if (parent != NULL) {
parent->removeObject(object, NULL, false);
} else
zone->remove(object);
Zone* oldZone = zone;
// oldZone->dropSceneObject(object);
// zoneLocker.release();
SortedVector<ManagedReference<QuadTreeEntry*> >* closeObjects = object->getCloseObjects();
if (closeObjects != NULL) {
try {
while (closeObjects->size() > 0) {
ManagedReference<QuadTreeEntry*> obj = closeObjects->get(0);
if (obj != NULL && obj != object && obj->getCloseObjects() != NULL)
obj->removeInRangeObject(object);
object->removeInRangeObject((int) 0);
}
} catch (...) {
}
} else {
object->info("Null closeobjects vector in ZoneContainerComponent::removeObject", true);
SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects;
zone->getInRangeObjects(object->getPositionX(), object->getPositionY(), 512, &closeSceneObjects, false);
for (int i = 0; i < closeSceneObjects.size(); ++i) {
QuadTreeEntry* obj = closeSceneObjects.get(i);
if (obj != NULL && obj != object && obj->getCloseObjects() != NULL)
obj->removeInRangeObject(object);
}
}
// Zone* oldZone = zone;
zone = NULL;
oldZone->dropSceneObject(object);
SharedBuildingObjectTemplate* objtemplate = dynamic_cast<SharedBuildingObjectTemplate*>(object->getObjectTemplate());
if (objtemplate != NULL) {
String modFile = objtemplate->getTerrainModificationFile();
if (!modFile.isEmpty()) {
oldZone->getPlanetManager()->getTerrainManager()->removeTerrainModification(object->getObjectID());
}
}
zoneLocker.release();
if (object->isTangibleObject()) {
TangibleObject* tano = cast<TangibleObject*>(object);
Vector<ManagedReference<ActiveArea*> >* activeAreas = tano->getActiveAreas();
while (activeAreas->size() > 0) {
Locker _alocker(object->getContainerLock());
ManagedReference<ActiveArea*> area = activeAreas->get(0);
activeAreas->remove(0);
_alocker.release();
area->enqueueExitEvent(object);
}
}
SortedVector<ManagedReference<SceneObject*> >* childObjects = object->getChildObjects();
//Remove all outdoor child objects from zone
for (int i = 0; i < childObjects->size(); ++i) {
ManagedReference<SceneObject*> outdoorChild = childObjects->get(i);
if (outdoorChild == NULL)
continue;
//.........这里部分代码省略.........
示例3: updateActiveAreas
void ZoneImplementation::updateActiveAreas(TangibleObject* tano) {
//Locker locker(_this.getReferenceUnsafeStaticCast());
Locker _alocker(tano->getContainerLock());
SortedVector<ManagedReference<ActiveArea* > > areas = *dynamic_cast<SortedVector<ManagedReference<ActiveArea* > >* >(tano->getActiveAreas());
_alocker.release();
Vector3 worldPos = tano->getWorldPosition();
SortedVector<ManagedReference<QuadTreeEntry*> > entryObjects;
Zone* managedRef = _this.getReferenceUnsafeStaticCast();
bool readlock = !managedRef->isLockedByCurrentThread();
managedRef->rlock(readlock);
try {
regionTree->inRange(worldPos.getX(), worldPos.getY(), entryObjects);
} catch (...) {
error("unexpeted error caught in void ZoneImplementation::updateActiveAreas(SceneObject* object) {");
}
managedRef->runlock(readlock);
//locker.release();
managedRef->unlock(!readlock);
try {
// update old ones
for (int i = 0; i < areas.size(); ++i) {
ManagedReference<ActiveArea*> area = areas.get(i);
// Locker lockerO(object);
// Locker locker(area, object);
if (!area->containsPoint(worldPos.getX(), worldPos.getY(), tano->getParentID())) {
tano->dropActiveArea(area);
area->enqueueExitEvent(tano);
// area->notifyExit(object);
} else {
area->notifyPositionUpdate(tano);
}
}
// we update the ones in quadtree.
for (int i = 0; i < entryObjects.size(); ++i) {
//update in new ones
ActiveArea* activeArea = dynamic_cast<ActiveArea*>(entryObjects.get(i).get());
if (!tano->hasActiveArea(activeArea) && activeArea->containsPoint(worldPos.getX(), worldPos.getY(), tano->getParentID())) {
//Locker lockerO(object);
//Locker locker(activeArea, object);
tano->addActiveArea(activeArea);
activeArea->enqueueEnterEvent(tano);
//activeArea->notifyEnter(object);
}
}
// update world areas
if (creatureManager != NULL) {
Vector<ManagedReference<SpawnArea*> >* worldAreas = creatureManager->getWorldSpawnAreas();
if (worldAreas != NULL) {
for (int i = 0; i < worldAreas->size(); ++i) {
ActiveArea* activeArea = worldAreas->get(i);
Locker lockerO(tano);
// Locker locker(activeArea, object);
if (!tano->hasActiveArea(activeArea)) {
tano->addActiveArea(activeArea);
//activeArea->enqueueEnterEvent(object);
activeArea->notifyEnter(tano);
} else {
activeArea->notifyPositionUpdate(tano);
}
}
}
}
} catch (...) {
error("unexpected exception caught in void ZoneImplementation::updateActiveAreas(SceneObject* object) {");
managedRef->wlock(!readlock);
throw;
}
managedRef->wlock(!readlock);
}