Merge pull request #7230 from RoosterDragon/occupied-cells-arrays
Make OccupiedCells implementations return arrays.
This commit is contained in:
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.QueueActivity(new Drag(self, CenterPosition, finalPosition, distance / dragSpeed));
|
self.QueueActivity(new Drag(self, CenterPosition, finalPosition, distance / dragSpeed));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(TopLeft, SubCell.FullCell); }
|
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return new[] { Pair.New(TopLeft, SubCell.FullCell) }; }
|
||||||
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return false; }
|
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return false; }
|
||||||
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
|
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
|
||||||
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true)
|
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CPos TopLeft { get { return Location; } }
|
public CPos TopLeft { get { return Location; } }
|
||||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(Location, SubCell.FullCell); }
|
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return new[] { Pair.New(Location, SubCell.FullCell) }; }
|
||||||
|
|
||||||
public WPos CenterPosition { get; private set; }
|
public WPos CenterPosition { get; private set; }
|
||||||
public void SetPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
public void SetPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
||||||
|
|||||||
@@ -486,14 +486,10 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells()
|
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells()
|
||||||
{
|
{
|
||||||
if (fromCell == toCell)
|
if (fromCell == toCell)
|
||||||
yield return Pair.New(fromCell, fromSubCell);
|
return new[] { Pair.New(fromCell, fromSubCell) };
|
||||||
else if (CanEnterCell(toCell))
|
if (CanEnterCell(toCell))
|
||||||
yield return Pair.New(toCell, toSubCell);
|
return new[] { Pair.New(toCell, toSubCell) };
|
||||||
else
|
return new[] { Pair.New(fromCell, fromSubCell), Pair.New(toCell, toSubCell) };
|
||||||
{
|
|
||||||
yield return Pair.New(fromCell, fromSubCell);
|
|
||||||
yield return Pair.New(toCell, toSubCell);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any)
|
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any)
|
||||||
|
|||||||
Reference in New Issue
Block a user