Add ILintSequencesPass.
This commit is contained in:
@@ -18,24 +18,9 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
class CheckSequences : ILintRulesPass
|
||||
class CheckSequences : ILintSequencesPass
|
||||
{
|
||||
void ILintRulesPass.Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Ruleset rules)
|
||||
{
|
||||
// Custom maps define rules.Sequences, default mod rules leave it null.
|
||||
if (rules.Sequences == null)
|
||||
{
|
||||
foreach (var kv in modData.DefaultSequences)
|
||||
{
|
||||
Console.WriteLine("Testing default sequences for {0}", kv.Key);
|
||||
Run(emitError, emitWarning, rules, kv.Value);
|
||||
}
|
||||
}
|
||||
else if (!modData.DefaultSequences.Values.Contains(rules.Sequences))
|
||||
Run(emitError, emitWarning, rules, rules.Sequences);
|
||||
}
|
||||
|
||||
void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules, SequenceProvider sequences)
|
||||
void ILintSequencesPass.Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Ruleset rules, SequenceProvider sequences)
|
||||
{
|
||||
var factions = rules.Actors[SystemActors.World].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
|
||||
@@ -13,6 +13,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Lint;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands
|
||||
@@ -62,6 +63,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
// Run all rule checks on the default mod rules.
|
||||
CheckRules(modData, modData.DefaultRules);
|
||||
foreach (var tileset in modData.DefaultTerrainInfo.Keys)
|
||||
{
|
||||
Console.WriteLine($"Testing default sequences for {tileset}");
|
||||
|
||||
var sequences = new SequenceProvider(modData.DefaultFileSystem, modData, tileset, null);
|
||||
CheckSequences(modData, modData.DefaultRules, sequences);
|
||||
}
|
||||
|
||||
// Run all generic (not mod-level) checks here.
|
||||
foreach (var customPassType in modData.ObjectCreator.GetTypesImplementing<ILintPass>())
|
||||
@@ -120,7 +128,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
// Run all rule checks on the map if it defines custom rules.
|
||||
if (map.RuleDefinitions != null || map.VoiceDefinitions != null || map.WeaponDefinitions != null)
|
||||
{
|
||||
CheckRules(modData, map.Rules);
|
||||
if (map.SequenceDefinitions != null)
|
||||
CheckSequences(modData, modData.DefaultRules, map.Sequences);
|
||||
}
|
||||
|
||||
// Run all map-level checks here.
|
||||
foreach (var customMapPassType in modData.ObjectCreator.GetTypesImplementing<ILintMapPass>())
|
||||
@@ -152,5 +164,21 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CheckSequences(ModData modData, Ruleset rules, SequenceProvider sequences)
|
||||
{
|
||||
foreach (var customSequencesPassType in modData.ObjectCreator.GetTypesImplementing<ILintSequencesPass>())
|
||||
{
|
||||
try
|
||||
{
|
||||
var customRulesPass = (ILintSequencesPass)modData.ObjectCreator.CreateBasic(customSequencesPassType);
|
||||
customRulesPass.Run(EmitError, EmitWarning, modData, rules, sequences);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
EmitError($"{customSequencesPassType} failed with exception: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
public interface ILintPass { void Run(Action<string> emitError, Action<string> emitWarning, ModData modData); }
|
||||
public interface ILintMapPass { void Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Map map); }
|
||||
public interface ILintRulesPass { void Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Ruleset rules); }
|
||||
public interface ILintSequencesPass { void Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Ruleset rules, SequenceProvider sequences); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user