From d47d850753ec19d82993c5e2af8a17ca729c43a7 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 12 Jan 2021 20:00:40 -0500 Subject: tuck location map reload into method (#751) --- src/SMAPI/Metadata/CoreAssetPropagator.cs | 66 +++++++++++++++++-------------- 1 file changed, 36 insertions(+), 30 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index b82dedfd..bd1cc50e 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -138,36 +138,7 @@ namespace StardewModdingAPI.Metadata { if (!string.IsNullOrWhiteSpace(location.mapPath.Value) && this.NormalizeAssetNameIgnoringEmpty(location.mapPath.Value) == key) { - // reset patch caches - switch (location) - { - case Town _: - this.Reflection.GetField(location, "ccRefurbished").SetValue(false); - this.Reflection.GetField(location, "isShowingDestroyedJoja").SetValue(false); - this.Reflection.GetField(location, "isShowingUpgradedPamHouse").SetValue(false); - break; - - case Beach _: - case BeachNightMarket _: - case Forest _: - this.Reflection.GetField(location, "hasShownCCUpgrade").SetValue(false); - break; - } - - // general updates - location.reloadMap(); - location.updateSeasonalTileSheets(); - location.updateWarps(); - - // update interior doors - location.interiorDoors.Clear(); - foreach (var entry in new InteriorDoorDictionary(location)) - location.interiorDoors.Add(entry); - - // update doors - location.doors.Clear(); - location.updateDoors(); - + this.ReloadMap(location); anyChanged = true; } } @@ -803,6 +774,41 @@ namespace StardewModdingAPI.Metadata return true; } + /// Reload the map for a location. + /// The location whose map to reload. + private void ReloadMap(GameLocation location) + { + // reset patch caches + switch (location) + { + case Town _: + this.Reflection.GetField(location, "ccRefurbished").SetValue(false); + this.Reflection.GetField(location, "isShowingDestroyedJoja").SetValue(false); + this.Reflection.GetField(location, "isShowingUpgradedPamHouse").SetValue(false); + break; + + case Beach _: + case BeachNightMarket _: + case Forest _: + this.Reflection.GetField(location, "hasShownCCUpgrade").SetValue(false); + break; + } + + // general updates + location.reloadMap(); + location.updateSeasonalTileSheets(); + location.updateWarps(); + + // update interior doors + location.interiorDoors.Clear(); + foreach (var entry in new InteriorDoorDictionary(location)) + location.interiorDoors.Add(entry); + + // update doors + location.doors.Clear(); + location.updateDoors(); + } + /// Reload the disposition data for matching NPCs. /// The content manager through which to reload the asset. /// The asset key to reload. -- cgit