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

@@ -358,14 +358,11 @@ namespace OpenRA.Mods.Cnc.Traits
bool IsValidTarget(CPos xy)
{
// Don't teleport if there are no units in range (either all moved out of range, or none yet moved into range)
var unitsInRange = power.UnitsInRange(sourceLocation);
if (!unitsInRange.Any())
return false;
var canTeleport = false;
foreach (var unit in unitsInRange)
var anyUnitsInRange = false;
foreach (var unit in power.UnitsInRange(sourceLocation))
{
anyUnitsInRange = true;
var targetCell = unit.Location + (xy - sourceLocation);
if (manager.Self.Owner.Shroud.IsExplored(targetCell) && unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell))
{
@@ -374,6 +371,10 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
// Don't teleport if there are no units in range (either all moved out of range, or none yet moved into range)
if (!anyUnitsInRange)
return false;
if (!canTeleport)
{
// Check the terrain types. This will allow chronoshifts to occur on empty terrain to terrain of