Beispiel #1
0
/**
 * Perform explosion
 * @param	sqrRadius	The squared radius that affect the bomb
 */
void Bomb::performExplosion(float sqrRadius, float power)
{
	// perform an aabb query
	sm::AABB query;
	query.setSize(2.0f * sqrRadius, 2.0f * sqrRadius);

	// set the actual position
	ASSERT(mNode);
	const Ogre::Vector3 &pos = mNode->getPosition();
	query.setPosition(sm::Vector2(pos.x, pos.z));
	static CollisionResult	objects;
	mCollMngr->getCollisionObjects(query, BOMB_AFFECTABLE_MASK, objects);

	debugRED("Tenemos que poner el power real aca, estamos"
			" usando directamente una fuerza lineal, tenemos que disminuir"
			" el poder a medida que nos alejamos del centro de explosion\n");

	// iterate over all the objects affected
	const CollisionObject *co;
	Hit_t hit;
	hit.shooter = 0;
	for(int i = objects.size()-1; i >= 0; --i){
		co = objects[i];
		if(checkObjectBetween(query.pos, co)) {
			// not affect that object..
			continue;
		}

		// else we affect the object with the corresponding power
		GameObject *go = static_cast<GameObject *>(co->userDefined);
		ASSERT(go);
		hit.power = power;
		hit.hitDir = query.pos - co->getPosition();
		go->beenHit(hit);
	}

}