diff --git a/GeneralMods/UnifiedSaveCore/AUnifiedSaveCore.csproj b/GeneralMods/UnifiedSaveCore/AUnifiedSaveCore.csproj
index 7a93166d..33b5f8bb 100644
--- a/GeneralMods/UnifiedSaveCore/AUnifiedSaveCore.csproj
+++ b/GeneralMods/UnifiedSaveCore/AUnifiedSaveCore.csproj
@@ -50,6 +50,7 @@
+
diff --git a/GeneralMods/UnifiedSaveCore/Framework/LocationHandler.cs b/GeneralMods/UnifiedSaveCore/Framework/LocationHandler.cs
index 84308985..88c75224 100644
--- a/GeneralMods/UnifiedSaveCore/Framework/LocationHandler.cs
+++ b/GeneralMods/UnifiedSaveCore/Framework/LocationHandler.cs
@@ -34,7 +34,7 @@ namespace UnifiedSaveCore.Framework
Game1.locations.Add(loc);
}
locations.Clear();
- //Game1.warpFarmer(oldLocation.name, (int)position.X*Game1.tileSize, (int)position.Y*Game1.tileSize, oldFacingDirection);
+ Game1.warpFarmer(oldLocation.name, (int)position.X/Game1.tileSize, (int)position.Y/Game1.tileSize, oldFacingDirection);
}
//Removes all game locations for the game to save.
@@ -46,7 +46,7 @@ namespace UnifiedSaveCore.Framework
oldFacingDirection = Game1.player.facingDirection;
Vector2 bed = Game1.player.mostRecentBed;
- //Game1.warpFarmer("Farmhouse", (int)bed.X, (int)bed.Y, 2);
+ Game1.warpFarmer("Farmhouse", (int)bed.X/Game1.tileSize, (int)bed.Y/Game1.tileSize, 2);
foreach (var loc in Game1.locations)
{
//UnifiedSaveCore.monitor.Log(loc.GetType().ToString());
diff --git a/GeneralMods/UnifiedSaveCore/Framework/NPCHandler.cs b/GeneralMods/UnifiedSaveCore/Framework/NPCHandler.cs
new file mode 100644
index 00000000..a8924da3
--- /dev/null
+++ b/GeneralMods/UnifiedSaveCore/Framework/NPCHandler.cs
@@ -0,0 +1,72 @@
+using StardewValley;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UnifiedSaveCore.Framework
+{
+ public class NPCHandler:IInformationHandler
+ {
+ ///
+ /// Deals with characters at specific locations.
+ ///
+ Dictionary> characterLocations;
+
+ ///
+ /// Constructor.
+ ///
+ public NPCHandler()
+ {
+ characterLocations = new Dictionary>();
+ }
+
+ ///
+ /// Removes all custom characters before saving.
+ ///
+ public void beforeSave()
+ {
+ foreach (var loc in Game1.locations)
+ {
+ List characters = new List();
+ foreach (var character in loc.characters)
+ {
+ foreach (Type t in UnifiedSaveCore.modTypes)
+ {
+ if (character.GetType().ToString() == t.ToString())
+ {
+ characters.Add(character);
+ }
+ }
+
+ }
+ foreach (var character in characters)
+ {
+ loc.characters.Remove(character);
+ }
+ characterLocations.Add(loc, characters);
+ }
+ }
+
+ ///
+ /// Restores all custom characters after saving.
+ ///
+ public void afterSave()
+ {
+ foreach(KeyValuePair> pair in characterLocations)
+ {
+ foreach(var npc in pair.Value)
+ {
+ pair.Key.characters.Add(npc);
+ }
+ }
+ characterLocations.Clear();
+ }
+
+ public void afterLoad()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/GeneralMods/UnifiedSaveCore/ModCore.cs b/GeneralMods/UnifiedSaveCore/ModCore.cs
index 20e1e93f..dfaf8fca 100644
--- a/GeneralMods/UnifiedSaveCore/ModCore.cs
+++ b/GeneralMods/UnifiedSaveCore/ModCore.cs
@@ -75,6 +75,7 @@ namespace UnifiedSaveCore
"xTile",
};
+ //taken from attribute example.
foreach (Assembly asm in assemblies)
{
@@ -127,13 +128,14 @@ namespace UnifiedSaveCore
//Console.WriteLine("{0} VERSIONS: (A){1} (F){2} (P){3}", name, asmV, fileV, prodV);
}
- StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave;
- StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave;
- StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
+ //StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave;
+ //StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave;
+ //StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
saveCoreAPI = new SaveCoreAPI();
dataHandlers = new List();
dataHandlers.Add(new LocationHandler());
+ dataHandlers.Add(new NPCHandler());
}