summaryrefslogtreecommitdiff
path: root/src/SMAPI/Metadata/CoreAssetPropagator.cs
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 /src/SMAPI/Metadata/CoreAssetPropagator.cs
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
Diffstat (limited to 'src/SMAPI/Metadata/CoreAssetPropagator.cs')
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs33
1 files changed, 23 insertions, 10 deletions
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>