diff --git a/OpenRA.Game/CPos.cs b/OpenRA.Game/CPos.cs index 2a9739438d..1557665202 100644 --- a/OpenRA.Game/CPos.cs +++ b/OpenRA.Game/CPos.cs @@ -40,10 +40,6 @@ namespace OpenRA public float2 ToFloat2() { return new float2(X, Y); } public int2 ToInt2() { return new int2(X, Y); } - public WPos CenterPosition { get { return new WPos(1024 * X + 512, 1024 * Y + 512, 0); } } - public WPos TopLeft { get { return new WPos(1024 * X, 1024 * Y, 0); } } - public WPos BottomRight { get { return new WPos(1024 * X + 1023, 1024 * Y + 1023, 0); } } - public CPos Clamp(Rectangle r) { return new CPos(Math.Min(r.Right, Math.Max(X, r.Left)), diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index 7d55487720..11dc2f142d 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -31,7 +31,7 @@ namespace OpenRA.Graphics foreach (var cell in map.Cells) { var tile = wr.Theater.TileSprite(map.MapTiles.Value[cell]); - var pos = wr.ScreenPosition(cell.CenterPosition) - 0.5f * tile.size; + var pos = wr.ScreenPosition(map.CenterOfCell(cell)) - 0.5f * tile.size; Util.FastCreateQuad(vertices, pos, tile, terrainPalette, nv, tile.size); nv += 4; } diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs old mode 100755 new mode 100644 index 1dd6a5f881..c28a9b7f6b --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -90,8 +90,10 @@ namespace OpenRA.Graphics // Calculate map bounds in world-px var b = map.Bounds; - var tl = wr.ScreenPxPosition(new CPos(b.Left, b.Top).TopLeft); - var br = wr.ScreenPxPosition(new CPos(b.Right, b.Bottom).BottomRight); + + // Expand to corners of cells + var tl = wr.ScreenPxPosition(map.CenterOfCell(new CPos(b.Left, b.Top)) - new WVec(512, 512, 0)); + var br = wr.ScreenPxPosition(map.CenterOfCell(new CPos(b.Right, b.Bottom)) + new WVec(511, 511, 0)); mapBounds = Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y); CenterLocation = (tl + br) / 2; @@ -131,8 +133,8 @@ namespace OpenRA.Graphics { get { - var ctl = VisibleCells.TopLeft.TopLeft; - var cbr = VisibleCells.BottomRight.BottomRight; + var ctl = worldRenderer.world.Map.CenterOfCell(VisibleCells.TopLeft) - new WVec(512, 512, 0); + var cbr = worldRenderer.world.Map.CenterOfCell(VisibleCells.BottomRight) + new WVec(511, 511, 0); var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl)).Clamp(ScreenClip); var br = WorldToViewPx(worldRenderer.ScreenPxPosition(cbr)).Clamp(ScreenClip); return Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y); diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 06f3b9019d..df9256d155 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -461,7 +461,15 @@ namespace OpenRA return dataStream.ToArray(); } - public bool Contains(CPos xy) { return Bounds.Contains(xy.X, xy.Y); } + public bool Contains(CPos cell) + { + return Bounds.Contains(cell.X, cell.Y); + } + + public WPos CenterOfCell(CPos c) + { + return new WPos(1024 * c.X + 512, 1024 * c.Y + 512, 0); + } public void Resize(int width, int height) // editor magic. { @@ -604,8 +612,8 @@ namespace OpenRA public WRange DistanceToEdge(WPos pos, WVec dir) { - var tl = Bounds.TopLeftAsCPos().TopLeft; - var br = Bounds.BottomRightAsCPos().BottomRight; + var tl = CenterOfCell(new CPos(Bounds.Left, Bounds.Top)) - new WVec(512, 512, 0); + var br = CenterOfCell(new CPos(Bounds.Right, Bounds.Bottom)) + new WVec(511, 511, 0); var x = dir.X == 0 ? int.MaxValue : ((dir.X < 0 ? tl.X : br.X) - pos.X) / dir.X; var y = dir.Y == 0 ? int.MaxValue : ((dir.Y < 0 ? tl.Y : br.Y) - pos.Y) / dir.Y; return new WRange(Math.Min(x, y) * dir.Length); diff --git a/OpenRA.Game/Traits/Target.cs b/OpenRA.Game/Traits/Target.cs index 9ad568aee2..0228917c20 100644 --- a/OpenRA.Game/Traits/Target.cs +++ b/OpenRA.Game/Traits/Target.cs @@ -28,7 +28,7 @@ namespace OpenRA.Traits int generation; public static Target FromPos(WPos p) { return new Target { pos = p, type = TargetType.Terrain }; } - public static Target FromCell(World w, CPos c) { return new Target { pos = c.CenterPosition, type = TargetType.Terrain }; } + public static Target FromCell(World w, CPos c) { return new Target { pos = w.Map.CenterOfCell(c), type = TargetType.Terrain }; } public static Target FromOrder(World w, Order o) { return o.TargetActor != null diff --git a/OpenRA.Game/Traits/Util.cs b/OpenRA.Game/Traits/Util.cs index 3223d83688..10f8973087 100644 --- a/OpenRA.Game/Traits/Util.cs +++ b/OpenRA.Game/Traits/Util.cs @@ -67,7 +67,7 @@ namespace OpenRA.Traits public static WPos BetweenCells(World w, CPos from, CPos to) { - return WPos.Lerp(from.CenterPosition, to.CenterPosition, 1, 2); + return WPos.Lerp(w.Map.CenterOfCell(from), w.Map.CenterOfCell(to), 1, 2); } public static Activity SequenceActivities(params Activity[] acts) diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index 0f405e1931..357c11339a 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -35,7 +35,7 @@ namespace OpenRA.Traits var c = render[cell]; if (c.Sprite != null) - new SpriteRenderable(c.Sprite, cell.CenterPosition, + new SpriteRenderable(c.Sprite, wr.world.Map.CenterOfCell(cell), WVec.Zero, -511, c.Type.Palette, 1f, true).Render(wr); } } diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 154dc66384..9692ddbff6 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -65,12 +65,13 @@ namespace OpenRA.Traits static IEnumerable FindVisibleTiles(World world, CPos position, WRange radius) { + var map = world.Map; var r = (radius.Range + 1023) / 1024; var limit = radius.Range * radius.Range; - var pos = position.CenterPosition; + var pos = map.CenterOfCell(position); - foreach (var cell in world.Map.FindTilesInCircle(position, r)) - if ((cell.CenterPosition - pos).HorizontalLengthSquared <= limit) + foreach (var cell in map.FindTilesInCircle(position, r)) + if ((map.CenterOfCell(cell) - pos).HorizontalLengthSquared <= limit) yield return cell; } diff --git a/OpenRA.Mods.Cnc/IonCannonPower.cs b/OpenRA.Mods.Cnc/IonCannonPower.cs index 92f25fddd7..116eb958fd 100644 --- a/OpenRA.Mods.Cnc/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/IonCannonPower.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc self.World.AddFrameEndTask(w => { var info = Info as IonCannonPowerInfo; - Sound.Play(Info.LaunchSound, order.TargetLocation.CenterPosition); + Sound.Play(Info.LaunchSound, self.World.Map.CenterOfCell(order.TargetLocation)); w.Add(new IonCannon(self.Owner, info.Weapon, w, order.TargetLocation, info.Effect, info.EffectPalette)); if (info.CameraActor == null) diff --git a/OpenRA.Mods.Cnc/ProductionAirdrop.cs b/OpenRA.Mods.Cnc/ProductionAirdrop.cs index 342f113a5e..c72b0e2205 100644 --- a/OpenRA.Mods.Cnc/ProductionAirdrop.cs +++ b/OpenRA.Mods.Cnc/ProductionAirdrop.cs @@ -55,7 +55,7 @@ namespace OpenRA.Mods.Cnc var altitude = self.World.Map.Rules.Actors[actorType].Traits.Get().CruiseAltitude; var a = w.CreateActor(actorType, new TypeDictionary { - new CenterPositionInit(startPos.CenterPosition + new WVec(WRange.Zero, WRange.Zero, altitude)), + new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WRange.Zero, WRange.Zero, altitude)), new OwnerInit(owner), new FacingInit(64) }); diff --git a/OpenRA.Mods.RA/AI/HackyAI.cs b/OpenRA.Mods.RA/AI/HackyAI.cs index 3d1bd3cf3c..22292835c2 100644 --- a/OpenRA.Mods.RA/AI/HackyAI.cs +++ b/OpenRA.Mods.RA/AI/HackyAI.cs @@ -348,7 +348,7 @@ namespace OpenRA.Mods.RA.AI for (var k = MaxBaseDistance; k >= 0; k--) { var tlist = Map.FindTilesInCircle(center, k) - .OrderBy(a => (a.CenterPosition - pos).LengthSquared); + .OrderBy(a => (world.Map.CenterOfCell(a) - pos).LengthSquared); foreach (var t in tlist) if (world.CanPlaceBuilding(actorType, bi, t, null)) @@ -360,10 +360,11 @@ namespace OpenRA.Mods.RA.AI return null; }; + var baseCenterPos = world.Map.CenterOfCell(baseCenter); switch (type) { case BuildingType.Defense: - var enemyBase = FindEnemyBuildingClosestToPos(baseCenter.CenterPosition); + var enemyBase = FindEnemyBuildingClosestToPos(baseCenterPos); return enemyBase != null ? findPos(enemyBase.CenterPosition, defenseCenter) : null; case BuildingType.Refinery: @@ -371,11 +372,12 @@ namespace OpenRA.Mods.RA.AI .Where(a => resourceTypeIndices.Contains(Map.GetTerrainIndex(new CPos(a.X, a.Y)))); if (tilesPos.Any()) { - var pos = tilesPos.MinBy(a => (a.CenterPosition - baseCenter.CenterPosition).LengthSquared); - return findPos(pos.CenterPosition, baseCenter); + var pos = tilesPos.MinBy(a => (world.Map.CenterOfCell(a) - baseCenterPos).LengthSquared); + return findPos(world.Map.CenterOfCell(pos), baseCenter); } return null; + case BuildingType.Building: for (var k = 0; k < maxBaseDistance; k++) { @@ -441,7 +443,7 @@ namespace OpenRA.Mods.RA.AI // Pick something worth attacking owned by that player var target = world.Actors .Where(a => a.Owner == enemy && a.HasTrait()) - .ClosestTo(baseCenter.CenterPosition); + .ClosestTo(world.Map.CenterOfCell(baseCenter)); if (target == null) { @@ -661,7 +663,7 @@ namespace OpenRA.Mods.RA.AI if (!protectSq.IsValid) { - var ownUnits = world.FindActorsInCircle(baseCenter.CenterPosition, WRange.FromCells(Info.ProtectUnitScanRadius)) + var ownUnits = world.FindActorsInCircle(world.Map.CenterOfCell(baseCenter), WRange.FromCells(Info.ProtectUnitScanRadius)) .Where(unit => unit.Owner == p && !unit.HasTrait() && unit.HasTrait()).ToList(); @@ -790,8 +792,8 @@ namespace OpenRA.Mods.RA.AI { for (var j = 0; j < y; j += radiusOfPower * 2) { - var pos = new CPos(i, j); - var targets = world.FindActorsInCircle(pos.CenterPosition, WRange.FromCells(radiusOfPower)).ToList(); + var pos = world.Map.CenterOfCell(new CPos(i, j)); + var targets = world.FindActorsInCircle(pos, WRange.FromCells(radiusOfPower)).ToList(); var enemies = targets.Where(unit => p.Stances[unit.Owner] == Stance.Enemy).ToList(); var ally = targets.Where(unit => p.Stances[unit.Owner] == Stance.Ally || unit.Owner == p).ToList(); diff --git a/OpenRA.Mods.RA/AI/States/AirStates.cs b/OpenRA.Mods.RA/AI/States/AirStates.cs index 685347504b..d14db90896 100644 --- a/OpenRA.Mods.RA/AI/States/AirStates.cs +++ b/OpenRA.Mods.RA/AI/States/AirStates.cs @@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA.AI for (var j = 0; j < y; j += DangerRadius * 2) { var pos = new CPos(i, j); - if (NearToPosSafely(owner, pos.CenterPosition, out detectedEnemyTarget)) + if (NearToPosSafely(owner, owner.world.Map.CenterOfCell(pos), out detectedEnemyTarget)) { if (needTarget && detectedEnemyTarget == null) continue; diff --git a/OpenRA.Mods.RA/Activities/FindResources.cs b/OpenRA.Mods.RA/Activities/FindResources.cs index 101dbbecb1..c2ace67f6e 100755 --- a/OpenRA.Mods.RA/Activities/FindResources.cs +++ b/OpenRA.Mods.RA/Activities/FindResources.cs @@ -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().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 => { diff --git a/OpenRA.Mods.RA/Activities/Leap.cs b/OpenRA.Mods.RA/Activities/Leap.cs index 9ab86d9335..ff5b56edd2 100644 --- a/OpenRA.Mods.RA/Activities/Leap.cs +++ b/OpenRA.Mods.RA/Activities/Leap.cs @@ -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().Attacking(self, Target.FromActor(target)); diff --git a/OpenRA.Mods.RA/Activities/MoveWithinRange.cs b/OpenRA.Mods.RA/Activities/MoveWithinRange.cs index 20eb9b4ce6..3093f3c4e4 100755 --- a/OpenRA.Mods.RA/Activities/MoveWithinRange.cs +++ b/OpenRA.Mods.RA/Activities/MoveWithinRange.cs @@ -43,11 +43,12 @@ namespace OpenRA.Mods.RA.Activities protected override IEnumerable 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; }); } diff --git a/OpenRA.Mods.RA/Activities/Teleport.cs b/OpenRA.Mods.RA/Activities/Teleport.cs index 9b80ce7c69..c8a0003cfd 100755 --- a/OpenRA.Mods.RA/Activities/Teleport.cs +++ b/OpenRA.Mods.RA/Activities/Teleport.cs @@ -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().SetPosition(self, destination); self.Generation++; diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index cd05962639..5c2cb96416 100755 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -114,7 +114,7 @@ namespace OpenRA.Mods.RA.Air } // Changes position, but not altitude - public void SetPosition(Actor self, CPos cell) { SetPosition(self, cell.CenterPosition + new WVec(0, 0, CenterPosition.Z)); } + public void SetPosition(Actor self, CPos cell) { SetPosition(self, self.World.Map.CenterOfCell(cell) + new WVec(0, 0, CenterPosition.Z)); } public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos); } public void AddedToWorld(Actor self) diff --git a/OpenRA.Mods.RA/Attack/AttackBase.cs b/OpenRA.Mods.RA/Attack/AttackBase.cs index 00619c7c17..e17b27e917 100644 --- a/OpenRA.Mods.RA/Attack/AttackBase.cs +++ b/OpenRA.Mods.RA/Attack/AttackBase.cs @@ -223,7 +223,7 @@ namespace OpenRA.Mods.RA if (modifiers.HasModifier(TargetModifiers.ForceAttack)) { var maxRange = ab.GetMaximumRange().Range; - var targetRange = (location.CenterPosition - self.CenterPosition).HorizontalLengthSquared; + var targetRange = (self.World.Map.CenterOfCell(location) - self.CenterPosition).HorizontalLengthSquared; if (targetRange > maxRange * maxRange) cursor = ab.info.OutsideRangeCursor; diff --git a/OpenRA.Mods.RA/Bridge.cs b/OpenRA.Mods.RA/Bridge.cs index 6fa095944c..7177156f11 100644 --- a/OpenRA.Mods.RA/Bridge.cs +++ b/OpenRA.Mods.RA/Bridge.cs @@ -122,7 +122,7 @@ namespace OpenRA.Mods.RA { return footprint.Select(c => (IRenderable)(new SpriteRenderable( wr.Theater.TileSprite(new TerrainTile(template, c.Value)), - c.Key.CenterPosition, WVec.Zero, -512, palette, 1f, true))).ToArray(); + wr.world.Map.CenterOfCell(c.Key), WVec.Zero, -512, palette, 1f, true))).ToArray(); } bool initialized; diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index 318a36c9a4..651583ada1 100644 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Buildings public Actor FindBaseProvider(World world, Player p, CPos topLeft) { - var center = topLeft.CenterPosition + FootprintUtils.CenterOffset(this); + var center = world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(this); foreach (var bp in world.ActorsWithTrait()) { var validOwner = bp.Actor.Owner == p || (world.LobbyInfo.GlobalSettings.AllyBuildRadius && bp.Actor.Owner.Stances[p] == Stance.Ally); @@ -137,7 +137,7 @@ namespace OpenRA.Mods.RA.Buildings occupiedCells = FootprintUtils.UnpathableTiles( self.Info.Name, Info, TopLeft ) .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); - CenterPosition = topLeft.CenterPosition + FootprintUtils.CenterOffset(Info); + CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(Info); BuildComplete = init.Contains(); } diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index 09484ef770..22df8bdf43 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.RA { self.World.ActorMap.RemoveInfluence(self, this); Location = cell; - CenterPosition = cell.CenterPosition; + CenterPosition = self.World.Map.CenterOfCell(cell); if (self.IsInWorld) { diff --git a/OpenRA.Mods.RA/CrateSpawner.cs b/OpenRA.Mods.RA/CrateSpawner.cs index 5de5945980..5fdad6ed9c 100644 --- a/OpenRA.Mods.RA/CrateSpawner.cs +++ b/OpenRA.Mods.RA/CrateSpawner.cs @@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA var altitude = w.Map.Rules.Actors[info.DeliveryAircraft].Traits.Get().CruiseAltitude; var plane = w.CreateActor(info.DeliveryAircraft, new TypeDictionary { - new CenterPositionInit(startPos.CenterPosition + new WVec(WRange.Zero, WRange.Zero, altitude)), + new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WRange.Zero, WRange.Zero, altitude)), new OwnerInit(w.WorldActor.Owner), new FacingInit(Util.GetFacing(p - startPos, 0)) }); diff --git a/OpenRA.Mods.RA/Effects/RallyPoint.cs b/OpenRA.Mods.RA/Effects/RallyPoint.cs index 6a4731a5a7..de9ed6cd30 100755 --- a/OpenRA.Mods.RA/Effects/RallyPoint.cs +++ b/OpenRA.Mods.RA/Effects/RallyPoint.cs @@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Effects if (!building.IsInWorld || !building.World.Selection.Actors.Contains(building)) return SpriteRenderable.None; - var pos = cachedLocation.CenterPosition; + var pos = wr.world.Map.CenterOfCell(cachedLocation); var palette = wr.Palette(palettePrefix+building.Owner.InternalName); return circles.Render(pos, palette).Concat(flag.Render(pos, palette)); } diff --git a/OpenRA.Mods.RA/Husk.cs b/OpenRA.Mods.RA/Husk.cs index 1fc5e813d9..e81151c1f6 100644 --- a/OpenRA.Mods.RA/Husk.cs +++ b/OpenRA.Mods.RA/Husk.cs @@ -42,13 +42,14 @@ namespace OpenRA.Mods.RA this.self = init.self; TopLeft = init.Get(); - CenterPosition = init.Contains() ? init.Get() : TopLeft.CenterPosition; + CenterPosition = init.Contains() ? init.Get() : init.world.Map.CenterOfCell(TopLeft); Facing = init.Contains() ? init.Get() : 128; var speed = init.Contains() ? init.Get() : 0; - var distance = (TopLeft.CenterPosition - CenterPosition).Length; + var finalPos = init.world.Map.CenterOfCell(TopLeft); + var distance = (finalPos - CenterPosition).Length; if (speed > 0 && distance > 0) - self.QueueActivity(new Drag(CenterPosition, TopLeft.CenterPosition, distance / speed)); + self.QueueActivity(new Drag(CenterPosition, finalPos, distance / speed)); } public IEnumerable> OccupiedCells() { yield return Pair.New(TopLeft, SubCell.FullCell); } @@ -69,8 +70,8 @@ namespace OpenRA.Mods.RA } public bool CanEnterCell(CPos cell) { return CanEnterCell(cell, null, true); } + public void SetPosition(Actor self, CPos cell) { SetPosition(self, self.World.Map.CenterOfCell(cell)); } - public void SetPosition(Actor self, CPos cell) { SetPosition(self, cell.CenterPosition); } public void SetVisualPosition(Actor self, WPos pos) { CenterPosition = pos; diff --git a/OpenRA.Mods.RA/Immobile.cs b/OpenRA.Mods.RA/Immobile.cs index 2f5b16dd7f..63570e95a8 100644 --- a/OpenRA.Mods.RA/Immobile.cs +++ b/OpenRA.Mods.RA/Immobile.cs @@ -23,11 +23,13 @@ namespace OpenRA.Mods.RA class Immobile : IOccupySpace, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld { [Sync] readonly CPos location; + [Sync] readonly WPos position; readonly IEnumerable> occupied; public Immobile(ActorInitializer init, ImmobileInfo info) { - this.location = init.Get(); + location = init.Get(); + position = init.world.Map.CenterOfCell(location); if (info.OccupiesSpace) occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) }; @@ -36,8 +38,8 @@ namespace OpenRA.Mods.RA } public CPos TopLeft { get { return location; } } + public WPos CenterPosition { get { return position; } } public IEnumerable> OccupiedCells() { return occupied; } - public WPos CenterPosition { get { return location.CenterPosition; } } public void AddedToWorld(Actor self) { diff --git a/OpenRA.Mods.RA/MPStartLocations.cs b/OpenRA.Mods.RA/MPStartLocations.cs index 695dcf6467..364138d949 100755 --- a/OpenRA.Mods.RA/MPStartLocations.cs +++ b/OpenRA.Mods.RA/MPStartLocations.cs @@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA // Set viewport if (world.LocalPlayer != null && Start.ContainsKey(world.LocalPlayer)) - wr.Viewport.Center(Start[world.LocalPlayer].CenterPosition); + wr.Viewport.Center(world.Map.CenterOfCell(Start[world.LocalPlayer])); } static Player FindPlayerInSlot(World world, string pr) diff --git a/OpenRA.Mods.RA/Minelayer.cs b/OpenRA.Mods.RA/Minelayer.cs index 88d642bd5a..d8679b7f5a 100644 --- a/OpenRA.Mods.RA/Minelayer.cs +++ b/OpenRA.Mods.RA/Minelayer.cs @@ -121,7 +121,7 @@ namespace OpenRA.Mods.RA var pal = wr.Palette("terrain"); foreach (var c in Minefield) - new SpriteRenderable(tile, c.CenterPosition, + new SpriteRenderable(tile, self.World.Map.CenterOfCell(c), WVec.Zero, -511, pal, 1f, true).Render(wr); } @@ -183,7 +183,7 @@ namespace OpenRA.Mods.RA foreach (var c in minefield) { var tile = movement.CanEnterCell(c) ? tileOk : tileBlocked; - new SpriteRenderable(tile, c.CenterPosition, + new SpriteRenderable(tile, world.Map.CenterOfCell(c), WVec.Zero, -511, pal, 1f, true).Render(wr); } } diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 0af1b5fdff..22a46dc35f 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -246,7 +246,7 @@ namespace OpenRA.Mods.RA.Move if (init.Contains()) { this.__fromCell = this.__toCell = init.Get(); - SetVisualPosition(self, fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]); + SetVisualPosition(self, init.world.Map.CenterOfCell(fromCell) + MobileInfo.SubCellOffsets[fromSubCell]); } this.Facing = init.Contains() ? init.Get() : info.InitialFacing; @@ -260,7 +260,7 @@ namespace OpenRA.Mods.RA.Move public void SetPosition(Actor self, CPos cell) { SetLocation(cell, fromSubCell, cell, fromSubCell); - SetVisualPosition(self, fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]); + SetVisualPosition(self, self.World.Map.CenterOfCell(fromCell) + MobileInfo.SubCellOffsets[fromSubCell]); FinishedMoving(self); } @@ -611,7 +611,7 @@ namespace OpenRA.Mods.RA.Move SetVisualPosition(self, pos); // Animate transition - var to = cell.CenterPosition; + var to = self.World.Map.CenterOfCell(cell); var speed = MovementSpeedForCell(self, cell); var length = speed > 0 ? (to - pos).Length / speed : 0; diff --git a/OpenRA.Mods.RA/Move/Move.cs b/OpenRA.Mods.RA/Move/Move.cs index 6c40974b0a..1af21831fb 100755 --- a/OpenRA.Mods.RA/Move/Move.cs +++ b/OpenRA.Mods.RA/Move/Move.cs @@ -151,7 +151,7 @@ namespace OpenRA.Mods.RA.Move mobile.SetLocation(mobile.fromCell, mobile.fromSubCell, nextCell.Value.First, nextCell.Value.Second); var move = new MoveFirstHalf( this, - mobile.fromCell.CenterPosition + MobileInfo.SubCellOffsets[mobile.fromSubCell], + self.World.Map.CenterOfCell(mobile.fromCell) + MobileInfo.SubCellOffsets[mobile.fromSubCell], Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (MobileInfo.SubCellOffsets[mobile.fromSubCell] + MobileInfo.SubCellOffsets[mobile.toSubCell]) / 2, mobile.Facing, mobile.Facing, @@ -375,7 +375,7 @@ namespace OpenRA.Mods.RA.Move var ret2 = new MoveSecondHalf( move, Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2, - mobile.toCell.CenterPosition + toSubcellOffset, + self.World.Map.CenterOfCell(mobile.toCell) + toSubcellOffset, mobile.Facing, mobile.Facing, moveFraction - moveFractionTotal); diff --git a/OpenRA.Mods.RA/Move/PathFinder.cs b/OpenRA.Mods.RA/Move/PathFinder.cs index 444fdaae57..c1431f5445 100644 --- a/OpenRA.Mods.RA/Move/PathFinder.cs +++ b/OpenRA.Mods.RA/Move/PathFinder.cs @@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA.Move // Select only the tiles that are within range from the requested SubCell // This assumes that the SubCell does not change during the path traversal var tilesInRange = world.Map.FindTilesInCircle(targetCell, range.Range / 1024 + 1) - .Where(t => (t.CenterPosition - target).LengthSquared <= rangeSquared + .Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= rangeSquared && mi.CanEnterCell(self.World, self, t, null, true, true)); // See if there is any cell within range that does not involve a cross-domain request diff --git a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs index 46ee716d4d..8d5742f97d 100644 --- a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs @@ -86,7 +86,7 @@ namespace OpenRA.Mods.RA.Orders var actorInfo = rules.Actors[Building]; foreach (var dec in actorInfo.Traits.WithInterface()) - dec.Render(wr, world, actorInfo, position.CenterPosition); /* hack hack */ + dec.Render(wr, world, actorInfo, world.Map.CenterOfCell(position)); var cells = new Dictionary(); // Linebuild for walls. @@ -114,7 +114,7 @@ namespace OpenRA.Mods.RA.Orders initialized = true; } - var offset = topLeft.CenterPosition + FootprintUtils.CenterOffset(BuildingInfo) - WPos.Zero; + var offset = world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(BuildingInfo) - WPos.Zero; foreach (var r in preview) r.OffsetBy(offset).Render(wr); @@ -128,7 +128,7 @@ namespace OpenRA.Mods.RA.Orders foreach (var c in cells) { var tile = c.Value ? buildOk : buildBlocked; - new SpriteRenderable(tile, c.Key.CenterPosition, + new SpriteRenderable(tile, world.Map.CenterOfCell(c.Key), WVec.Zero, -511, pal, 1f, true).Render(wr); } } diff --git a/OpenRA.Mods.RA/Player/PlaceBeacon.cs b/OpenRA.Mods.RA/Player/PlaceBeacon.cs index 4b335ea6ed..d7a1b5da01 100644 --- a/OpenRA.Mods.RA/Player/PlaceBeacon.cs +++ b/OpenRA.Mods.RA/Player/PlaceBeacon.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA if (order.OrderString != "PlaceBeacon") return; - var pos = order.TargetLocation.CenterPosition; + var pos = self.World.Map.CenterOfCell(order.TargetLocation); self.World.AddFrameEndTask(w => { diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index 8b7734ec42..701577f670 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA { var exit = self.Location + exitinfo.ExitCell; var spawn = self.CenterPosition + exitinfo.SpawnOffset; - var to = exit.CenterPosition; + var to = self.World.Map.CenterOfCell(exit); var fi = producee.Traits.Get(); var initialFacing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, fi.GetInitialFacing()) : exitinfo.Facing; diff --git a/OpenRA.Mods.RA/Render/WithBuildingExplosion.cs b/OpenRA.Mods.RA/Render/WithBuildingExplosion.cs index ba5e28c125..7019bc7d6a 100755 --- a/OpenRA.Mods.RA/Render/WithBuildingExplosion.cs +++ b/OpenRA.Mods.RA/Render/WithBuildingExplosion.cs @@ -22,8 +22,7 @@ namespace OpenRA.Mods.RA.Render //TODO: Make palette for this customizable as well var bi = self.Info.Traits.Get(); FootprintUtils.UnpathableTiles(self.Info.Name, bi, self.Location).Do( - t => self.World.AddFrameEndTask( - w => w.Add(new Explosion(w, t.CenterPosition, "building", "effect")))); + t => self.World.AddFrameEndTask(w => w.Add(new Explosion(w, w.Map.CenterOfCell(t), "building", "effect")))); } } } diff --git a/OpenRA.Mods.RA/Scripting/Global/UtilsGlobal.cs b/OpenRA.Mods.RA/Scripting/Global/UtilsGlobal.cs index 1e70d6a259..cb330e43cb 100644 --- a/OpenRA.Mods.RA/Scripting/Global/UtilsGlobal.cs +++ b/OpenRA.Mods.RA/Scripting/Global/UtilsGlobal.cs @@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA.Scripting [Desc("Returns the center of a cell in world coordinates.")] public WPos CenterOfCell(CPos cell) { - return cell.CenterPosition; + return context.World.Map.CenterOfCell(cell); } } } diff --git a/OpenRA.Mods.RA/ShroudRenderer.cs b/OpenRA.Mods.RA/ShroudRenderer.cs index f6de9030de..84f1eaf535 100644 --- a/OpenRA.Mods.RA/ShroudRenderer.cs +++ b/OpenRA.Mods.RA/ShroudRenderer.cs @@ -199,7 +199,7 @@ namespace OpenRA.Mods.RA // Initialize tile cache foreach (var cell in map.Cells) { - var screen = wr.ScreenPosition(cell.CenterPosition); + var screen = wr.ScreenPosition(w.Map.CenterOfCell(cell)); var variant = Game.CosmeticRandom.Next(info.ShroudVariants.Length); tiles[cell] = new ShroudTile(cell, screen, variant); } diff --git a/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs b/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs index d363863f8f..eadeeba275 100644 --- a/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA var delta = new WVec(0, -1024, 0).Rotate(attackRotation); var altitude = self.World.Map.Rules.Actors[info.UnitType].Traits.Get().CruiseAltitude.Range; - var target = order.TargetLocation.CenterPosition + new WVec(0, 0, altitude); + var target = self.World.Map.CenterOfCell(order.TargetLocation) + new WVec(0, 0, altitude); var startEdge = target - (self.World.Map.DistanceToEdge(target, -delta) + info.Cordon).Range * delta / 1024; var finishEdge = target + (self.World.Map.DistanceToEdge(target, delta) + info.Cordon).Range * delta / 1024; @@ -174,7 +174,7 @@ namespace OpenRA.Mods.RA beacon = new Beacon( order.Player, - order.TargetLocation.CenterPosition, + self.World.Map.CenterOfCell(order.TargetLocation), Info.BeaconPalettePrefix, Info.BeaconPoster, Info.BeaconPosterPalette, diff --git a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs index 4f76a76a0b..78e9ecdb1c 100644 --- a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs @@ -136,7 +136,7 @@ namespace OpenRA.Mods.RA var tiles = world.Map.FindTilesInCircle(xy, range); var pal = wr.Palette("terrain"); foreach (var t in tiles) - yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true); + yield return new SpriteRenderable(tile, wr.world.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true); } public string GetCursor(World world, CPos xy, MouseInput mi) @@ -217,11 +217,11 @@ namespace OpenRA.Mods.RA // Source tiles foreach (var t in world.Map.FindTilesInCircle(sourceLocation, range)) - yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true); + yield return new SpriteRenderable(sourceTile, wr.world.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true); // Destination tiles foreach (var t in world.Map.FindTilesInCircle(xy, range)) - yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true); + yield return new SpriteRenderable(sourceTile, wr.world.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true); // Unit previews foreach (var unit in power.UnitsInRange(sourceLocation)) @@ -241,7 +241,7 @@ namespace OpenRA.Mods.RA var canEnter = manager.self.Owner.Shroud.IsExplored(targetCell) && unit.Trait().CanChronoshiftTo(unit, targetCell); var tile = canEnter ? validTile : invalidTile; - yield return new SpriteRenderable(tile, targetCell.CenterPosition, WVec.Zero, -511, pal, 1f, true); + yield return new SpriteRenderable(tile, wr.world.Map.CenterOfCell(targetCell), WVec.Zero, -511, pal, 1f, true); } } } diff --git a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs index 5836b9f10e..62fd6b944a 100644 --- a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA self.Trait().PlayCustomAnim(self, "active"); - Sound.Play(info.IronCurtainSound, order.TargetLocation.CenterPosition); + Sound.Play(info.IronCurtainSound, self.World.Map.CenterOfCell(order.TargetLocation)); foreach (var target in UnitsInRange(order.TargetLocation) .Where(a => a.Owner.Stances[self.Owner] == Stance.Ally)) @@ -109,8 +109,9 @@ namespace OpenRA.Mods.RA { var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos(); var pal = wr.Palette("terrain"); + foreach (var t in world.Map.FindTilesInCircle(xy, range)) - yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true); + yield return new SpriteRenderable(tile, wr.world.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true); } public string GetCursor(World world, CPos xy, MouseInput mi) diff --git a/OpenRA.Mods.RA/SupportPowers/NukePower.cs b/OpenRA.Mods.RA/SupportPowers/NukePower.cs index b9c4609719..5e1582bcf4 100755 --- a/OpenRA.Mods.RA/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/NukePower.cs @@ -77,9 +77,10 @@ namespace OpenRA.Mods.RA var rb = self.Trait(); rb.PlayCustomAnim(self, "active"); + var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation); var missile = new NukeLaunch(self.Owner, npi.MissileWeapon, self.CenterPosition + body.LocalToWorld(npi.SpawnOffset), - order.TargetLocation.CenterPosition, + targetPosition, npi.FlightVelocity, npi.FlightDelay, npi.SkipAscent); self.World.AddFrameEndTask(w => w.Add(missile)); @@ -103,7 +104,7 @@ namespace OpenRA.Mods.RA { var beacon = new Beacon( order.Player, - order.TargetLocation.CenterPosition, + targetPosition, Info.BeaconPalettePrefix, Info.BeaconPoster, Info.BeaconPosterPalette, diff --git a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs index 201cef454a..24bbf0f0ed 100644 --- a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs @@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA var altitude = self.World.Map.Rules.Actors[info.UnitType].Traits.Get().CruiseAltitude; var a = w.CreateActor(info.UnitType, new TypeDictionary { - new CenterPositionInit(startPos.CenterPosition + new WVec(WRange.Zero, WRange.Zero, altitude)), + new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WRange.Zero, WRange.Zero, altitude)), new OwnerInit(self.Owner), new FacingInit(Util.GetFacing(order.TargetLocation - startPos, 0)) }); diff --git a/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs b/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs index e797cba278..d4ec13acbc 100644 --- a/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA var plane = self.World.CreateActor("u2", new TypeDictionary { - new CenterPositionInit(enterCell.CenterPosition + new WVec(WRange.Zero, WRange.Zero, altitude)), + new CenterPositionInit(self.World.Map.CenterOfCell(enterCell) + new WVec(WRange.Zero, WRange.Zero, altitude)), new OwnerInit(self.Owner), new FacingInit(Util.GetFacing(order.TargetLocation - enterCell, 0)) }); diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs index 506ad62584..a1cea59d42 100755 --- a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs @@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA { ping = manager.RadarPings.Value.Add( () => order.Player.IsAlliedWith(self.World.RenderPlayer), - order.TargetLocation.CenterPosition, + self.World.Map.CenterOfCell(order.TargetLocation), order.Player.Color.RGB, Info.RadarPingDuration); } diff --git a/OpenRA.Mods.RA/TargetableBuilding.cs b/OpenRA.Mods.RA/TargetableBuilding.cs index 0a14520987..ae2535cd31 100755 --- a/OpenRA.Mods.RA/TargetableBuilding.cs +++ b/OpenRA.Mods.RA/TargetableBuilding.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA public IEnumerable TargetablePositions(Actor self) { - return building.OccupiedCells().Select(c => c.First.CenterPosition); + return building.OccupiedCells().Select(c => self.World.Map.CenterOfCell(c.First)); } public bool RequiresForceFire { get { return info.RequiresForceFire; } } diff --git a/OpenRA.Mods.RA/Widgets/RadarWidget.cs b/OpenRA.Mods.RA/Widgets/RadarWidget.cs index 4a0a5e99c4..51717074a2 100755 --- a/OpenRA.Mods.RA/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.RA/Widgets/RadarWidget.cs @@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA.Widgets return null; var cell = MinimapPixelToCell(pos); - var location = worldRenderer.Viewport.WorldToViewPx(worldRenderer.ScreenPxPosition(cell.CenterPosition)); + var location = worldRenderer.Viewport.WorldToViewPx(worldRenderer.ScreenPxPosition(world.Map.CenterOfCell(cell))); var mi = new MouseInput { @@ -113,9 +113,9 @@ namespace OpenRA.Mods.RA.Widgets return true; var cell = MinimapPixelToCell(mi.Location); - var pos = cell.CenterPosition; + var pos = world.Map.CenterOfCell(cell); if ((mi.Event == MouseInputEvent.Down || mi.Event == MouseInputEvent.Move) && mi.Button == MouseButton.Left) - worldRenderer.Viewport.Center(cell.CenterPosition); + worldRenderer.Viewport.Center(world.Map.CenterOfCell(cell)); if (mi.Event == MouseInputEvent.Down && mi.Button == MouseButton.Right) { diff --git a/OpenRA.Mods.RA/World/BuildableTerrainLayer.cs b/OpenRA.Mods.RA/World/BuildableTerrainLayer.cs index e580673c99..481db4b25f 100644 --- a/OpenRA.Mods.RA/World/BuildableTerrainLayer.cs +++ b/OpenRA.Mods.RA/World/BuildableTerrainLayer.cs @@ -69,7 +69,7 @@ namespace OpenRA.Mods.RA if (wr.world.ShroudObscures(kv.Key)) continue; - new SpriteRenderable(kv.Value, kv.Key.CenterPosition, + new SpriteRenderable(kv.Value, wr.world.Map.CenterOfCell(kv.Key), WVec.Zero, -511, pal, 1f, true).Render(wr); } } diff --git a/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs b/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs index 17cdcd7d50..c23d0474d0 100644 --- a/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs +++ b/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs @@ -76,8 +76,9 @@ namespace OpenRA.Mods.RA layer[cell] = layer[cell] * 5 / 6; // TODO: This doesn't make sense for isometric terrain - var tl = wr.ScreenPxPosition(cell.TopLeft); - var br = wr.ScreenPxPosition(cell.BottomRight); + var pos = wr.world.Map.CenterOfCell(cell); + var tl = wr.ScreenPxPosition(pos - new WVec(512, 512, 0)); + var br = wr.ScreenPxPosition(pos + new WVec(511, 511, 0)); qr.FillRect(RectangleF.FromLTRB(tl.X, tl.Y, br.X, br.Y), Color.FromArgb(w, c)); } } diff --git a/OpenRA.Mods.RA/World/SmudgeLayer.cs b/OpenRA.Mods.RA/World/SmudgeLayer.cs index f1c1e65e35..85ef43ccd0 100644 --- a/OpenRA.Mods.RA/World/SmudgeLayer.cs +++ b/OpenRA.Mods.RA/World/SmudgeLayer.cs @@ -79,7 +79,7 @@ namespace OpenRA.Mods.RA public void AddSmudge(CPos loc) { if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage) - world.AddFrameEndTask(w => w.Add(new Smoke(w, loc.CenterPosition, Info.SmokeType))); + world.AddFrameEndTask(w => w.Add(new Smoke(w, world.Map.CenterOfCell(loc), Info.SmokeType))); if (!dirty.ContainsKey(loc) && !tiles.ContainsKey(loc)) { @@ -130,7 +130,7 @@ namespace OpenRA.Mods.RA if (world.ShroudObscures(kv.Key)) continue; - new SpriteRenderable(kv.Value.Sprite, kv.Key.CenterPosition, + new SpriteRenderable(kv.Value.Sprite, world.Map.CenterOfCell(kv.Key), WVec.Zero, -511, pal, 1f, true).Render(wr); } }