From 124e7b389a6da5304597ea49deaaa3bd66e3e19b Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 19 Dec 2015 13:15:23 +0000 Subject: [PATCH] Add a lint test for projectile target search radius. --- .../Lint/CheckTargetHealthRadius.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs b/OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs index 15eb1232b7..9ac4f990e5 100644 --- a/OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs +++ b/OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs @@ -10,6 +10,8 @@ using System; using System.Linq; +using OpenRA.GameRules; +using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; @@ -48,6 +50,21 @@ namespace OpenRA.Mods.Common.Lint emitError("Actor type `{0}` has a health radius exceeding the victim scan radius of a warhead on `{1}`!" .F(actorInfo.Key, weaponInfo.Key)); } + + var bullet = weaponInfo.Value.Projectile as BulletInfo; + var missile = weaponInfo.Value.Projectile as MissileInfo; + var areabeam = weaponInfo.Value.Projectile as AreaBeamInfo; + + if (bullet == null && missile == null && areabeam == null) + continue; + + var targetExtraSearchRadius = bullet != null ? bullet.TargetExtraSearchRadius : + missile != null ? missile.TargetExtraSearchRadius : + areabeam != null ? areabeam.TargetExtraSearchRadius : WDist.Zero; + + if (healthTraits.Where(x => x.Shape.OuterRadius.Length > targetExtraSearchRadius.Length).Any()) + emitError("Actor type `{0}` has a health radius exceeding the victim scan radius of the projectile on `{1}`!" + .F(actorInfo.Key, weaponInfo.Key)); } } }