diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 9ad6248792..39cba9d30f 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -77,6 +77,17 @@ namespace OpenRA public Bitmap CustomPreview; public readonly TileShape TileShape; + [FieldLoader.Ignore] + public readonly WVec[] SubCellOffsets = + { + new WVec(0, 0, 0), + new WVec(-299, -256, 0), + new WVec(256, -256, 0), + new WVec(0, 0, 0), + new WVec(-299, 256, 0), + new WVec(256, 256, 0), + }; + public readonly int SubCellsDefaultIndex = 3; [FieldLoader.LoadUsing("LoadOptions")] public MapOptions Options; diff --git a/OpenRA.Mods.RA/Activities/Leap.cs b/OpenRA.Mods.RA/Activities/Leap.cs index 465d7247c5..b226ad19de 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 = self.World.Map.CenterOfCell(targetMobile.fromCell) + MobileInfo.SubCellOffsets[targetMobile.fromSubCell]; + to = self.World.Map.CenterOfCell(targetMobile.fromCell) + self.World.Map.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/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index fc334bc06c..9c1992ca12 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -133,16 +133,6 @@ namespace OpenRA.Mods.RA.Move return TilesetMovementClass[tileset]; } - public static readonly WVec[] SubCellOffsets = - { - new WVec(0, 0, 0), - new WVec(-299, -256, 0), - new WVec(256, -256, 0), - new WVec(0, 0, 0), - new WVec(-299, 256, 0), - new WVec(256, 256, 0), - }; - static bool IsMovingInMyDirection(Actor self, Actor other) { if (!other.IsMoving()) return false; @@ -248,8 +238,7 @@ namespace OpenRA.Mods.RA.Move this.self = init.self; this.Info = info; - // TODO replace 3 w/ SubCellDefaultIndex - toSubCell = fromSubCell = info.SharesCell ? 3 : 0; + toSubCell = fromSubCell = info.SharesCell ? init.world.Map.SubCellsDefaultIndex : 0; if (init.Contains()) { this.fromSubCell = this.toSubCell = init.Get(); @@ -258,7 +247,7 @@ namespace OpenRA.Mods.RA.Move if (init.Contains()) { this.__fromCell = this.__toCell = init.Get(); - SetVisualPosition(self, init.world.Map.CenterOfCell(fromCell) + MobileInfo.SubCellOffsets[fromSubCell]); + SetVisualPosition(self, init.world.Map.CenterOfCell(fromCell) + self.World.Map.SubCellOffsets[fromSubCell]); } this.Facing = init.Contains() ? init.Get() : info.InitialFacing; @@ -272,7 +261,7 @@ namespace OpenRA.Mods.RA.Move public void SetPosition(Actor self, CPos cell) { SetLocation(cell, fromSubCell, cell, fromSubCell); - SetVisualPosition(self, self.World.Map.CenterOfCell(fromCell) + MobileInfo.SubCellOffsets[fromSubCell]); + SetVisualPosition(self, self.World.Map.CenterOfCell(fromCell) + self.World.Map.SubCellOffsets[fromSubCell]); FinishedMoving(self); } diff --git a/OpenRA.Mods.RA/Move/Move.cs b/OpenRA.Mods.RA/Move/Move.cs index 5dc077a58d..d58e100f88 100755 --- a/OpenRA.Mods.RA/Move/Move.cs +++ b/OpenRA.Mods.RA/Move/Move.cs @@ -150,8 +150,8 @@ namespace OpenRA.Mods.RA.Move mobile.SetLocation(mobile.fromCell, mobile.fromSubCell, nextCell.Value.First, nextCell.Value.Second); var move = new MoveFirstHalf( this, - 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, + self.World.Map.CenterOfCell(mobile.fromCell) + self.World.Map.SubCellOffsets[mobile.fromSubCell], + Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (self.World.Map.SubCellOffsets[mobile.fromSubCell] + self.World.Map.SubCellOffsets[mobile.toSubCell]) / 2, mobile.Facing, mobile.Facing, 0); @@ -347,15 +347,15 @@ namespace OpenRA.Mods.RA.Move protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent) { - var fromSubcellOffset = MobileInfo.SubCellOffsets[mobile.fromSubCell]; - var toSubcellOffset = MobileInfo.SubCellOffsets[mobile.toSubCell]; + var fromSubcellOffset = self.World.Map.SubCellOffsets[mobile.fromSubCell]; + var toSubcellOffset = self.World.Map.SubCellOffsets[mobile.toSubCell]; var nextCell = parent.PopPath(self, mobile); if (nextCell != null) { if (IsTurn(mobile, nextCell.Value.First)) { - var nextSubcellOffset = MobileInfo.SubCellOffsets[nextCell.Value.Second]; + var nextSubcellOffset = self.World.Map.SubCellOffsets[nextCell.Value.Second]; var ret = new MoveFirstHalf( move, Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2, diff --git a/OpenRA.Mods.RA/Move/PathFinder.cs b/OpenRA.Mods.RA/Move/PathFinder.cs index ead53ad4f0..43e165d121 100644 --- a/OpenRA.Mods.RA/Move/PathFinder.cs +++ b/OpenRA.Mods.RA/Move/PathFinder.cs @@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Move var rangeSquared = range.Range*range.Range; // Correct for SubCell offset - target -= MobileInfo.SubCellOffsets[srcSub]; + target -= self.World.Map.SubCellOffsets[srcSub]; // Select only the tiles that are within range from the requested SubCell // This assumes that the SubCell does not change during the path traversal