diff options
| author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2018-12-16 17:25:58 -0500 |
|---|---|---|
| committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2018-12-16 17:25:58 -0500 |
| commit | b214a76965d98ca785b64b490533b6bf66371a48 (patch) | |
| tree | 76017f8b5762d9cb4e179d32a6b44270e6726051 /src/SMAPI/Metadata | |
| parent | 13ed6decf55a7fd72c34b965397011d3012cb9cc (diff) | |
| parent | fd0af5f3c149629b91bbe1651a7bda9564b860eb (diff) | |
| download | SMAPI-b214a76965d98ca785b64b490533b6bf66371a48.tar.gz SMAPI-b214a76965d98ca785b64b490533b6bf66371a48.tar.bz2 SMAPI-b214a76965d98ca785b64b490533b6bf66371a48.zip | |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Metadata')
| -rw-r--r-- | src/SMAPI/Metadata/CoreAssetPropagator.cs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 90629d7f..a44ab7d1 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -31,6 +31,9 @@ namespace StardewModdingAPI.Metadata /// <summary>Simplifies access to private game code.</summary> private readonly Reflector Reflection; + /// <summary>Encapsulates monitoring and logging.</summary> + private readonly IMonitor Monitor; + /********* ** Public methods @@ -38,10 +41,12 @@ namespace StardewModdingAPI.Metadata /// <summary>Initialise the core asset data.</summary> /// <param name="getNormalisedPath">Normalises an asset key to match the cache key.</param> /// <param name="reflection">Simplifies access to private code.</param> - public CoreAssetPropagator(Func<string, string> getNormalisedPath, Reflector reflection) + /// <param name="monitor">Encapsulates monitoring and logging.</param> + public CoreAssetPropagator(Func<string, string> getNormalisedPath, Reflector reflection, IMonitor monitor) { this.GetNormalisedPath = getNormalisedPath; this.Reflection = reflection; + this.Monitor = monitor; } /// <summary>Reload one of the game's core assets (if applicable).</summary> @@ -499,7 +504,7 @@ namespace StardewModdingAPI.Metadata if (!character.isVillager() || !dispositions.ContainsKey(character.Name)) continue; - NPC clone = new NPC(null, Vector2.Zero, 0, character.Name); + NPC clone = new NPC(null, character.Position, character.DefaultMap, character.FacingDirection, character.Name, null, character.Portrait, eventActor: false); character.Age = clone.Age; character.Manners = clone.Manners; character.SocialAnxiety = clone.SocialAnxiety; @@ -619,6 +624,11 @@ namespace StardewModdingAPI.Metadata { // reload schedule villager.Schedule = villager.getSchedule(Game1.dayOfMonth); + if (villager.Schedule == null) + { + this.Monitor.Log($"A mod set an invalid schedule for {villager.Name ?? key}, so the NPC may not behave correctly.", LogLevel.Warn); + return true; + } // switch to new schedule if needed int lastScheduleTime = villager.Schedule.Keys.Where(p => p <= Game1.timeOfDay).OrderByDescending(p => p).FirstOrDefault(); |
