summaryrefslogtreecommitdiff
path: root/src/SMAPI/Metadata
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-02-08 18:20:03 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-02-08 18:20:03 -0500
commit84b9f4336d5b0c7f269a7bfbb94042360574bbaa (patch)
tree0a4d138f88522ca101bff739c8ade1f62c74fbfe /src/SMAPI/Metadata
parent79c616600576acf16f70daad68cc60a22cbbbf74 (diff)
parent41f77f51c0203fa36c1e47cf67409244ed3c2ff2 (diff)
downloadSMAPI-84b9f4336d5b0c7f269a7bfbb94042360574bbaa.tar.gz
SMAPI-84b9f4336d5b0c7f269a7bfbb94042360574bbaa.tar.bz2
SMAPI-84b9f4336d5b0c7f269a7bfbb94042360574bbaa.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Metadata')
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs25
-rw-r--r--src/SMAPI/Metadata/InstructionMetadata.cs3
2 files changed, 24 insertions, 4 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs
index d83fc748..a64dc89b 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Microsoft.Xna.Framework;
+using System.Reflection;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Framework.Reflection;
using StardewValley;
@@ -99,8 +99,21 @@ namespace StardewModdingAPI.Metadata
{
if (!string.IsNullOrWhiteSpace(location.mapPath.Value) && this.GetNormalisedPath(location.mapPath.Value) == key)
{
+ // reload map data
this.Reflection.GetMethod(location, "reloadMap").Invoke();
this.Reflection.GetMethod(location, "updateWarps").Invoke();
+
+ // reload doors
+ {
+ Type interiorDoorDictType = Type.GetType($"StardewValley.InteriorDoorDictionary, {Constants.GameAssemblyName}", throwOnError: true);
+ ConstructorInfo constructor = interiorDoorDictType.GetConstructor(new[] { typeof(GameLocation) });
+ if (constructor == null)
+ throw new InvalidOperationException("Can't reset location doors: constructor not found for InteriorDoorDictionary type.");
+ object instance = constructor.Invoke(new object[] { location });
+
+ this.Reflection.GetField<object>(location, "interiorDoors").SetValue(instance);
+ }
+
anyChanged = true;
}
}
@@ -529,7 +542,7 @@ namespace StardewModdingAPI.Metadata
{
// get NPCs
NPC[] characters = this.GetCharacters()
- .Where(npc => this.GetNormalisedPath(npc.Sprite.textureName.Value) == key)
+ .Where(npc => npc.Sprite != null && this.GetNormalisedPath(npc.Sprite.textureName.Value) == key)
.ToArray();
if (!characters.Any())
return false;
@@ -677,7 +690,13 @@ namespace StardewModdingAPI.Metadata
/// <summary>Get all locations in the game.</summary>
private IEnumerable<GameLocation> GetLocations()
{
- foreach (GameLocation location in Game1.locations)
+ // get available root locations
+ IEnumerable<GameLocation> rootLocations = Game1.locations;
+ if (SaveGame.loaded?.locations != null)
+ rootLocations = rootLocations.Concat(SaveGame.loaded.locations);
+
+ // yield root + child locations
+ foreach (GameLocation location in rootLocations)
{
yield return location;
diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs
index 9ff99440..272ceb09 100644
--- a/src/SMAPI/Metadata/InstructionMetadata.cs
+++ b/src/SMAPI/Metadata/InstructionMetadata.cs
@@ -51,7 +51,8 @@ namespace StardewModdingAPI.Metadata
yield return new FieldFinder(typeof(SaveGame).FullName, nameof(SaveGame.serializer), InstructionHandleResult.DetectedSaveSerialiser);
yield return new FieldFinder(typeof(SaveGame).FullName, nameof(SaveGame.farmerSerializer), InstructionHandleResult.DetectedSaveSerialiser);
yield return new FieldFinder(typeof(SaveGame).FullName, nameof(SaveGame.locationSerializer), InstructionHandleResult.DetectedSaveSerialiser);
- yield return new TypeFinder(typeof(ISpecialisedEvents).FullName, InstructionHandleResult.DetectedUnvalidatedUpdateTick);
+ yield return new EventFinder(typeof(ISpecialisedEvents).FullName, nameof(ISpecialisedEvents.UnvalidatedUpdateTicked), InstructionHandleResult.DetectedUnvalidatedUpdateTick);
+ yield return new EventFinder(typeof(ISpecialisedEvents).FullName, nameof(ISpecialisedEvents.UnvalidatedUpdateTicking), InstructionHandleResult.DetectedUnvalidatedUpdateTick);
#if !SMAPI_3_0_STRICT
yield return new EventFinder(typeof(SpecialisedEvents).FullName, nameof(SpecialisedEvents.UnvalidatedUpdateTick), InstructionHandleResult.DetectedUnvalidatedUpdateTick);
#endif