Clean up SmudgeLayer init.
This commit is contained in:
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public readonly string Palette = "terrain";
|
public readonly string Palette = "terrain";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new SmudgeLayer(this); }
|
public object Create(ActorInitializer init) { return new SmudgeLayer(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SmudgeLayer : IRenderOverlay, IWorldLoaded, ITickRender
|
public class SmudgeLayer : IRenderOverlay, IWorldLoaded, ITickRender
|
||||||
@@ -46,23 +46,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public Sprite Sprite;
|
public Sprite Sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SmudgeLayerInfo Info;
|
public readonly SmudgeLayerInfo Info;
|
||||||
Dictionary<CPos, Smudge> tiles;
|
readonly Dictionary<CPos, Smudge> tiles = new Dictionary<CPos, Smudge>();
|
||||||
Dictionary<CPos, Smudge> dirty;
|
readonly Dictionary<CPos, Smudge> dirty = new Dictionary<CPos, Smudge>();
|
||||||
Dictionary<string, Sprite[]> smudges;
|
readonly Dictionary<string, Sprite[]> smudges = new Dictionary<string, Sprite[]>();
|
||||||
World world;
|
readonly World world;
|
||||||
|
|
||||||
public SmudgeLayer(SmudgeLayerInfo info)
|
public SmudgeLayer(Actor self, SmudgeLayerInfo info)
|
||||||
{
|
{
|
||||||
this.Info = info;
|
Info = info;
|
||||||
}
|
world = self.World;
|
||||||
|
|
||||||
public void WorldLoaded(World w, WorldRenderer wr)
|
|
||||||
{
|
|
||||||
world = w;
|
|
||||||
tiles = new Dictionary<CPos, Smudge>();
|
|
||||||
dirty = new Dictionary<CPos, Smudge>();
|
|
||||||
smudges = new Dictionary<string, Sprite[]>();
|
|
||||||
|
|
||||||
var types = world.Map.SequenceProvider.Sequences(Info.Sequence);
|
var types = world.Map.SequenceProvider.Sequences(Info.Sequence);
|
||||||
foreach (var t in types)
|
foreach (var t in types)
|
||||||
@@ -71,7 +64,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var sprites = Exts.MakeArray(seq.Length, x => seq.GetSprite(x));
|
var sprites = Exts.MakeArray(seq.Length, x => seq.GetSprite(x));
|
||||||
smudges.Add(t, sprites);
|
smudges.Add(t, sprites);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WorldLoaded(World w, WorldRenderer wr)
|
||||||
|
{
|
||||||
// Add map smudges
|
// Add map smudges
|
||||||
foreach (var s in w.Map.SmudgeDefinitions)
|
foreach (var s in w.Map.SmudgeDefinitions)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user