From 16e6522c97f387977ba5eb485fdc63469e61cfee Mon Sep 17 00:00:00 2001 From: SoulSilverJD <165866563+SoulSilverJD@users.noreply.github.com> Date: Tue, 16 Jun 2026 03:56:44 -0400 Subject: [PATCH] Stale Cache Causing Night Sky to Disappear I've have come to terms with tile properties simply being overwritten in some shape or form, while the cache does work I failed to add a case where the tile properties are not applied or lost. This should fix the bug with the disappearing Night_Sky_Sheet on certain maps by first validating if the property is applied if a cache is in play. --- .../Framework/Managers/SkyManager.cs | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/DynamicReflections/Framework/Managers/SkyManager.cs b/DynamicReflections/Framework/Managers/SkyManager.cs index 12a7d92..7d07ccb 100644 --- a/DynamicReflections/Framework/Managers/SkyManager.cs +++ b/DynamicReflections/Framework/Managers/SkyManager.cs @@ -36,11 +36,11 @@ public void Generate(GameLocation location, bool force = false) return; } - if (_locationToSkyTiles is null) + if (_locationToSkyTiles is null || _locationToSkyPoints is null) { Reset(); } - else if (force is false && _locationToSkyTiles.ContainsKey(location) is true && _locationToSkyTiles[location] is not null) + else if (force is false && IsGeneratedStateCurrent(location) is true) { return; } @@ -48,6 +48,52 @@ public void Generate(GameLocation location, bool force = false) GeneratePerTile(location); } + private bool IsGeneratedStateCurrent(GameLocation location) + { + if (_locationToSkyTiles.ContainsKey(location) is false || _locationToSkyTiles[location] is null) + { + return false; + } + + if (_locationToSkyPoints.ContainsKey(location) is false || _locationToSkyPoints[location] is null) + { + return false; + } + + if (location.Map.GetLayer("Back") is not Layer backLayer) + { + return false; + } + + var skyTiles = _locationToSkyTiles[location]; + if (skyTiles.GetLength(0) != backLayer.LayerWidth || skyTiles.GetLength(1) != backLayer.LayerHeight) + { + return false; + } + + var skyPoints = _locationToSkyPoints[location]; + if (skyPoints.Count == 0) + { + return true; + } + + foreach (var point in skyPoints) + { + if (point.X < 0 || point.Y < 0 || point.X >= backLayer.LayerWidth || point.Y >= backLayer.LayerHeight) + { + continue; + } + + var tile = backLayer.Tiles[point.X, point.Y]; + if (tile is not null && tile.Properties.ContainsKey("SkyIndex") is true) + { + return true; + } + } + + return false; + } + private void GeneratePerTile(GameLocation location) { var random = new Random((int)((long)Game1.uniqueIDForThisGame + Game1.stats.DaysPlayed * 500 + Game1.ticks + DateTime.Now.Ticks));