Move cell corner state into Map.

This commit is contained in:
Paul Chote
2015-03-27 22:47:46 +00:00
parent 49624e335c
commit c68cb995f4
2 changed files with 59 additions and 74 deletions

View File

@@ -125,6 +125,42 @@ namespace OpenRA
public class Map : IMap
{
static readonly int[][] CellCornerHalfHeights = new int[][]
{
// Flat
new[] { 0, 0, 0, 0 },
// Slopes (two corners high)
new[] { 0, 0, 1, 1 },
new[] { 1, 0, 0, 1 },
new[] { 1, 1, 0, 0 },
new[] { 0, 1, 1, 0 },
// Slopes (one corner high)
new[] { 0, 0, 0, 1 },
new[] { 1, 0, 0, 0 },
new[] { 0, 1, 0, 0 },
new[] { 0, 0, 1, 0 },
// Slopes (three corners high)
new[] { 1, 0, 1, 1 },
new[] { 1, 1, 0, 1 },
new[] { 1, 1, 1, 0 },
new[] { 0, 1, 1, 1 },
// Slopes (two corners high, one corner double high)
new[] { 1, 0, 1, 2 },
new[] { 2, 1, 0, 1 },
new[] { 1, 2, 1, 0 },
new[] { 0, 1, 2, 1 },
// Slopes (two corners high, alternating)
new[] { 1, 0, 1, 0 },
new[] { 0, 1, 0, 1 },
new[] { 1, 0, 1, 0 },
new[] { 0, 1, 0, 1 }
};
public const int MaxTilesInCircleRange = 50;
public readonly TileShape TileShape;
TileShape IMap.TileShape
@@ -219,6 +255,7 @@ namespace OpenRA
public Ruleset Rules { get { return rules != null ? rules.Value : null; } }
public SequenceProvider SequenceProvider { get { return Rules.Sequences[Tileset]; } }
public WVec[][] CellCorners { get; private set; }
[FieldLoader.Ignore] public CellRegion Cells;
public static Map FromTileset(TileSet tileset)
@@ -394,6 +431,18 @@ namespace OpenRA
CustomTerrain = new CellLayer<byte>(this);
foreach (var uv in Cells.MapCoords)
CustomTerrain[uv] = byte.MaxValue;
var leftDelta = TileShape == TileShape.Diamond ? new WVec(-512, 0, 0) : new WVec(-512, -512, 0);
var topDelta = TileShape == TileShape.Diamond ? new WVec(0, -512, 0) : new WVec(512, -512, 0);
var rightDelta = TileShape == TileShape.Diamond ? new WVec(512, 0, 0) : new WVec(512, 512, 0);
var bottomDelta = TileShape == TileShape.Diamond ? new WVec(0, 512, 0) : new WVec(-512, 512, 0);
CellCorners = CellCornerHalfHeights.Select(ramp => new WVec[]
{
leftDelta + new WVec(0, 0, 512 * ramp[0]),
topDelta + new WVec(0, 0, 512 * ramp[1]),
rightDelta + new WVec(0, 0, 512 * ramp[2]),
bottomDelta + new WVec(0, 0, 512 * ramp[3])
}).ToArray();
}
public Ruleset PreloadRules()