Bake PickAny tiles on map save. Translate maxvalue index to random tile for backwards compat.
This commit is contained in:
@@ -14,20 +14,11 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
public T type;
|
||||
public U index;
|
||||
public U image;
|
||||
|
||||
public TileReference(T t, U i)
|
||||
{
|
||||
type = t;
|
||||
index = i;
|
||||
image = i;
|
||||
}
|
||||
|
||||
public TileReference(T t, U i, U im)
|
||||
{
|
||||
type = t;
|
||||
index = i;
|
||||
image = im;
|
||||
}
|
||||
|
||||
public override int GetHashCode() { return type.GetHashCode() ^ index.GetHashCode(); }
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
Terrain tile;
|
||||
if( Tiles.TryGetValue( r.type, out tile ) )
|
||||
return tile.TileBitmapBytes[ r.image ];
|
||||
return tile.TileBitmapBytes[ r.index ];
|
||||
|
||||
byte[] missingTile = new byte[ TileSize * TileSize ];
|
||||
for( int i = 0 ; i < missingTile.Length ; i++ )
|
||||
@@ -149,7 +149,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
var tt = Templates[r.type].Tiles;
|
||||
string ret;
|
||||
if (!tt.TryGetValue(r.image, out ret))
|
||||
if (!tt.TryGetValue(r.index, out ret))
|
||||
return "Clear"; // Default walkable
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -66,8 +66,7 @@ namespace OpenRA
|
||||
MapTiles = new TileReference<ushort, byte>[1, 1]
|
||||
{ { new TileReference<ushort, byte> {
|
||||
type = tile.Key,
|
||||
image = (byte)(tile.Value.PickAny ? 0xffu : 0),
|
||||
index = (byte)(tile.Value.PickAny ? 0xffu : 0) }
|
||||
index = (byte)0 }
|
||||
} },
|
||||
};
|
||||
|
||||
@@ -324,8 +323,10 @@ namespace OpenRA
|
||||
{
|
||||
ushort tile = ReadWord(dataStream);
|
||||
byte index = ReadByte(dataStream);
|
||||
byte image = (index == byte.MaxValue) ? (byte)(i % 4 + (j % 4) * 4) : index;
|
||||
MapTiles[i, j] = new TileReference<ushort, byte>(tile, index, image);
|
||||
if (index == byte.MaxValue)
|
||||
index = (byte)(i % 4 + (j % 4) * 4);
|
||||
|
||||
MapTiles[i, j] = new TileReference<ushort, byte>(tile, index);
|
||||
}
|
||||
|
||||
// Load resource data
|
||||
@@ -350,7 +351,8 @@ namespace OpenRA
|
||||
for (int j = 0; j < MapSize.Y; j++)
|
||||
{
|
||||
writer.Write(MapTiles[i, j].type);
|
||||
writer.Write(MapTiles[i, j].index);
|
||||
var PickAny = OpenRA.Rules.TileSets[Tileset].Templates[MapTiles[i, j].type].PickAny;
|
||||
writer.Write(PickAny ? (byte)(i % 4 + (j % 4) * 4) : MapTiles[i, j].index);
|
||||
}
|
||||
|
||||
// Resource data
|
||||
|
||||
@@ -67,10 +67,10 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
// Correlate the tile "image" aka subtile with its position to find the template origin
|
||||
var tile = w.Map.MapTiles[i, j].type;
|
||||
var image = w.Map.MapTiles[i, j].image;
|
||||
var index = w.Map.MapTiles[i, j].index;
|
||||
var template = w.TileSet.Templates[tile];
|
||||
var ni = i - image % template.Size.X;
|
||||
var nj = j - image / template.Size.X;
|
||||
var ni = i - index % template.Size.X;
|
||||
var nj = j - index / template.Size.X;
|
||||
|
||||
// Create a new actor for this bridge and keep track of which subtiles this bridge includes
|
||||
var bridge = w.CreateActor(BridgeTypes[tile].First, new TypeDictionary
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA
|
||||
var y = nj + ind / template.Size.X;
|
||||
|
||||
// This isn't the bridge you're looking for
|
||||
if (!w.Map.IsInMap(x, y) || w.Map.MapTiles[x, y].image != ind)
|
||||
if (!w.Map.IsInMap(x, y) || w.Map.MapTiles[x, y].index != ind)
|
||||
continue;
|
||||
|
||||
subTiles.Add(new int2(x,y),ind);
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
if (!world.LocalShroud.IsExplored(kv.Key))
|
||||
continue;
|
||||
|
||||
bibSprites[kv.Value.type - 1][kv.Value.image].DrawAt( wr,
|
||||
bibSprites[kv.Value.type - 1][kv.Value.index].DrawAt( wr,
|
||||
Game.CellSize * kv.Key, "terrain");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ namespace OpenRA.Mods.RA
|
||||
var tile = tiles[loc];
|
||||
// Existing smudge; make it deeper
|
||||
int depth = Info.Depths[tile.type-1];
|
||||
if (tile.image < depth - 1)
|
||||
if (tile.index < depth - 1)
|
||||
{
|
||||
tile.image++;
|
||||
tile.index++;
|
||||
tiles[loc] = tile; // struct semantics.
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA
|
||||
if (localPlayer != null && !localPlayer.Shroud.IsExplored(kv.Key))
|
||||
continue;
|
||||
|
||||
smudgeSprites[kv.Value.type- 1][kv.Value.image].DrawAt( wr,
|
||||
smudgeSprites[kv.Value.type- 1][kv.Value.index].DrawAt( wr,
|
||||
Game.CellSize * kv.Key, "terrain");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user