Fix CA1851

This commit is contained in:
RoosterDragon
2023-07-13 20:08:36 +01:00
committed by abcdefg30
parent 88f830a9e5
commit 3275875ae5
63 changed files with 349 additions and 267 deletions

View File

@@ -54,13 +54,15 @@ namespace OpenRA.Mods.Common.Traits
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos<LocomotorInfo>();
LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor);
if (LocomotorInfo == null)
var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos<LocomotorInfo>()
.Where(li => li.Name == Locomotor).ToList();
if (locomotorInfos.Count == 0)
throw new YamlException($"A locomotor named '{Locomotor}' doesn't exist.");
else if (locomotorInfos.Count(li => li.Name == Locomotor) > 1)
else if (locomotorInfos.Count > 1)
throw new YamlException($"There is more than one locomotor named '{Locomotor}'.");
LocomotorInfo = locomotorInfos[0];
base.RulesetLoaded(rules, ai);
}
}