1 #region Copyright & License Information 2 /* 3 * Copyright 2007-2020 The OpenRA Developers (see AUTHORS) 4 * This file is part of OpenRA, which is free software. It is made 5 * available to you under the terms of the GNU General Public License 6 * as published by the Free Software Foundation, either version 3 of 7 * the License, or (at your option) any later version. For more 8 * information, see COPYING. 9 */ 10 #endregion 11 12 using System; 13 using System.Linq; 14 using OpenRA.Mods.Common.Traits; 15 using OpenRA.Traits; 16 17 namespace OpenRA.Mods.Common.Lint 18 { 19 class CheckRevealFootprint : ILintRulesPass 20 { Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)21 public void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules) 22 { 23 foreach (var actorInfo in rules.Actors) 24 { 25 var ios = actorInfo.Value.TraitInfoOrDefault<IOccupySpaceInfo>(); 26 foreach (var rsi in actorInfo.Value.TraitInfos<RevealsShroudInfo>()) 27 { 28 if (rsi.Type != VisibilityType.Footprint) 29 continue; 30 31 if (ios == null) 32 emitError("Actor type `{0}` defines VisibilityType.Footprint in `{1}` but has no IOccupySpace traits!".F(actorInfo.Key, rsi.GetType())); 33 else if (!ios.OccupiedCells(actorInfo.Value, CPos.Zero).Any()) 34 emitError("Actor type `{0}` defines VisibilityType.Footprint in `{1}` but does not have any footprint cells!".F(actorInfo.Key, rsi.GetType())); 35 } 36 } 37 } 38 } 39 } 40