make projectile sprite sequences lint testable
This commit is contained in:
@@ -12,6 +12,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -89,6 +90,48 @@ namespace OpenRA.Mods.Common.Lint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var weaponInfo in map.Rules.Weapons)
|
||||
{
|
||||
var projectileInfo = weaponInfo.Value.Projectile;
|
||||
if (projectileInfo == null)
|
||||
continue;
|
||||
|
||||
var fields = projectileInfo.GetType().GetFields();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
if (field.HasAttribute<SequenceReferenceAttribute>())
|
||||
{
|
||||
var sequences = LintExts.GetFieldValues(projectileInfo, field, emitError);
|
||||
foreach (var sequence in sequences)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sequence))
|
||||
continue;
|
||||
|
||||
var sequenceReference = field.GetCustomAttributes<SequenceReferenceAttribute>(true).FirstOrDefault();
|
||||
if (sequenceReference != null && !string.IsNullOrEmpty(sequenceReference.ImageReference))
|
||||
{
|
||||
var imageField = fields.FirstOrDefault(f => f.Name == sequenceReference.ImageReference);
|
||||
if (imageField != null)
|
||||
{
|
||||
foreach (var imageOverride in LintExts.GetFieldValues(projectileInfo, imageField, emitError))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(imageOverride))
|
||||
{
|
||||
var definitions = sequenceDefinitions.FirstOrDefault(n => n.Key == imageOverride.ToLowerInvariant());
|
||||
if (definitions == null)
|
||||
emitWarning("Can't find sequence definition for projectile image {0} at weapon {1}.".F(imageOverride, weaponInfo.Key));
|
||||
else if (!definitions.Value.Nodes.Any(n => n.Key == sequence))
|
||||
emitWarning("Projectile sprite image {0} from weapon {1} does not define sequence {2} from field {3} of {4}"
|
||||
.F(imageOverride, weaponInfo.Key, sequence, field.Name, projectileInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user