Moved MobileInfo.SubCellOffsets to Map (dropping static) & added Map.SubCellsDefaultIndex
This commit is contained in:
@@ -77,6 +77,17 @@ namespace OpenRA
|
|||||||
public Bitmap CustomPreview;
|
public Bitmap CustomPreview;
|
||||||
|
|
||||||
public readonly TileShape TileShape;
|
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")]
|
[FieldLoader.LoadUsing("LoadOptions")]
|
||||||
public MapOptions Options;
|
public MapOptions Options;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
mobile.IsMoving = true;
|
mobile.IsMoving = true;
|
||||||
|
|
||||||
from = self.CenterPosition;
|
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);
|
length = Math.Max((to - from).Length / speed.Range, 1);
|
||||||
|
|
||||||
self.Trait<RenderInfantry>().Attacking(self, Target.FromActor(target));
|
self.Trait<RenderInfantry>().Attacking(self, Target.FromActor(target));
|
||||||
|
|||||||
@@ -133,16 +133,6 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
return TilesetMovementClass[tileset];
|
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)
|
static bool IsMovingInMyDirection(Actor self, Actor other)
|
||||||
{
|
{
|
||||||
if (!other.IsMoving()) return false;
|
if (!other.IsMoving()) return false;
|
||||||
@@ -248,8 +238,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
this.self = init.self;
|
this.self = init.self;
|
||||||
this.Info = info;
|
this.Info = info;
|
||||||
|
|
||||||
// TODO replace 3 w/ SubCellDefaultIndex
|
toSubCell = fromSubCell = info.SharesCell ? init.world.Map.SubCellsDefaultIndex : 0;
|
||||||
toSubCell = fromSubCell = info.SharesCell ? 3 : 0;
|
|
||||||
if (init.Contains<SubCellInit>())
|
if (init.Contains<SubCellInit>())
|
||||||
{
|
{
|
||||||
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, int>();
|
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, int>();
|
||||||
@@ -258,7 +247,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>();
|
||||||
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;
|
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)
|
public void SetPosition(Actor self, CPos cell)
|
||||||
{
|
{
|
||||||
SetLocation(cell, fromSubCell, cell, fromSubCell);
|
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);
|
FinishedMoving(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,8 +150,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,
|
||||||
self.World.Map.CenterOfCell(mobile.fromCell) + MobileInfo.SubCellOffsets[mobile.fromSubCell],
|
self.World.Map.CenterOfCell(mobile.fromCell) + self.World.Map.SubCellOffsets[mobile.fromSubCell],
|
||||||
Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (MobileInfo.SubCellOffsets[mobile.fromSubCell] + MobileInfo.SubCellOffsets[mobile.toSubCell]) / 2,
|
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,
|
||||||
mobile.Facing,
|
mobile.Facing,
|
||||||
0);
|
0);
|
||||||
@@ -347,15 +347,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 = MobileInfo.SubCellOffsets[mobile.fromSubCell];
|
var fromSubcellOffset = self.World.Map.SubCellOffsets[mobile.fromSubCell];
|
||||||
var toSubcellOffset = MobileInfo.SubCellOffsets[mobile.toSubCell];
|
var toSubcellOffset = self.World.Map.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 = MobileInfo.SubCellOffsets[nextCell.Value.Second];
|
var nextSubcellOffset = self.World.Map.SubCellOffsets[nextCell.Value.Second];
|
||||||
var ret = new MoveFirstHalf(
|
var ret = new MoveFirstHalf(
|
||||||
move,
|
move,
|
||||||
Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2,
|
Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2,
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
var rangeSquared = range.Range*range.Range;
|
var rangeSquared = range.Range*range.Range;
|
||||||
|
|
||||||
// Correct for SubCell offset
|
// 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
|
// Select only the tiles that are within range from the requested SubCell
|
||||||
// This assumes that the SubCell does not change during the path traversal
|
// This assumes that the SubCell does not change during the path traversal
|
||||||
|
|||||||
Reference in New Issue
Block a user