StyleCop clean Map/*.cs files
This commit is contained in:
@@ -46,8 +46,8 @@ namespace OpenRA.Editor
|
|||||||
surface.Map.MapTiles.Value[u + pos.X, v + pos.Y] =
|
surface.Map.MapTiles.Value[u + pos.X, v + pos.Y] =
|
||||||
new TileReference<ushort, byte>
|
new TileReference<ushort, byte>
|
||||||
{
|
{
|
||||||
type = brushTemplate.N,
|
Type = brushTemplate.N,
|
||||||
index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z,
|
Index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z,
|
||||||
};
|
};
|
||||||
|
|
||||||
var ch = new int2((pos.X + u) / Surface.ChunkSize, (pos.Y + v) / Surface.ChunkSize);
|
var ch = new int2((pos.X + u) / Surface.ChunkSize, (pos.Y + v) / Surface.ChunkSize);
|
||||||
@@ -96,7 +96,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
for (var x = a.X; x <= b.X; x++)
|
for (var x = a.X; x <= b.X; x++)
|
||||||
{
|
{
|
||||||
s.Map.MapTiles.Value[x, p.Y] = new TileReference<ushort, byte> { type = brushTemplate.N, index = (byte)0 };
|
s.Map.MapTiles.Value[x, p.Y] = new TileReference<ushort, byte> { Type = brushTemplate.N, Index = (byte)0 };
|
||||||
if (s.Map.MapTiles.Value[x, p.Y - 1].Equals(replace))
|
if (s.Map.MapTiles.Value[x, p.Y - 1].Equals(replace))
|
||||||
maybeEnqueue(x, p.Y - 1);
|
maybeEnqueue(x, p.Y - 1);
|
||||||
if (s.Map.MapTiles.Value[x, p.Y + 1].Equals(replace))
|
if (s.Map.MapTiles.Value[x, p.Y + 1].Equals(replace))
|
||||||
|
|||||||
10
OpenRA.Editor/Form1.cs
Executable file → Normal file
10
OpenRA.Editor/Form1.cs
Executable file → Normal file
@@ -519,8 +519,8 @@ namespace OpenRA.Editor
|
|||||||
for (var i = surface1.Map.Bounds.Left; i < surface1.Map.Bounds.Right; i++)
|
for (var i = surface1.Map.Bounds.Left; i < surface1.Map.Bounds.Right; i++)
|
||||||
{
|
{
|
||||||
var tr = surface1.Map.MapTiles.Value[i, j];
|
var tr = surface1.Map.MapTiles.Value[i, j];
|
||||||
if (tr.type == 0xff || tr.type == 0xffff || tr.type == 1 || tr.type == 2)
|
if (tr.Type == 0xff || tr.Type == 0xffff || tr.Type == 1 || tr.Type == 2)
|
||||||
tr.index = (byte)r.Next(0, surface1.TileSetRenderer.Data(tr.type).Count);
|
tr.Index = (byte)r.Next(0, surface1.TileSetRenderer.Data(tr.Type).Count);
|
||||||
|
|
||||||
surface1.Map.MapTiles.Value[i, j] = tr;
|
surface1.Map.MapTiles.Value[i, j] = tr;
|
||||||
}
|
}
|
||||||
@@ -674,7 +674,7 @@ namespace OpenRA.Editor
|
|||||||
for (int i = 0; i < surface1.Map.MapSize.X; i++)
|
for (int i = 0; i < surface1.Map.MapSize.X; i++)
|
||||||
for (int j = 0; j < surface1.Map.MapSize.Y; j++)
|
for (int j = 0; j < surface1.Map.MapSize.Y; j++)
|
||||||
{
|
{
|
||||||
if (surface1.Map.MapResources.Value[i, j].type != 0)
|
if (surface1.Map.MapResources.Value[i, j].Type != 0)
|
||||||
totalResource += GetResourceValue(i, j);
|
totalResource += GetResourceValue(i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,7 +689,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
if (!surface1.Map.IsInMap(new CPos(x + u, y + v)))
|
if (!surface1.Map.IsInMap(new CPos(x + u, y + v)))
|
||||||
continue;
|
continue;
|
||||||
if (surface1.Map.MapResources.Value[x + u, y + v].type == resourceType)
|
if (surface1.Map.MapResources.Value[x + u, y + v].Type == resourceType)
|
||||||
++sum;
|
++sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +699,7 @@ namespace OpenRA.Editor
|
|||||||
int GetResourceValue(int x, int y)
|
int GetResourceValue(int x, int y)
|
||||||
{
|
{
|
||||||
int imageLength = 0;
|
int imageLength = 0;
|
||||||
int type = surface1.Map.MapResources.Value[x, y].type;
|
int type = surface1.Map.MapResources.Value[x, y].Type;
|
||||||
var template = surface1.ResourceTemplates.Where(a => a.Value.Info.ResourceType == type).FirstOrDefault().Value;
|
var template = surface1.ResourceTemplates.Where(a => a.Value.Info.ResourceType == type).FirstOrDefault().Value;
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
imageLength = 12;
|
imageLength = 12;
|
||||||
|
|||||||
@@ -254,11 +254,11 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (int j = 0; j < mapSize; j++)
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (int i = 0; i < mapSize; i++)
|
||||||
map.MapTiles.Value[i, j].type = ReadWord(ms);
|
map.MapTiles.Value[i, j].Type = ReadWord(ms);
|
||||||
|
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (int j = 0; j < mapSize; j++)
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (int i = 0; i < mapSize; i++)
|
||||||
map.MapTiles.Value[i, j].index = ReadByte(ms);
|
map.MapTiles.Value[i, j].Index = ReadByte(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnpackRAOverlayData(MemoryStream ms)
|
void UnpackRAOverlayData(MemoryStream ms)
|
||||||
@@ -311,8 +311,8 @@ namespace OpenRA.Editor
|
|||||||
for (int j = 0; j < mapSize; j++)
|
for (int j = 0; j < mapSize; j++)
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (int i = 0; i < mapSize; i++)
|
||||||
{
|
{
|
||||||
map.MapTiles.Value[i, j].type = ReadByte(ms);
|
map.MapTiles.Value[i, j].Type = ReadByte(ms);
|
||||||
map.MapTiles.Value[i, j].index = ReadByte(ms);
|
map.MapTiles.Value[i, j].Index = ReadByte(ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ namespace OpenRA.Editor
|
|||||||
surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y]
|
surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y]
|
||||||
= new TileReference<byte, byte>
|
= new TileReference<byte, byte>
|
||||||
{
|
{
|
||||||
type = (byte)resourceTemplate.Info.ResourceType,
|
Type = (byte)resourceTemplate.Info.ResourceType,
|
||||||
index = (byte)random.Next(resourceTemplate.Info.SpriteNames.Length)
|
Index = (byte)random.Next(resourceTemplate.Info.SpriteNames.Length)
|
||||||
};
|
};
|
||||||
|
|
||||||
var ch = new int2(surface.GetBrushLocation().X / Surface.ChunkSize,
|
var ch = new int2(surface.GetBrushLocation().X / Surface.ChunkSize,
|
||||||
|
|||||||
10
OpenRA.Editor/Surface.cs
Executable file → Normal file
10
OpenRA.Editor/Surface.cs
Executable file → Normal file
@@ -206,7 +206,7 @@ namespace OpenRA.Editor
|
|||||||
var key = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == brushLocation);
|
var key = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == brushLocation);
|
||||||
if (key.Key != null) Map.Actors.Value.Remove(key.Key);
|
if (key.Key != null) Map.Actors.Value.Remove(key.Key);
|
||||||
|
|
||||||
if (Map.MapResources.Value[brushLocation.X, brushLocation.Y].type != 0)
|
if (Map.MapResources.Value[brushLocation.X, brushLocation.Y].Type != 0)
|
||||||
{
|
{
|
||||||
Map.MapResources.Value[brushLocation.X, brushLocation.Y] = new TileReference<byte, byte>();
|
Map.MapResources.Value[brushLocation.X, brushLocation.Y] = new TileReference<byte, byte>();
|
||||||
var ch = new int2(brushLocation.X / ChunkSize, brushLocation.Y / ChunkSize);
|
var ch = new int2(brushLocation.X / ChunkSize, brushLocation.Y / ChunkSize);
|
||||||
@@ -272,16 +272,16 @@ namespace OpenRA.Editor
|
|||||||
for (var j = 0; j < ChunkSize; j++)
|
for (var j = 0; j < ChunkSize; j++)
|
||||||
{
|
{
|
||||||
var tr = Map.MapTiles.Value[u * ChunkSize + i, v * ChunkSize + j];
|
var tr = Map.MapTiles.Value[u * ChunkSize + i, v * ChunkSize + j];
|
||||||
var tile = TileSetRenderer.Data(tr.type);
|
var tile = TileSetRenderer.Data(tr.Type);
|
||||||
var index = (tr.index < tile.Count) ? tr.index : (byte)0;
|
var index = (tr.Index < tile.Count) ? tr.Index : (byte)0;
|
||||||
var rawImage = tile[index];
|
var rawImage = tile[index];
|
||||||
for (var x = 0; x < TileSetRenderer.TileSize.Width; x++)
|
for (var x = 0; x < TileSetRenderer.TileSize.Width; x++)
|
||||||
for (var y = 0; y < TileSetRenderer.TileSize.Height; y++)
|
for (var y = 0; y < TileSetRenderer.TileSize.Height; y++)
|
||||||
p[(j * TileSetRenderer.TileSize.Width + y) * stride + i * TileSetRenderer.TileSize.Width + x] = Palette.GetColor(rawImage[x + TileSetRenderer.TileSize.Width * y]).ToArgb();
|
p[(j * TileSetRenderer.TileSize.Width + y) * stride + i * TileSetRenderer.TileSize.Width + x] = Palette.GetColor(rawImage[x + TileSetRenderer.TileSize.Width * y]).ToArgb();
|
||||||
|
|
||||||
if (Map.MapResources.Value[u * ChunkSize + i, v * ChunkSize + j].type != 0)
|
if (Map.MapResources.Value[u * ChunkSize + i, v * ChunkSize + j].Type != 0)
|
||||||
{
|
{
|
||||||
var resourceImage = ResourceTemplates[Map.MapResources.Value[u * ChunkSize + i, v * ChunkSize + j].type].Bitmap;
|
var resourceImage = ResourceTemplates[Map.MapResources.Value[u * ChunkSize + i, v * ChunkSize + j].Type].Bitmap;
|
||||||
var srcdata = resourceImage.LockBits(resourceImage.Bounds(),
|
var srcdata = resourceImage.LockBits(resourceImage.Bounds(),
|
||||||
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ namespace OpenRA.FileFormats
|
|||||||
Dictionary<ushort, List<byte[]>> templates;
|
Dictionary<ushort, List<byte[]>> templates;
|
||||||
public Size TileSize;
|
public Size TileSize;
|
||||||
|
|
||||||
List<byte[]> LoadTemplate(string filename, string[] exts, Cache<string, R8Reader> r8Cache, int[] frames)
|
List<byte[]> LoadTemplate(string filename, string[] exts, Cache<string, R8Reader> r8cache, int[] frames)
|
||||||
{
|
{
|
||||||
if (exts.Contains(".R8") && FileSystem.Exists(filename+".R8"))
|
if (exts.Contains(".R8") && FileSystem.Exists(filename + ".R8"))
|
||||||
{
|
{
|
||||||
var data = new List<byte[]>();
|
var data = new List<byte[]>();
|
||||||
|
|
||||||
foreach (var f in frames)
|
foreach (var f in frames)
|
||||||
data.Add(f >= 0 ? r8Cache[filename][f].Image : null);
|
data.Add(f >= 0 ? r8cache[filename][f].Image : null);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -45,9 +45,9 @@ namespace OpenRA.FileFormats
|
|||||||
this.TileSize = tileSize;
|
this.TileSize = tileSize;
|
||||||
|
|
||||||
templates = new Dictionary<ushort, List<byte[]>>();
|
templates = new Dictionary<ushort, List<byte[]>>();
|
||||||
var r8Cache = new Cache<string, R8Reader>(s => new R8Reader(FileSystem.OpenWithExts(s, ".R8")));
|
var r8cache = new Cache<string, R8Reader>(s => new R8Reader(FileSystem.OpenWithExts(s, ".R8")));
|
||||||
foreach (var t in TileSet.Templates)
|
foreach (var t in TileSet.Templates)
|
||||||
templates.Add(t.Key, LoadTemplate(t.Value.Image, tileset.Extensions, r8Cache, t.Value.Frames));
|
templates.Add(t.Key, LoadTemplate(t.Value.Image, tileset.Extensions, r8cache, t.Value.Frames));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap RenderTemplate(ushort id, Palette p)
|
public Bitmap RenderTemplate(ushort id, Palette p)
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.FileFormats
|
namespace OpenRA.FileFormats
|
||||||
{
|
{
|
||||||
@@ -30,8 +30,8 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
// ColorRamp naming retained for backward compatibility
|
// ColorRamp naming retained for backward compatibility
|
||||||
public bool LockColor = false;
|
public bool LockColor = false;
|
||||||
public HSLColor ColorRamp = new HSLColor(0,0,238);
|
public HSLColor ColorRamp = new HSLColor(0, 0, 238);
|
||||||
public HSLColor Color { get { return ColorRamp; } set { ColorRamp = value; }}
|
public HSLColor Color { get { return ColorRamp; } set { ColorRamp = value; } }
|
||||||
|
|
||||||
public bool LockSpawn = false;
|
public bool LockSpawn = false;
|
||||||
public int Spawn = 0;
|
public int Spawn = 0;
|
||||||
@@ -39,10 +39,10 @@ namespace OpenRA.FileFormats
|
|||||||
public bool LockTeam = false;
|
public bool LockTeam = false;
|
||||||
public int Team = 0;
|
public int Team = 0;
|
||||||
|
|
||||||
public string[] Allies = {};
|
public string[] Allies = { };
|
||||||
public string[] Enemies = {};
|
public string[] Enemies = { };
|
||||||
|
|
||||||
public PlayerReference() {}
|
public PlayerReference() { }
|
||||||
public PlayerReference(MiniYaml my) { FieldLoader.Load(this, my); }
|
public PlayerReference(MiniYaml my) { FieldLoader.Load(this, my); }
|
||||||
|
|
||||||
public override string ToString() { return Name; }
|
public override string ToString() { return Name; }
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRA.FileFormats
|
|||||||
public readonly int2 Location;
|
public readonly int2 Location;
|
||||||
public readonly int Depth;
|
public readonly int Depth;
|
||||||
|
|
||||||
public SmudgeReference( string type, int2 location, int depth )
|
public SmudgeReference(string type, int2 location, int depth)
|
||||||
{
|
{
|
||||||
Type = type;
|
Type = type;
|
||||||
Location = location;
|
Location = location;
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
public struct TileReference<T, U>
|
public struct TileReference<T, U>
|
||||||
{
|
{
|
||||||
public T type;
|
public T Type;
|
||||||
public U index;
|
public U Index;
|
||||||
|
|
||||||
public TileReference(T t, U i)
|
public TileReference(T t, U i)
|
||||||
{
|
{
|
||||||
type = t;
|
Type = t;
|
||||||
index = i;
|
Index = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode() { return type.GetHashCode() ^ index.GetHashCode(); }
|
public override int GetHashCode() { return Type.GetHashCode() ^ Index.GetHashCode(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.FileFormats
|
|||||||
public Color Color;
|
public Color Color;
|
||||||
public string CustomCursor;
|
public string CustomCursor;
|
||||||
|
|
||||||
public TerrainTypeInfo() {}
|
public TerrainTypeInfo() { }
|
||||||
public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); }
|
public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); }
|
||||||
|
|
||||||
public MiniYaml Save() { return FieldSaver.Save(this); }
|
public MiniYaml Save() { return FieldSaver.Save(this); }
|
||||||
@@ -43,7 +43,7 @@ namespace OpenRA.FileFormats
|
|||||||
[FieldLoader.LoadUsing("LoadTiles")]
|
[FieldLoader.LoadUsing("LoadTiles")]
|
||||||
public Dictionary<byte, string> Tiles = new Dictionary<byte, string>();
|
public Dictionary<byte, string> Tiles = new Dictionary<byte, string>();
|
||||||
|
|
||||||
public TileTemplate() {}
|
public TileTemplate() { }
|
||||||
public TileTemplate(MiniYaml my) { FieldLoader.Load(this, my); }
|
public TileTemplate(MiniYaml my) { FieldLoader.Load(this, my); }
|
||||||
|
|
||||||
static object LoadTiles(MiniYaml y)
|
static object LoadTiles(MiniYaml y)
|
||||||
@@ -87,9 +87,9 @@ namespace OpenRA.FileFormats
|
|||||||
public Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
|
public Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
|
||||||
public string[] EditorTemplateOrder;
|
public string[] EditorTemplateOrder;
|
||||||
|
|
||||||
static readonly string[] fields = {"Name", "TileSize", "Id", "SheetSize", "Palette", "Extensions"};
|
static readonly string[] Fields = { "Name", "TileSize", "Id", "SheetSize", "Palette", "Extensions" };
|
||||||
|
|
||||||
public TileSet() {}
|
public TileSet() { }
|
||||||
|
|
||||||
public TileSet(string filepath)
|
public TileSet(string filepath)
|
||||||
{
|
{
|
||||||
@@ -112,9 +112,9 @@ namespace OpenRA.FileFormats
|
|||||||
var root = new List<MiniYamlNode>();
|
var root = new List<MiniYamlNode>();
|
||||||
var gen = new List<MiniYamlNode>();
|
var gen = new List<MiniYamlNode>();
|
||||||
|
|
||||||
foreach (var field in fields)
|
foreach (var field in Fields)
|
||||||
{
|
{
|
||||||
FieldInfo f = this.GetType().GetField(field);
|
var f = this.GetType().GetField(field);
|
||||||
if (f.GetValue(this) == null)
|
if (f.GetValue(this) == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -123,23 +123,19 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
root.Add(new MiniYamlNode("General", null, gen));
|
root.Add(new MiniYamlNode("General", null, gen));
|
||||||
|
|
||||||
root.Add(new MiniYamlNode( "Terrain", null,
|
root.Add(new MiniYamlNode("Terrain", null,
|
||||||
Terrain.Select(t => new MiniYamlNode(
|
Terrain.Select(t => new MiniYamlNode("TerrainType@{0}".F(t.Value.Type), t.Value.Save())).ToList()));
|
||||||
"TerrainType@{0}".F(t.Value.Type),
|
|
||||||
t.Value.Save())).ToList()));
|
|
||||||
|
|
||||||
root.Add(new MiniYamlNode("Templates", null,
|
root.Add(new MiniYamlNode("Templates", null,
|
||||||
Templates.Select(t => new MiniYamlNode(
|
Templates.Select(t => new MiniYamlNode("Template@{0}".F(t.Value.Id), t.Value.Save())).ToList()));
|
||||||
"Template@{0}".F(t.Value.Id),
|
|
||||||
t.Value.Save())).ToList()));
|
|
||||||
root.WriteToFile(filepath);
|
root.WriteToFile(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetTerrainType(TileReference<ushort, byte> r)
|
public string GetTerrainType(TileReference<ushort, byte> r)
|
||||||
{
|
{
|
||||||
var tt = Templates[r.type].Tiles;
|
var tt = Templates[r.Type].Tiles;
|
||||||
string ret;
|
string ret;
|
||||||
if (!tt.TryGetValue(r.index, out ret))
|
if (!tt.TryGetValue(r.Index, out ret))
|
||||||
return "Clear"; // Default walkable
|
return "Clear"; // Default walkable
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
var mapX = x + map.Bounds.Left;
|
var mapX = x + map.Bounds.Left;
|
||||||
var mapY = y + map.Bounds.Top;
|
var mapY = y + map.Bounds.Top;
|
||||||
if (map.MapResources.Value[mapX, mapY].type == 0)
|
if (map.MapResources.Value[mapX, mapY].Type == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var res = Rules.Info["world"].Traits.WithInterface<ResourceTypeInfo>()
|
var res = Rules.Info["world"].Traits.WithInterface<ResourceTypeInfo>()
|
||||||
.Where(t => t.ResourceType == map.MapResources.Value[mapX, mapY].type)
|
.Where(t => t.ResourceType == map.MapResources.Value[mapX, mapY].Type)
|
||||||
.Select(t => t.TerrainType).FirstOrDefault();
|
.Select(t => t.TerrainType).FirstOrDefault();
|
||||||
if (res == null)
|
if (res == null)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ namespace OpenRA.Graphics
|
|||||||
public Sprite TileSprite(TileReference<ushort, byte> r)
|
public Sprite TileSprite(TileReference<ushort, byte> r)
|
||||||
{
|
{
|
||||||
Sprite[] template;
|
Sprite[] template;
|
||||||
if (templates.TryGetValue(r.type, out template))
|
if (templates.TryGetValue(r.Type, out template))
|
||||||
if (template.Length > r.index && template[r.index] != null)
|
if (template.Length > r.Index && template[r.Index] != null)
|
||||||
return template[r.index];
|
return template[r.Index];
|
||||||
|
|
||||||
return missingTile;
|
return missingTile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace OpenRA
|
|||||||
public static Map FromTileset(string tileset)
|
public static Map FromTileset(string tileset)
|
||||||
{
|
{
|
||||||
var tile = OpenRA.Rules.TileSets[tileset].Templates.First();
|
var tile = OpenRA.Rules.TileSets[tileset].Templates.First();
|
||||||
var tileRef = new TileReference<ushort, byte> { type = tile.Key, index = (byte)0 };
|
var tileRef = new TileReference<ushort, byte> { Type = tile.Key, Index = (byte)0 };
|
||||||
|
|
||||||
Map map = new Map()
|
Map map = new Map()
|
||||||
{
|
{
|
||||||
@@ -349,17 +349,17 @@ namespace OpenRA
|
|||||||
for (var i = 0; i < MapSize.X; i++)
|
for (var i = 0; i < MapSize.X; i++)
|
||||||
for (var j = 0; j < MapSize.Y; j++)
|
for (var j = 0; j < MapSize.Y; j++)
|
||||||
{
|
{
|
||||||
writer.Write(MapTiles.Value[i, j].type);
|
writer.Write(MapTiles.Value[i, j].Type);
|
||||||
var pickAny = OpenRA.Rules.TileSets[Tileset].Templates[MapTiles.Value[i, j].type].PickAny;
|
var pickAny = OpenRA.Rules.TileSets[Tileset].Templates[MapTiles.Value[i, j].Type].PickAny;
|
||||||
writer.Write(pickAny ? (byte)(i % 4 + (j % 4) * 4) : MapTiles.Value[i, j].index);
|
writer.Write(pickAny ? (byte)(i % 4 + (j % 4) * 4) : MapTiles.Value[i, j].Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resource data
|
// Resource data
|
||||||
for (var i = 0; i < MapSize.X; i++)
|
for (var i = 0; i < MapSize.X; i++)
|
||||||
for (var j = 0; j < MapSize.Y; j++)
|
for (var j = 0; j < MapSize.Y; j++)
|
||||||
{
|
{
|
||||||
writer.Write(MapResources.Value[i, j].type);
|
writer.Write(MapResources.Value[i, j].Type);
|
||||||
writer.Write(MapResources.Value[i, j].index);
|
writer.Write(MapResources.Value[i, j].Index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace OpenRA.Traits
|
|||||||
for (var y = map.Bounds.Top; y < map.Bounds.Bottom; y++)
|
for (var y = map.Bounds.Top; y < map.Bounds.Bottom; y++)
|
||||||
{
|
{
|
||||||
var type = resourceTypes.FirstOrDefault(
|
var type = resourceTypes.FirstOrDefault(
|
||||||
r => r.info.ResourceType == w.Map.MapResources.Value[x, y].type);
|
r => r.info.ResourceType == w.Map.MapResources.Value[x, y].Type);
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA
|
|||||||
// Loop through the map looking for templates to overlay
|
// Loop through the map looking for templates to overlay
|
||||||
for (int i = w.Map.Bounds.Left; i < w.Map.Bounds.Right; i++)
|
for (int i = w.Map.Bounds.Left; i < w.Map.Bounds.Right; i++)
|
||||||
for (int j = w.Map.Bounds.Top; j < w.Map.Bounds.Bottom; j++)
|
for (int j = w.Map.Bounds.Top; j < w.Map.Bounds.Bottom; j++)
|
||||||
if (BridgeTypes.Keys.Contains(w.Map.MapTiles.Value[i, j].type))
|
if (BridgeTypes.Keys.Contains(w.Map.MapTiles.Value[i, j].Type))
|
||||||
ConvertBridgeToActor(w, i, j);
|
ConvertBridgeToActor(w, i, j);
|
||||||
|
|
||||||
// Link adjacent (long)-bridges so that artwork is updated correctly
|
// Link adjacent (long)-bridges so that artwork is updated correctly
|
||||||
@@ -66,8 +66,8 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Correlate the tile "image" aka subtile with its position to find the template origin
|
// Correlate the tile "image" aka subtile with its position to find the template origin
|
||||||
var tile = w.Map.MapTiles.Value[i, j].type;
|
var tile = w.Map.MapTiles.Value[i, j].Type;
|
||||||
var index = w.Map.MapTiles.Value[i, j].index;
|
var index = w.Map.MapTiles.Value[i, j].Index;
|
||||||
var template = w.TileSet.Templates[tile];
|
var template = w.TileSet.Templates[tile];
|
||||||
var ni = i - index % template.Size.X;
|
var ni = i - index % template.Size.X;
|
||||||
var nj = j - index / template.Size.X;
|
var nj = j - index / template.Size.X;
|
||||||
@@ -90,8 +90,8 @@ namespace OpenRA.Mods.RA
|
|||||||
var y = nj + ind / template.Size.X;
|
var y = nj + ind / template.Size.X;
|
||||||
|
|
||||||
// This isn't the bridge you're looking for
|
// This isn't the bridge you're looking for
|
||||||
if (!w.Map.IsInMap(x, y) || w.Map.MapTiles.Value[x, y].type != tile ||
|
if (!w.Map.IsInMap(x, y) || w.Map.MapTiles.Value[x, y].Type != tile ||
|
||||||
w.Map.MapTiles.Value[x, y].index != ind)
|
w.Map.MapTiles.Value[x, y].Index != ind)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
subTiles.Add(new CPos(x, y), ind);
|
subTiles.Add(new CPos(x, y), ind);
|
||||||
|
|||||||
8
OpenRA.Mods.RA/World/SmudgeLayer.cs
Executable file → Normal file
8
OpenRA.Mods.RA/World/SmudgeLayer.cs
Executable file → Normal file
@@ -69,9 +69,9 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
// Existing smudge; make it deeper
|
// Existing smudge; make it deeper
|
||||||
var tile = dirty.ContainsKey(loc) ? dirty[loc] : tiles[loc];
|
var tile = dirty.ContainsKey(loc) ? dirty[loc] : tiles[loc];
|
||||||
var depth = Info.Depths[tile.type - 1];
|
var depth = Info.Depths[tile.Type - 1];
|
||||||
if (tile.index < depth - 1)
|
if (tile.Index < depth - 1)
|
||||||
tile.index++;
|
tile.Index++;
|
||||||
|
|
||||||
dirty[loc] = tile;
|
dirty[loc] = tile;
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (world.ShroudObscures(kv.Key))
|
if (world.ShroudObscures(kv.Key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
smudgeSprites[kv.Value.type - 1][kv.Value.index].DrawAt(kv.Key.ToPPos().ToFloat2(), pal);
|
smudgeSprites[kv.Value.Type - 1][kv.Value.Index].DrawAt(kv.Key.ToPPos().ToFloat2(), pal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user