Make MobileInfo.SubCellOffsets static.

This commit is contained in:
Paul Chote
2013-07-06 17:24:46 +12:00
parent 34df1ab705
commit 82b7854ed7
2 changed files with 8 additions and 8 deletions

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA.Move
return passability.ToBits(); return passability.ToBits();
} }
public readonly Dictionary<SubCell, PVecInt> SubCellOffsets = new Dictionary<SubCell, PVecInt>() public static readonly Dictionary<SubCell, PVecInt> SubCellOffsets = new Dictionary<SubCell, PVecInt>()
{ {
{SubCell.TopLeft, new PVecInt(-7,-6)}, {SubCell.TopLeft, new PVecInt(-7,-6)},
{SubCell.TopRight, new PVecInt(6,-6)}, {SubCell.TopRight, new PVecInt(6,-6)},
@@ -197,7 +197,7 @@ namespace OpenRA.Mods.RA.Move
if (init.Contains<LocationInit>()) if (init.Contains<LocationInit>())
{ {
this.__fromCell = this.__toCell = init.Get<LocationInit, CPos>(); this.__fromCell = this.__toCell = init.Get<LocationInit, CPos>();
this.PxPosition = Util.CenterOfCell(fromCell) + info.SubCellOffsets[fromSubCell]; this.PxPosition = Util.CenterOfCell(fromCell) + MobileInfo.SubCellOffsets[fromSubCell];
} }
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing; this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
@@ -207,7 +207,7 @@ namespace OpenRA.Mods.RA.Move
public void SetPosition(Actor self, CPos cell) public void SetPosition(Actor self, CPos cell)
{ {
SetLocation(cell,fromSubCell, cell,fromSubCell); SetLocation(cell,fromSubCell, cell,fromSubCell);
PxPosition = Util.CenterOfCell(fromCell) + Info.SubCellOffsets[fromSubCell]; PxPosition = Util.CenterOfCell(fromCell) + MobileInfo.SubCellOffsets[fromSubCell];
FinishedMoving(self); FinishedMoving(self);
} }

View File

@@ -144,8 +144,8 @@ namespace OpenRA.Mods.RA.Move
mobile.SetLocation( mobile.fromCell, mobile.fromSubCell, nextCell.Value.First, nextCell.Value.Second ); mobile.SetLocation( mobile.fromCell, mobile.fromSubCell, nextCell.Value.First, nextCell.Value.Second );
var move = new MoveFirstHalf( var move = new MoveFirstHalf(
this, this,
Util.CenterOfCell( mobile.fromCell ) + mobile.Info.SubCellOffsets[mobile.fromSubCell], Util.CenterOfCell( mobile.fromCell ) + MobileInfo.SubCellOffsets[mobile.fromSubCell],
Util.BetweenCells( mobile.fromCell, mobile.toCell ) + (mobile.Info.SubCellOffsets[mobile.fromSubCell] + mobile.Info.SubCellOffsets[mobile.toSubCell] ) / 2, Util.BetweenCells( mobile.fromCell, mobile.toCell ) + (MobileInfo.SubCellOffsets[mobile.fromSubCell] + MobileInfo.SubCellOffsets[mobile.toSubCell] ) / 2,
mobile.Facing, mobile.Facing,
mobile.Facing, mobile.Facing,
0 ); 0 );
@@ -335,15 +335,15 @@ namespace OpenRA.Mods.RA.Move
protected override MovePart OnComplete( Actor self, Mobile mobile, Move parent ) protected override MovePart OnComplete( Actor self, Mobile mobile, Move parent )
{ {
var fromSubcellOffset = mobile.Info.SubCellOffsets[mobile.fromSubCell]; var fromSubcellOffset = MobileInfo.SubCellOffsets[mobile.fromSubCell];
var toSubcellOffset = mobile.Info.SubCellOffsets[mobile.toSubCell]; var toSubcellOffset = MobileInfo.SubCellOffsets[mobile.toSubCell];
var nextCell = parent.PopPath( self, mobile ); var nextCell = parent.PopPath( self, mobile );
if( nextCell != null ) if( nextCell != null )
{ {
if(IsTurn(mobile, nextCell.Value.First)) if(IsTurn(mobile, nextCell.Value.First))
{ {
var nextSubcellOffset = mobile.Info.SubCellOffsets[nextCell.Value.Second]; var nextSubcellOffset = MobileInfo.SubCellOffsets[nextCell.Value.Second];
var ret = new MoveFirstHalf( var ret = new MoveFirstHalf(
move, move,
Util.BetweenCells( mobile.fromCell, mobile.toCell ) + (fromSubcellOffset + toSubcellOffset) / 2, Util.BetweenCells( mobile.fromCell, mobile.toCell ) + (fromSubcellOffset + toSubcellOffset) / 2,