Replace duplicate BlockedByActor with BlocksProjectiles.AnyBlockingActorAt

This commit is contained in:
reaperrr
2015-09-30 22:26:28 +02:00
parent 7e1f29d4c5
commit 4cf27fc207
3 changed files with 11 additions and 21 deletions

View File

@@ -167,12 +167,8 @@ namespace OpenRA.Mods.Common.Effects
if (info.ContrailLength > 0)
contrail.Update(pos);
var cell = world.Map.CellContaining(pos);
var height = world.Map.DistanceAboveTerrain(pos);
var shouldExplode = height.Length <= 0 // Hit the ground
|| ticks++ >= length // Flight length reached/exceeded
|| BlockedByActor(world, pos); // Hit a wall or other blocking obstacle
var shouldExplode = ticks++ >= length // Flight length reached/exceeded
|| (info.Blockable && BlocksProjectiles.AnyBlockingActorAt(world, pos)); // Hit a wall or other blocking obstacle
if (shouldExplode)
Explode(world);
@@ -212,11 +208,5 @@ namespace OpenRA.Mods.Common.Effects
args.Weapon.Impact(Target.FromPos(pos), args.SourceActor, args.DamageModifiers);
}
bool BlockedByActor(World world, WPos pos)
{
return info.Blockable && world.ActorMap.GetUnitsAt(world.Map.CellContaining(pos))
.Any(a => a.TraitsImplementing<BlocksProjectiles>().Any(Exts.IsTraitEnabled));
}
}
}