Replace CPos.CenterPosition -> Map.CenterOfCell.
This commit is contained in:
@@ -55,8 +55,8 @@ namespace OpenRA.Mods.RA.Activities
|
||||
// TODO: calculate weapons ranges of units and factor those in instead of hard-coding 8.
|
||||
var path = self.World.WorldActor.Trait<PathFinder>().FindPath(
|
||||
PathSearch.Search(self.World, mobileInfo, self, true)
|
||||
.WithCustomCost(loc => self.World.FindActorsInCircle(loc.CenterPosition, WRange.FromCells(8))
|
||||
.Where (u => !u.Destroyed && self.Owner.Stances[u.Owner] == Stance.Enemy)
|
||||
.WithCustomCost(loc => self.World.FindActorsInCircle(self.World.Map.CenterOfCell(loc), WRange.FromCells(8))
|
||||
.Where(u => !u.Destroyed && self.Owner.Stances[u.Owner] == Stance.Enemy)
|
||||
.Sum(u => Math.Max(0, 64 - (loc - u.Location).LengthSquared)))
|
||||
.WithHeuristic(loc =>
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
mobile.IsMoving = true;
|
||||
|
||||
from = self.CenterPosition;
|
||||
to = targetMobile.fromCell.CenterPosition + MobileInfo.SubCellOffsets[targetMobile.fromSubCell];
|
||||
to = self.World.Map.CenterOfCell(targetMobile.fromCell) + MobileInfo.SubCellOffsets[targetMobile.fromSubCell];
|
||||
length = Math.Max((to - from).Length / speed.Range, 1);
|
||||
|
||||
self.Trait<RenderInfantry>().Attacking(self, Target.FromActor(target));
|
||||
|
||||
@@ -43,11 +43,12 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
protected override IEnumerable<CPos> CandidateMovementCells(Actor self)
|
||||
{
|
||||
var map = self.World.Map;
|
||||
var maxCells = (maxRange.Range + 1023) / 1024;
|
||||
var outerCells = self.World.Map.FindTilesInCircle(targetPosition, maxCells);
|
||||
var outerCells = map.FindTilesInCircle(targetPosition, maxCells);
|
||||
|
||||
var minCells = minRange.Range / 1024;
|
||||
var innerCells = self.World.Map.FindTilesInCircle(targetPosition, minCells);
|
||||
var innerCells = map.FindTilesInCircle(targetPosition, minCells);
|
||||
|
||||
var outerSq = maxRange.Range * maxRange.Range;
|
||||
var innerSq = minRange.Range * minRange.Range;
|
||||
@@ -55,7 +56,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
return outerCells.Except(innerCells).Where(c =>
|
||||
{
|
||||
var dxSq = (c.CenterPosition - center).HorizontalLengthSquared;
|
||||
var dxSq = (map.CenterOfCell(c) - center).HorizontalLengthSquared;
|
||||
return dxSq >= innerSq && dxSq <= outerSq;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
destination = bestCell.Value;
|
||||
|
||||
Sound.Play(sound, self.CenterPosition);
|
||||
Sound.Play(sound, destination.CenterPosition);
|
||||
Sound.Play(sound, self.World.Map.CenterOfCell(destination));
|
||||
|
||||
self.Trait<IPositionable>().SetPosition(self, destination);
|
||||
self.Generation++;
|
||||
|
||||
Reference in New Issue
Block a user