Fix CA1851
This commit is contained in:
@@ -133,15 +133,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override TraitPair<Production> MostLikelyProducer()
|
||||
{
|
||||
var productionActors = self.World.ActorsWithTrait<Production>()
|
||||
var productionActor = self.World.ActorsWithTrait<Production>()
|
||||
.Where(x => x.Actor.Owner == self.Owner
|
||||
&& !x.Trait.IsTraitDisabled && x.Trait.Info.Produces.Contains(Info.Type))
|
||||
.OrderByDescending(x => x.Actor.IsPrimaryBuilding())
|
||||
.OrderBy(x => x.Trait.IsTraitPaused)
|
||||
.ThenByDescending(x => x.Actor.IsPrimaryBuilding())
|
||||
.ThenByDescending(x => x.Actor.ActorID)
|
||||
.ToList();
|
||||
.FirstOrDefault();
|
||||
|
||||
var unpaused = productionActors.FirstOrDefault(a => !a.Trait.IsTraitPaused);
|
||||
return unpaused.Trait != null ? unpaused : productionActors.FirstOrDefault();
|
||||
return productionActor;
|
||||
}
|
||||
|
||||
protected override bool BuildUnit(ActorInfo unit)
|
||||
@@ -159,14 +159,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.OrderByDescending(x => x.Actor.IsPrimaryBuilding())
|
||||
.ThenByDescending(x => x.Actor.ActorID);
|
||||
|
||||
if (!producers.Any())
|
||||
{
|
||||
CancelProduction(unit.Name, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
var anyProducers = false;
|
||||
foreach (var p in producers)
|
||||
{
|
||||
anyProducers = true;
|
||||
if (p.Trait.IsTraitPaused)
|
||||
continue;
|
||||
|
||||
@@ -184,6 +180,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyProducers)
|
||||
{
|
||||
CancelProduction(unit.Name, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user