Reference SubCells directly from MapGrid.

This commit is contained in:
Paul Chote
2016-03-12 21:01:55 +00:00
parent c9e7bb43c2
commit e79fbe1bb9
8 changed files with 33 additions and 38 deletions

View File

@@ -74,10 +74,6 @@ namespace OpenRA
public readonly MapGrid Grid;
readonly ModData modData;
[FieldLoader.Ignore] public readonly WVec[] SubCellOffsets;
public readonly SubCell DefaultSubCell;
public readonly SubCell LastSubCell;
public IReadOnlyPackage Package { get; private set; }
// Yaml map data
@@ -93,14 +89,6 @@ namespace OpenRA
public bool LockPreview;
public bool InvalidCustomRules { get; private set; }
public WVec OffsetOfSubCell(SubCell subCell)
{
if (subCell == SubCell.Invalid || subCell == SubCell.Any)
return WVec.Zero;
return SubCellOffsets[(int)subCell];
}
public static string ComputeUID(IReadOnlyPackage package)
{
// UID is calculated by taking an SHA1 of the yaml and binary data
@@ -274,10 +262,6 @@ namespace OpenRA
Grid = modData.Manifest.Get<MapGrid>();
SubCellOffsets = Grid.SubCellOffsets;
LastSubCell = (SubCell)(SubCellOffsets.Length - 1);
DefaultSubCell = (SubCell)Grid.SubCellDefaultIndex;
PostInit();
Uid = ComputeUID(Package);
@@ -760,8 +744,8 @@ namespace OpenRA
public WPos CenterOfSubCell(CPos cell, SubCell subCell)
{
var index = (int)subCell;
if (index >= 0 && index <= SubCellOffsets.Length)
return CenterOfCell(cell) + SubCellOffsets[index];
if (index >= 0 && index <= Grid.SubCellOffsets.Length)
return CenterOfCell(cell) + Grid.SubCellOffsets[index];
return CenterOfCell(cell);
}