From 9b2cdd4457b1dff077f51eb1f1e2e2f6af5d0138 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 6 Oct 2015 22:21:31 +0200 Subject: [PATCH] Add Height property to BlocksProjectiles --- OpenRA.Mods.Common/Traits/BlocksProjectiles.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/BlocksProjectiles.cs b/OpenRA.Mods.Common/Traits/BlocksProjectiles.cs index 742441e808..3bd90c95a7 100644 --- a/OpenRA.Mods.Common/Traits/BlocksProjectiles.cs +++ b/OpenRA.Mods.Common/Traits/BlocksProjectiles.cs @@ -13,10 +13,11 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - // TODO: Add functionality like a customizable Height that is compared to projectile altitude [Desc("This actor blocks bullets and missiles with 'Blockable' property.")] public class BlocksProjectilesInfo : UpgradableTraitInfo { + public readonly WDist Height = WDist.FromCells(1); + public override object Create(ActorInitializer init) { return new BlocksProjectiles(init.Self, this); } } @@ -27,8 +28,11 @@ namespace OpenRA.Mods.Common.Traits public static bool AnyBlockingActorAt(World world, WPos pos) { + var dat = world.Map.DistanceAboveTerrain(pos); return world.ActorMap.GetActorsAt(world.Map.CellContaining(pos)) - .Any(a => a.TraitsImplementing().Any(Exts.IsTraitEnabled)); + .Any(a => a.TraitsImplementing() + .Where(t => t.Info.Height.Length >= dat.Length) + .Any(Exts.IsTraitEnabled)); } } }