From 155d0cc97d9b5e630faee71d0f05c4c1fbc501b4 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 4 Aug 2015 21:59:22 +0100 Subject: [PATCH] Reveal the initial resources if shroud is disabled. Fixes #8943. --- .../Traits/World/ResourceLayer.cs | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs b/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs index 042bb2ca65..80bbfe0d23 100644 --- a/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs @@ -86,35 +86,6 @@ namespace OpenRA.Mods.Common.Traits var resources = w.WorldActor.TraitsImplementing() .ToDictionary(r => r.Info.ResourceType, r => r); - foreach (var cell in w.Map.AllCells) - { - ResourceType t; - if (!resources.TryGetValue(w.Map.MapResources.Value[cell].Type, out t)) - continue; - - if (!AllowResourceAt(t, cell)) - continue; - - Content[cell] = CreateResourceCell(t, cell); - } - - // Set initial density based on the number of neighboring resources - foreach (var cell in w.Map.AllCells) - { - var type = Content[cell].Type; - if (type != null) - { - // Adjacent includes the current cell, so is always >= 1 - var adjacent = GetAdjacentCellsWith(type, cell); - var density = int2.Lerp(0, type.Info.MaxDensity, adjacent, 9); - var temp = Content[cell]; - temp.Density = Math.Max(density, 1); - - Content[cell] = temp; - dirty.Add(cell); - } - } - // Build the sprite layer dictionary for rendering resources // All resources that have the same palette must also share a sheet and blend mode foreach (var r in resources) @@ -135,6 +106,37 @@ namespace OpenRA.Mods.Common.Traits throw new InvalidDataException("Resource sprites specify different blend modes. " + "Try using different palettes for resource types that use different blend modes."); } + + foreach (var cell in w.Map.AllCells) + { + ResourceType t; + if (!resources.TryGetValue(w.Map.MapResources.Value[cell].Type, out t)) + continue; + + if (!AllowResourceAt(t, cell)) + continue; + + Content[cell] = CreateResourceCell(t, cell); + } + + foreach (var cell in w.Map.AllCells) + { + var type = Content[cell].Type; + if (type != null) + { + // Set initial density based on the number of neighboring resources + // Adjacent includes the current cell, so is always >= 1 + var adjacent = GetAdjacentCellsWith(type, cell); + var density = int2.Lerp(0, type.Info.MaxDensity, adjacent, 9); + var temp = Content[cell]; + temp.Density = Math.Max(density, 1); + + // Initialize the RenderContent with the initial map state + // because the shroud may not be enabled. + RenderContent[cell] = Content[cell] = temp; + UpdateRenderedSprite(cell); + } + } } protected virtual void UpdateRenderedSprite(CPos cell)