Files
OpenRA/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs
2011-06-28 23:36:39 +12:00

56 lines
1.6 KiB
C#

#region Copyright & License Information
/*
* Copyright 2007-2011 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. For more information,
* see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRA.Traits;
using OpenRA.Mods.RA.Buildings;
namespace OpenRA.Mods.RA
{
class LintBuildablePrerequisites : ILintPass
{
public void Run(Action<string> emitError)
{
var providedPrereqs = Rules.Info.Keys.Concat(
Rules.Info.SelectMany( a => a.Value.Traits
.WithInterface<ProvidesCustomPrerequisiteInfo>()
.Select( p => p.Prerequisite ))).ToArray();
foreach( var i in Rules.Info )
{
var bi = i.Value.Traits.GetOrDefault<BuildableInfo>();
if (bi != null)
foreach( var prereq in bi.Prerequisites )
if ( !providedPrereqs.Contains(prereq) )
emitError( "Buildable actor {0} has prereq {1} not provided by anything.".F( i.Key, prereq ) );
}
}
}
class CheckAutotargetWiring : ILintPass
{
public void Run(Action<string> emitError)
{
foreach( var i in Rules.Info )
{
if (i.Key.StartsWith("^"))
continue;
var attackMove = i.Value.Traits.GetOrDefault<AttackMoveInfo>();
if (attackMove != null && !attackMove.JustMove &&
!i.Value.Traits.Contains<AutoTargetInfo>())
emitError( "{0} has AttackMove setup without AutoTarget, and will crash when resolving that order.".F(i.Key) );
}
}
}
}