void TangibleObjectImplementation::broadcastPvpStatusBitmask() {
	if (getZone() == NULL)
			return;

	if (closeobjects != NULL) {
		Zone* zone = getZone();

		CreatureObject* thisCreo = asCreatureObject();

		SortedVector<ManagedReference<QuadTreeEntry*> > closeObjects(closeobjects->size(), 10);

		closeobjects->safeCopyTo(closeObjects);

		for (int i = 0; i < closeObjects.size(); ++i) {
			SceneObject* obj = cast<SceneObject*>(closeObjects.get(i).get());

			if (obj != NULL && obj->isCreatureObject()) {
				CreatureObject* creo = obj->asCreatureObject();

				sendPvpStatusTo(creo);

				if (thisCreo != NULL)
					creo->sendPvpStatusTo(thisCreo);
			}

		}
	}
}
Ejemplo n.º 2
0
void ZoneComponent::updateInRangeObjectsOnMount(SceneObject* sceneObject) {
	CloseObjectsVector* closeObjectsVector = (CloseObjectsVector*) sceneObject->getCloseObjects();
	CloseObjectsVector* parentCloseObjectsVector = (CloseObjectsVector*) sceneObject->getRootParent().get()->getCloseObjects();

	SortedVector<ManagedReference<QuadTreeEntry*> > closeObjects(closeObjectsVector->size(), 10);
	closeObjectsVector->safeCopyTo(closeObjects);

	SortedVector<ManagedReference<QuadTreeEntry*> > parentCloseObjects(parentCloseObjectsVector->size(), 10);
	parentCloseObjectsVector->safeCopyTo(parentCloseObjects);

	//remove old ones
	float rangesq = 192.f * 192.f;

	float x = sceneObject->getPositionX();
	float y = sceneObject->getPositionY();

	float oldx = sceneObject->getPreviousPositionX();
	float oldy = sceneObject->getPreviousPositionY();

	for (int i = 0; i < closeObjects.size(); ++i) {
		ManagedReference<QuadTreeEntry*> o = closeObjects.get(i);
		ManagedReference<QuadTreeEntry*> objectToRemove = o;
		ManagedReference<QuadTreeEntry*> rootParent = o->getRootParent();

		if (rootParent != NULL)
			o = rootParent;

		if (o != sceneObject) {
			float deltaX = x - o->getPositionX();
			float deltaY = y - o->getPositionY();

			if (deltaX * deltaX + deltaY * deltaY > rangesq) {
				float oldDeltaX = oldx - o->getPositionX();
				float oldDeltaY = oldy - o->getPositionY();

				if (oldDeltaX * oldDeltaX + oldDeltaY * oldDeltaY <= rangesq) {

					if (sceneObject->getCloseObjects() != NULL)
						sceneObject->removeInRangeObject(objectToRemove);

					if (objectToRemove->getCloseObjects() != NULL)
						objectToRemove->removeInRangeObject(sceneObject);
				}
			}
		}
	}

	//insert new ones
	for (int i = 0; i < parentCloseObjects.size(); ++i) {
		QuadTreeEntry* o = parentCloseObjects.get(i);

		if (sceneObject->getCloseObjects() != NULL)
			sceneObject->addInRangeObject(o, false);

		if (o->getCloseObjects() != NULL)
			o->addInRangeObject(sceneObject, true);
	}
}
Ejemplo n.º 3
0
void CollisionManager::getWorldFloorCollisions(float x, float y, Zone* zone, SortedVector<IntersectionResult>* result, CloseObjectsVector* closeObjectsVector) {
	if (closeObjectsVector != NULL) {
		Vector<QuadTreeEntry*> closeObjects(closeObjectsVector->size(), 10);
		closeObjectsVector->safeCopyTo(closeObjects);

		getWorldFloorCollisions(x, y, zone, result, closeObjects);
	} else {
		zone->info("Null closeobjects vector in CollisionManager::getWorldFloorCollisions", true);
		SortedVector<ManagedReference<QuadTreeEntry*> > closeObjects;

		zone->getInRangeObjects(x, y, 128, &closeObjects, true);

		getWorldFloorCollisions(x, y, zone, result, closeObjects);
	}
}