Added int subCell = -1 to IMove.MoveIntoWorld & IPositionable.SetPosition(Actor self, CPos cell)

This commit is contained in:
atlimit8
2014-07-29 14:40:22 -05:00
parent 921d77f825
commit fe57417aa8
8 changed files with 24 additions and 11 deletions

View File

@@ -258,10 +258,11 @@ namespace OpenRA.Mods.RA.Move
SetVisualPosition(self, init.Get<CenterPositionInit, WPos>());
}
public void SetPosition(Actor self, CPos cell)
public void SetPosition(Actor self, CPos cell, int subCell = -1)
{
SetLocation(cell, fromSubCell, cell, fromSubCell);
SetVisualPosition(self, self.World.Map.CenterOfCell(fromCell) + self.World.Map.SubCellOffsets[fromSubCell]);
SetVisualPosition(self, self.World.Map.CenterOfCell(fromCell)
+ self.World.Map.SubCellOffsets[subCell >= 0 ? subCell : fromSubCell]);
FinishedMoving(self);
}
@@ -603,10 +604,16 @@ namespace OpenRA.Mods.RA.Move
Nudge(self, blocking, true);
}
public Activity MoveIntoWorld(Actor self, CPos cell)
public Activity MoveIntoWorld(Actor self, CPos cell, int subCell = -1)
{
var pos = self.CenterPosition;
subCell = self.World.ActorMap.FreeSubCell(cell, subCell);
// TODO: solve/reduce cell is full problem
if (subCell < 0)
subCell = self.World.Map.SubCellDefaultIndex;
// Reserve the exit cell
SetPosition(self, cell);
SetVisualPosition(self, pos);