Exemple #1
0
Collision Projectile::checkProjectileCollision(TileMap &map)
{
	if (!this->tileObject)
	{
		// It's possible the projectile reached the end of it's lifetime this frame
		// so ignore stuff without a tile
		return {};
	}

	sp<TileObject> ignoredObject = nullptr;
	if (ownerInvulnerableTicks > 0)
	{
		if (firerVehicle)
		{
			ignoredObject = firerVehicle->tileObject;
		}
		else if (firerUnit)
		{
			ignoredObject = firerUnit->tileObject;
		}
	}
	Collision c = map.findCollision(this->previousPosition, this->position, {}, ignoredObject);
	if (!c)
		return {};

	c.projectile = shared_from_this();
	return c;
}
Exemple #2
0
static void test_collision(const TileMap &map, Vec3<float> line_start, Vec3<float> line_end,
                           sp<TileObject> expected_collision)
{
	auto collision = map.findCollision(line_start, line_end);
	if (collision.obj != expected_collision)
	{
		LogError("Line between {%f,%f,%f} and {%f,%f,%f} collided with %s, expected %s",
		         line_start.x, line_start.y, line_start.z, line_end.x, line_end.y, line_end.z,
		         collision.obj ? collision.obj->getName() : "NONE",
		         expected_collision ? expected_collision->getName() : "NONE");
		exit(EXIT_FAILURE);
	}
}
Exemple #3
0
Collision Projectile::checkProjectileCollision(TileMap &map)
{
	if (!this->tileObject)
	{
		// It's possible the projectile reached the end of it's lifetime this frame
		// so ignore stuff without a tile
		return {};
	}

	Collision c = map.findCollision(this->previousPosition, this->position);
	if (c && c.obj->getType() == TileObject::Type::Vehicle &&
	    this->firer == std::static_pointer_cast<TileObjectVehicle>(c.obj)->getVehicle())
	{
		return {};
	}

	c.projectile = shared_from_this();
	return c;
}