Lint check for distinct sprite body names
This commit is contained in:
committed by
Matthias Mailänder
parent
d060f885e8
commit
1c78073808
32
OpenRA.Mods.Common/Lint/CheckSpriteBodies.cs
Normal file
32
OpenRA.Mods.Common/Lint/CheckSpriteBodies.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2018 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.Mods.Common.Traits.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
class CheckSpriteBodies : ILintRulesPass
|
||||
{
|
||||
public void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)
|
||||
{
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
var wsbs = actorInfo.Value.TraitInfos<WithSpriteBodyInfo>();
|
||||
foreach (var wsb in wsbs)
|
||||
if (wsbs.Any(w => w != wsb && w.Name == wsb.Name))
|
||||
emitError("Actor type `{0}` has more than one *SpriteBody with Name: {1}!".F(actorInfo.Key, wsb.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user