From 55b6084b60a1f0de3f422e2520b2b71e9831e471 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 8 Dec 2017 22:44:58 +0000 Subject: [PATCH] Add a lint test for conflicting Interactable and Selectable. --- .../Lint/CheckConflictingMouseBounds.cs | 31 +++++++++++++++++++ OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + 2 files changed, 32 insertions(+) create mode 100644 OpenRA.Mods.Common/Lint/CheckConflictingMouseBounds.cs diff --git a/OpenRA.Mods.Common/Lint/CheckConflictingMouseBounds.cs b/OpenRA.Mods.Common/Lint/CheckConflictingMouseBounds.cs new file mode 100644 index 0000000000..2334e7fdd9 --- /dev/null +++ b/OpenRA.Mods.Common/Lint/CheckConflictingMouseBounds.cs @@ -0,0 +1,31 @@ +#region Copyright & License Information +/* + * Copyright 2007-2017 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System; +using System.Linq; +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Lint +{ + public class CheckConflictingMouseBounds : ILintRulesPass + { + public void Run(Action emitError, Action emitWarning, Ruleset rules) + { + foreach (var actorInfo in rules.Actors) + { + var selectable = actorInfo.Value.TraitInfos().Count(); + var interactable = actorInfo.Value.TraitInfos().Count(); + if (selectable > 0 && selectable != interactable) + emitWarning("Actor {0} defines both Interactable and Selectable traits. This may cause unexpected results.".F(actorInfo.Value.Name)); + } + } + } +} \ No newline at end of file diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 91e393d806..09c9f43a93 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -835,6 +835,7 @@ +