diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-11-11 20:56:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 20:56:35 -0500 |
commit | a52f888c3f7098eb06f4ae2e6a3a5b1998470d15 (patch) | |
tree | a2484f50ce3b2a7e511f2cd6991a589edbc9e3ea /src/SMAPI/Metadata | |
parent | 42bcd3068f24a4b3ec14e1ec6132956218643679 (diff) | |
parent | 286c2d244949f4eee62e2de440938d2d8ae3ce76 (diff) | |
download | SMAPI-a52f888c3f7098eb06f4ae2e6a3a5b1998470d15.tar.gz SMAPI-a52f888c3f7098eb06f4ae2e6a3a5b1998470d15.tar.bz2 SMAPI-a52f888c3f7098eb06f4ae2e6a3a5b1998470d15.zip |
Merge pull request #883 from SinZ163/feature/sinz/farmhand-mapedit
Add logic to remove from the multiplayer map cache for asset propagation
Diffstat (limited to 'src/SMAPI/Metadata')
-rw-r--r-- | src/SMAPI/Metadata/CoreAssetPropagator.cs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 1ef9a8f2..037e4573 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -40,6 +40,9 @@ namespace StardewModdingAPI.Metadata /// <summary>Writes messages to the console.</summary> private readonly IMonitor Monitor; + /// <summary>The multiplayer instance whose map cache to update.</summary> + private readonly Multiplayer Multiplayer; + /// <summary>Simplifies access to private game code.</summary> private readonly Reflector Reflection; @@ -70,13 +73,15 @@ namespace StardewModdingAPI.Metadata /// <param name="mainContent">The main content manager through which to reload assets.</param> /// <param name="disposableContent">An internal content manager used only for asset propagation.</param> /// <param name="monitor">Writes messages to the console.</param> + /// <param name="multiplayer">The multiplayer instance whose map cache to update.</param> /// <param name="reflection">Simplifies access to private code.</param> /// <param name="parseAssetName">Parse a raw asset name.</param> - public CoreAssetPropagator(LocalizedContentManager mainContent, GameContentManagerForAssetPropagation disposableContent, IMonitor monitor, Reflector reflection, Func<string, IAssetName> parseAssetName) + public CoreAssetPropagator(LocalizedContentManager mainContent, GameContentManagerForAssetPropagation disposableContent, IMonitor monitor, Multiplayer multiplayer, Reflector reflection, Func<string, IAssetName> parseAssetName) { this.MainContentManager = mainContent; this.DisposableContentManager = disposableContent; this.Monitor = monitor; + this.Multiplayer = multiplayer; this.Reflection = reflection; this.ParseAssetName = parseAssetName; } @@ -1166,6 +1171,10 @@ namespace StardewModdingAPI.Metadata GameLocation location = locationInfo.Location; Vector2? playerPos = Game1.player?.Position; + // clear multiplayer cache for farmhands + if (!Context.IsMainPlayer) + this.Multiplayer.cachedMultiplayerMaps.Remove(location.NameOrUniqueName); + // reload map location.interiorDoors.Clear(); // prevent errors when doors try to update tiles which no longer exist location.reloadMap(); |