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(key); @@ -835,6 +827,27 @@ namespace StardewModdingAPI.Metadata } } + /// Reload the sprites for matching players. + /// The asset key to reload. + 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>>>(typeof(FarmerRenderer), "_recolorOffsets").GetValue().Remove(player.getTexture()); + player.FarmerRenderer.MarkSpriteDirty(); + } + + return players.Any(); + } + /// Reload tree textures. /// The content manager through which to reload the asset. /// The asset key to reload.