diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-01-12 15:45:54 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-01-12 15:45:54 -0500 |
commit | 5518e4cf241e487da26bd2e651a57724389edfe2 (patch) | |
tree | b8cfa124f7aa300231dd64de3f606343cfaa3922 /src/SMAPI/Metadata/CoreAssetPropagator.cs | |
parent | 351f5ad5e0ec7f0fe703888b7fd5a3770a330e15 (diff) | |
download | SMAPI-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.cs | 33 |
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> |