Merge pull request #6208 from atlimit8/FixUnloadCargo

Fixed UnloadCargo stacking using new subcell API exposure
This commit is contained in:
Matthias Mailänder
2014-08-30 14:38:17 +02:00
22 changed files with 287 additions and 153 deletions

View File

@@ -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>

View File

@@ -79,7 +79,10 @@ namespace OpenRA
public readonly TileShape TileShape;
[FieldLoader.Ignore]
public readonly WVec[] SubCellOffsets;
public readonly int SubCellDefaultIndex;
public readonly SubCell DefaultSubCell;
public readonly SubCell LastSubCell;
public WVec OffsetOfSubCell(SubCell subCell) { return SubCellOffsets[(int)subCell]; }
[FieldLoader.LoadUsing("LoadOptions")]
public MapOptions Options;
@@ -250,7 +253,8 @@ namespace OpenRA
MapResources = Exts.Lazy(() => LoadResourceTiles());
TileShape = Game.modData.Manifest.TileShape;
SubCellOffsets = Game.modData.Manifest.SubCellOffsets;
SubCellDefaultIndex = Game.modData.Manifest.SubCellDefaultIndex;
LastSubCell = (SubCell)(SubCellOffsets.Length - 1);
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 +498,14 @@ namespace OpenRA
return new WPos(512 * (cell.X - cell.Y + 1), 512 * (cell.X + cell.Y + 1), 0);
}
public WPos CenterOfSubCell(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)