Moved MobileInfo.SubCellOffsets to Map (dropping static) & added Map.SubCellsDefaultIndex

This commit is contained in:
atlimit8
2014-07-29 09:01:37 -05:00
parent 43478dd500
commit 4b7537bb13
5 changed files with 21 additions and 21 deletions

View File

@@ -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<RenderInfantry>().Attacking(self, Target.FromActor(target));

View File

@@ -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<SubCellInit>())
{
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, int>();
@@ -258,7 +247,7 @@ namespace OpenRA.Mods.RA.Move
if (init.Contains<LocationInit>())
{
this.__fromCell = this.__toCell = init.Get<LocationInit, CPos>();
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<FacingInit>() ? init.Get<FacingInit, int>() : 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);
}

View File

@@ -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,

View File

@@ -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