actually working custom lint passes
This commit is contained in:
@@ -84,6 +84,14 @@ namespace OpenRA
|
||||
return ctor.Invoke( a );
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetTypesImplementing<T>()
|
||||
{
|
||||
var it = typeof(T);
|
||||
return ModAssemblies.Select( ma => ma.First ).Distinct()
|
||||
.SelectMany(ma => ma.GetTypes()
|
||||
.Where(t => t != it && it.IsAssignableFrom(t)));
|
||||
}
|
||||
|
||||
[AttributeUsage( AttributeTargets.Parameter )]
|
||||
public class ParamAttribute : Attribute
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.FileFormats;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Network;
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -42,6 +43,7 @@ namespace OpenRA.Traits
|
||||
IEnumerable<IOrderTargeter> Orders { get; }
|
||||
Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued);
|
||||
}
|
||||
|
||||
public interface IOrderTargeter
|
||||
{
|
||||
string OrderID { get; }
|
||||
@@ -50,9 +52,9 @@ namespace OpenRA.Traits
|
||||
bool CanTargetLocation(Actor self, int2 location, List<Actor> actorsAtLocation, bool forceAttack, bool forceQueue, bool forceMove, ref string cursor);
|
||||
bool IsQueued { get; }
|
||||
}
|
||||
|
||||
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
|
||||
public interface IValidateOrder { bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order);
|
||||
}
|
||||
public interface IValidateOrder { bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order); }
|
||||
public interface IOrderCursor { string CursorForOrder(Actor self, Order order); }
|
||||
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
||||
public interface ICustomUnitOrderGenerator : IOrderGenerator { };
|
||||
@@ -236,6 +238,11 @@ namespace OpenRA.Traits
|
||||
bool TargetableBy(Actor self, Actor byActor);
|
||||
}
|
||||
|
||||
public interface INotifyStanceChanged { void StanceChanged(Actor self, Player a, Player b,
|
||||
Stance oldStance, Stance newStance); }
|
||||
public interface INotifyStanceChanged
|
||||
{
|
||||
void StanceChanged(Actor self, Player a, Player b,
|
||||
Stance oldStance, Stance newStance);
|
||||
}
|
||||
|
||||
public interface ILintPass { void Run(Action<string> emitError); }
|
||||
}
|
||||
|
||||
16
OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs
Normal file
16
OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class LintBuildablePrerequisites : ILintPass
|
||||
{
|
||||
public void Run(Action<string> emitError)
|
||||
{
|
||||
emitError("Hello World");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -63,6 +63,7 @@
|
||||
<Compile Include="Air\FlyCircle.cs" />
|
||||
<Compile Include="Buildings\Sellable.cs" />
|
||||
<Compile Include="Effects\CashTick.cs" />
|
||||
<Compile Include="Lint\LintBuildablePrerequisites.cs" />
|
||||
<Compile Include="ProductionBar.cs" />
|
||||
<Compile Include="Render\RenderEditorOnly.cs" />
|
||||
<Compile Include="SmokeTrailWhenDamaged.cs" />
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace RALint
|
||||
|
||||
static int Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("This is teh sucks");
|
||||
try
|
||||
{
|
||||
// bind some nonfatal error handling into FieldLoader, so we don't just *explode*.
|
||||
@@ -44,6 +45,17 @@ namespace RALint
|
||||
foreach (var traitInfo in actorInfo.Value.Traits.WithInterface<ITraitInfo>())
|
||||
CheckTrait(actorInfo.Value, traitInfo);
|
||||
|
||||
foreach (var customPassType in Game.modData.ObjectCreator
|
||||
.GetTypesImplementing<ILintPass>())
|
||||
{
|
||||
var customPass = (ILintPass)Game.modData.ObjectCreator
|
||||
.CreateBasic(customPassType);
|
||||
|
||||
Console.WriteLine("CustomPass: {0}".F(customPassType.ToString()));
|
||||
|
||||
customPass.Run(EmitError);
|
||||
}
|
||||
|
||||
if (errors > 0)
|
||||
{
|
||||
Console.WriteLine("Errors: {0}", errors);
|
||||
|
||||
Reference in New Issue
Block a user