diff --git a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs index 7edf0ad3c5..ee6e3f47f0 100644 --- a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits 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 @@ -46,23 +46,16 @@ namespace OpenRA.Mods.Common.Traits public Sprite Sprite; } - public SmudgeLayerInfo Info; - Dictionary tiles; - Dictionary dirty; - Dictionary smudges; - World world; + public readonly SmudgeLayerInfo Info; + readonly Dictionary tiles = new Dictionary(); + readonly Dictionary dirty = new Dictionary(); + readonly Dictionary smudges = new Dictionary(); + readonly World world; - public SmudgeLayer(SmudgeLayerInfo info) + public SmudgeLayer(Actor self, SmudgeLayerInfo info) { - this.Info = info; - } - - public void WorldLoaded(World w, WorldRenderer wr) - { - world = w; - tiles = new Dictionary(); - dirty = new Dictionary(); - smudges = new Dictionary(); + Info = info; + world = self.World; var types = world.Map.SequenceProvider.Sequences(Info.Sequence); foreach (var t in types) @@ -71,7 +64,10 @@ namespace OpenRA.Mods.Common.Traits var sprites = Exts.MakeArray(seq.Length, x => seq.GetSprite(x)); smudges.Add(t, sprites); } + } + public void WorldLoaded(World w, WorldRenderer wr) + { // Add map smudges foreach (var s in w.Map.SmudgeDefinitions) {