diff --git a/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs b/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs index 636a76b079..ca19cc7dd6 100644 --- a/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits readonly World world; readonly BuildingInfluence buildingInfluence; - readonly List dirty = new List(); + readonly HashSet dirty = new HashSet(); protected readonly CellLayer Content; protected readonly CellLayer RenderContent; @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits public ResourceLayer(Actor self) { world = self.World; - buildingInfluence = world.WorldActor.Trait(); + buildingInfluence = self.Trait(); Content = new CellLayer(world.Map); RenderContent = new CellLayer(world.Map); @@ -102,8 +102,8 @@ namespace OpenRA.Mods.Common.Traits var temp = Content[cell]; temp.Density = Math.Max(density, 1); - RenderContent[cell] = Content[cell] = temp; - UpdateRenderedSprite(cell); + Content[cell] = temp; + dirty.Add(cell); } } } @@ -200,8 +200,7 @@ namespace OpenRA.Mods.Common.Traits cell.Density = Math.Min(cell.Type.Info.MaxDensity, cell.Density + n); Content[p] = cell; - if (!dirty.Contains(p)) - dirty.Add(p); + dirty.Add(p); } public bool IsFull(CPos cell) @@ -223,8 +222,7 @@ namespace OpenRA.Mods.Common.Traits else Content[cell] = c; - if (!dirty.Contains(cell)) - dirty.Add(cell); + dirty.Add(cell); return c.Type; } @@ -239,8 +237,7 @@ namespace OpenRA.Mods.Common.Traits Content[cell] = EmptyCell; world.Map.CustomTerrain[cell] = byte.MaxValue; - if (!dirty.Contains(cell)) - dirty.Add(cell); + dirty.Add(cell); } public ResourceType GetResource(CPos cell) { return Content[cell].Type; }