Lint check for distinct sprite body names

This commit is contained in:
reaperrr
2018-05-18 01:04:47 +02:00
committed by Matthias Mailänder
parent d060f885e8
commit 1c78073808
4 changed files with 39 additions and 0 deletions

View 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));
}
}
}
}

View File

@@ -198,6 +198,7 @@
<Compile Include="Lint\CheckChromeHotkeys.cs" />
<Compile Include="Lint\CheckConflictingMouseBounds.cs" />
<Compile Include="Lint\CheckLocomotorReferences.cs" />
<Compile Include="Lint\CheckSpriteBodies.cs" />
<Compile Include="Lint\LintBuildablePrerequisites.cs" />
<Compile Include="Lint\LintExts.cs" />
<Compile Include="LoadScreens\ModContentLoadScreen.cs" />

View File

@@ -30,9 +30,11 @@ V2RL:
AttackFrontal:
WithFacingSpriteBody:
RequiresCondition: !reloading
Name: loaded
WithFacingSpriteBody@EMPTY:
RequiresCondition: reloading
Sequence: empty-idle
Name: reloading
SelectionDecorations:
Explodes:
Weapon: V2Explode

View File

@@ -111,16 +111,20 @@ NAFNCE:
RequiresCondition: laserfence-direction-x && active-posts == 2
Type: laserfence
Sequence: enabled-x
Name: x-enabled
WithWallSpriteBody@YENABLED:
RequiresCondition: laserfence-direction-y && active-posts == 2
Type: laserfence
Sequence: enabled-y
Name: y-enabled
WithSpriteBody@XDISABLED:
RequiresCondition: laserfence-direction-x && active-posts < 2
Sequence: disabled-x
Name: x-disabled
WithSpriteBody@YDISABLED:
RequiresCondition: laserfence-direction-y && active-posts < 2
Sequence: disabled-y
Name: y-disabled
BlocksProjectiles:
RequiresCondition: active-posts == 2
DamageMultiplier: # Prevent all normal damage, but still allows direct kills from the post