Refactored in new enum SubCell
This commit is contained in:
@@ -63,12 +63,13 @@ namespace OpenRA
|
||||
public CPos Value(World world) { return value; }
|
||||
}
|
||||
|
||||
public class SubCellInit : IActorInit<int>
|
||||
public class SubCellInit : IActorInit<SubCell>
|
||||
{
|
||||
[FieldFromYamlKey] public readonly int value = 0;
|
||||
[FieldFromYamlKey] public readonly int value = (int)SubCell.FullCell;
|
||||
public SubCellInit() { }
|
||||
public SubCellInit(int init) { value = init; }
|
||||
public int Value(World world) { return value; }
|
||||
public SubCellInit(SubCell init) { value = (int)init; }
|
||||
public SubCell Value(World world) { return (SubCell)value; }
|
||||
}
|
||||
|
||||
public class CenterPositionInit : IActorInit<WPos>
|
||||
|
||||
@@ -79,7 +79,9 @@ namespace OpenRA
|
||||
public readonly TileShape TileShape;
|
||||
[FieldLoader.Ignore]
|
||||
public readonly WVec[] SubCellOffsets;
|
||||
public readonly int SubCellDefaultIndex;
|
||||
public readonly SubCell DefaultSubCell;
|
||||
|
||||
public WVec OffsetOf(SubCell subCell) { return SubCellOffsets[(int)subCell]; }
|
||||
|
||||
[FieldLoader.LoadUsing("LoadOptions")]
|
||||
public MapOptions Options;
|
||||
@@ -250,7 +252,7 @@ namespace OpenRA
|
||||
MapResources = Exts.Lazy(() => LoadResourceTiles());
|
||||
TileShape = Game.modData.Manifest.TileShape;
|
||||
SubCellOffsets = Game.modData.Manifest.SubCellOffsets;
|
||||
SubCellDefaultIndex = Game.modData.Manifest.SubCellDefaultIndex;
|
||||
DefaultSubCell = (SubCell)Game.modData.Manifest.SubCellDefaultIndex;
|
||||
|
||||
// The Uid is calculated from the data on-disk, so
|
||||
// format changes must be flushed to disk.
|
||||
@@ -494,6 +496,14 @@ namespace OpenRA
|
||||
return new WPos(512 * (cell.X - cell.Y + 1), 512 * (cell.X + cell.Y + 1), 0);
|
||||
}
|
||||
|
||||
public WPos CenterOf(CPos cell, SubCell subCell)
|
||||
{
|
||||
var index = (int)subCell;
|
||||
if (index >= 0 && index <= SubCellOffsets.Length)
|
||||
return CenterOfCell(cell) + SubCellOffsets[index];
|
||||
return CenterOfCell(cell);
|
||||
}
|
||||
|
||||
public CPos CellContaining(WPos pos)
|
||||
{
|
||||
if (TileShape == TileShape.Rectangle)
|
||||
|
||||
Reference in New Issue
Block a user