summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md3
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs33
2 files changed, 35 insertions, 1 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index c2b58cd2..cfcaf65c 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -6,7 +6,8 @@
* Fixed Console Commands' handling of tool upgrade levels for item commands.
* For modders:
- * Reloading a map asset will now automatically update affected locations.
+ * Reloading a map asset will now update affected locations.
+ * Reloading the `Data\NPCDispositions` asset will now update affected NPCs.
* Fixed newlines in most manifest fields not being ignored.
* For the web UI:
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs
index 841e6d64..8083b4b1 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Framework.Reflection;
using StardewValley;
@@ -163,6 +164,9 @@ namespace StardewModdingAPI.Metadata
case "data\\craftingrecipes": // CraftingRecipe.InitShared
return CraftingRecipe.craftingRecipes = content.Load<Dictionary<string, string>>(key);
+ case "data\\npcdispositions": // NPC constructor
+ return this.ReloadNpcDispositions(content, key);
+
case "data\\npcgifttastes": // Game1.loadContent
return Game1.NPCGiftTastes = content.Load<Dictionary<string, string>>(key);
@@ -482,6 +486,35 @@ namespace StardewModdingAPI.Metadata
return true;
}
+ /// <summary>Reload the disposition data for matching NPCs.</summary>
+ /// <param name="content">The content manager through which to reload the asset.</param>
+ /// <param name="key">The asset key to reload.</param>
+ /// <returns>Returns whether any NPCs were affected.</returns>
+ private bool ReloadNpcDispositions(LocalizedContentManager content, string key)
+ {
+ IDictionary<string, string> dispositions = content.Load<Dictionary<string, string>>(key);
+ foreach (NPC character in this.GetCharacters())
+ {
+ if (!character.isVillager() || !dispositions.ContainsKey(character.Name))
+ continue;
+
+ NPC clone = new NPC(null, Vector2.Zero, 0, character.Name);
+ character.Age = clone.Age;
+ character.Manners = clone.Manners;
+ character.SocialAnxiety = clone.SocialAnxiety;
+ character.Optimism = clone.Optimism;
+ character.Gender = clone.Gender;
+ character.datable.Value = clone.datable.Value;
+ character.homeRegion = clone.homeRegion;
+ character.Birthday_Season = clone.Birthday_Season;
+ character.Birthday_Day = clone.Birthday_Day;
+ character.id = clone.id;
+ character.displayName = clone.displayName;
+ }
+
+ return true;
+ }
+
/// <summary>Reload the sprites for matching NPCs.</summary>
/// <param name="content">The content manager through which to reload the asset.</param>
/// <param name="key">The asset key to reload.</param>