summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-12 15:45:54 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-12 15:45:54 -0500
commit5518e4cf241e487da26bd2e651a57724389edfe2 (patch)
treeb8cfa124f7aa300231dd64de3f606343cfaa3922
parent351f5ad5e0ec7f0fe703888b7fd5a3770a330e15 (diff)
downloadSMAPI-5518e4cf241e487da26bd2e651a57724389edfe2.tar.gz
SMAPI-5518e4cf241e487da26bd2e651a57724389edfe2.tar.bz2
SMAPI-5518e4cf241e487da26bd2e651a57724389edfe2.zip
fix asset propagation for player sprites not affecting other players or recolor maps
-rw-r--r--docs/release-notes.md3
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs33
2 files changed, 26 insertions, 10 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 63cbbc2c..f5c49a88 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -9,6 +9,9 @@
* Fixed 'collection was modified' error when returning to title in rare cases.
* Fixed update-check error if a mod's Chucklefish page has no version.
+For modders:
+ * Asset propagation for player sprites now affects other players' sprites, and updates recolor maps (e.g. sleeves).
+
* For SMAPI/tool developers:
* The `/mods` web API endpoint now includes version mappings from the wiki.
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs
index b86a6790..abe28ce9 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -190,17 +190,9 @@ namespace StardewModdingAPI.Metadata
case "characters\\farmer\\farmer_base": // Farmer
case "characters\\farmer\\farmer_base_bald":
- if (Game1.player == null || !Game1.player.IsMale)
- return false;
- Game1.player.FarmerRenderer = new FarmerRenderer(key, Game1.player);
- return true;
-
- case "characters\\farmer\\farmer_girl_base": // Farmer
+ case "characters\\farmer\\farmer_girl_base":
case "characters\\farmer\\farmer_girl_base_bald":
- if (Game1.player == null || Game1.player.IsMale)
- return false;
- Game1.player.FarmerRenderer = new FarmerRenderer(key, Game1.player);
- return true;
+ return this.ReloadPlayerSprites(key);
case "characters\\farmer\\hairstyles": // Game1.LoadContent
FarmerRenderer.hairStylesTexture = content.Load<Texture2D>(key);
@@ -835,6 +827,27 @@ namespace StardewModdingAPI.Metadata
}
}
+ /// <summary>Reload the sprites for matching players.</summary>
+ /// <param name="key">The asset key to reload.</param>
+ private bool ReloadPlayerSprites(string key)
+ {
+ Farmer[] players =
+ (
+ from player in Game1.getOnlineFarmers()
+ where key == this.NormalizeAssetNameIgnoringEmpty(player.getTexture())
+ select player
+ )
+ .ToArray();
+
+ foreach (Farmer player in players)
+ {
+ this.Reflection.GetField<Dictionary<string, Dictionary<int, List<int>>>>(typeof(FarmerRenderer), "_recolorOffsets").GetValue().Remove(player.getTexture());
+ player.FarmerRenderer.MarkSpriteDirty();
+ }
+
+ return players.Any();
+ }
+
/// <summary>Reload tree textures.</summary>
/// <param name="content">The content manager through which to reload the asset.</param>
/// <param name="key">The asset key to reload.</param>