diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-06-13 19:35:51 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-14 18:03:54 -0400 |
commit | 31c882c8cea66bbd2805cc5aab11abbce248782c (patch) | |
tree | 4368ebe2d3b4a98ab505ede69cdc267245d206ac /src | |
parent | 93551c094139d4446ef5c4fc69bcda26e49e62bd (diff) | |
download | SMAPI-31c882c8cea66bbd2805cc5aab11abbce248782c.tar.gz SMAPI-31c882c8cea66bbd2805cc5aab11abbce248782c.tar.bz2 SMAPI-31c882c8cea66bbd2805cc5aab11abbce248782c.zip |
fix map reloads not updating door warps (#643)
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI/Metadata/CoreAssetPropagator.cs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index bb269643..186cd4ee 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI.Framework.Reflection; using StardewValley; @@ -14,6 +15,7 @@ using StardewValley.Objects; using StardewValley.Projectiles; using StardewValley.TerrainFeatures; using xTile; +using xTile.ObjectModel; using xTile.Tiles; namespace StardewModdingAPI.Metadata @@ -138,10 +140,37 @@ namespace StardewModdingAPI.Metadata { if (!string.IsNullOrWhiteSpace(location.mapPath.Value) && this.GetNormalisedPath(location.mapPath.Value) == key) { + // general updates location.reloadMap(); location.updateSeasonalTileSheets(); location.updateWarps(); - this.Reflection.GetField<InteriorDoorDictionary>(location, nameof(location.interiorDoors)).SetValue(new InteriorDoorDictionary(location)); + + // update interior doors + location.interiorDoors.Clear(); + foreach (var entry in new InteriorDoorDictionary(location)) + location.interiorDoors.Add(entry); + + // update doors (derived from GameLocation.loadObjects) + location.doors.Clear(); + for (int x = 0; x < location.map.Layers[0].LayerWidth; ++x) + { + for (int y = 0; y < location.map.Layers[0].LayerHeight; ++y) + { + if (location.map.GetLayer("Buildings").Tiles[x, y] != null) + { + location.map.GetLayer("Buildings").Tiles[x, y].Properties.TryGetValue("Action", out PropertyValue action); + if (action != null && action.ToString().Contains("Warp")) + { + string[] strArray = action.ToString().Split(' '); + if (strArray[0] == "WarpCommunityCenter") + location.doors.Add(new Point(x, y), "CommunityCenter"); + else if ((location.Name != "Mountain" || x != 8 || y != 20) && strArray.Length > 2) + location.doors.Add(new Point(x, y), strArray[3]); + } + } + } + } + anyChanged = true; } } |