fix asset propagation for player sprites not affecting other players or recolor maps
This commit is contained in:
parent
351f5ad5e0
commit
5518e4cf24
|
@ -9,6 +9,9 @@
|
||||||
* Fixed 'collection was modified' error when returning to title in rare cases.
|
* 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.
|
* 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:
|
* For SMAPI/tool developers:
|
||||||
* The `/mods` web API endpoint now includes version mappings from the wiki.
|
* The `/mods` web API endpoint now includes version mappings from the wiki.
|
||||||
|
|
||||||
|
|
|
@ -190,17 +190,9 @@ namespace StardewModdingAPI.Metadata
|
||||||
|
|
||||||
case "characters\\farmer\\farmer_base": // Farmer
|
case "characters\\farmer\\farmer_base": // Farmer
|
||||||
case "characters\\farmer\\farmer_base_bald":
|
case "characters\\farmer\\farmer_base_bald":
|
||||||
if (Game1.player == null || !Game1.player.IsMale)
|
case "characters\\farmer\\farmer_girl_base":
|
||||||
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_bald":
|
case "characters\\farmer\\farmer_girl_base_bald":
|
||||||
if (Game1.player == null || Game1.player.IsMale)
|
return this.ReloadPlayerSprites(key);
|
||||||
return false;
|
|
||||||
Game1.player.FarmerRenderer = new FarmerRenderer(key, Game1.player);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case "characters\\farmer\\hairstyles": // Game1.LoadContent
|
case "characters\\farmer\\hairstyles": // Game1.LoadContent
|
||||||
FarmerRenderer.hairStylesTexture = content.Load<Texture2D>(key);
|
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>
|
/// <summary>Reload tree textures.</summary>
|
||||||
/// <param name="content">The content manager through which to reload the asset.</param>
|
/// <param name="content">The content manager through which to reload the asset.</param>
|
||||||
/// <param name="key">The asset key to reload.</param>
|
/// <param name="key">The asset key to reload.</param>
|
||||||
|
|
Loading…
Reference in New Issue