unify SaveAnywhere's save utilities
This commit is contained in:
parent
d99a45144e
commit
5a7bac7ea5
|
@ -1,33 +0,0 @@
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere
|
|
||||||
{
|
|
||||||
class Animal_Utilities
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void save_animal_info()
|
|
||||||
{
|
|
||||||
Mod_Core.animal_path = Path.Combine(Mod_Core.player_path, "Animals");
|
|
||||||
if (!Directory.Exists(Mod_Core.animal_path))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(Mod_Core.animal_path);
|
|
||||||
|
|
||||||
}
|
|
||||||
Horse_Utility.Save_Horse_Info();
|
|
||||||
Pet_Utilities.save_pet_info();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void load_animal_info()
|
|
||||||
{
|
|
||||||
Mod_Core.animal_path = Path.Combine(Mod_Core.player_path, "Animals");
|
|
||||||
if (!Directory.Exists(Mod_Core.animal_path))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(Mod_Core.animal_path);
|
|
||||||
|
|
||||||
}
|
|
||||||
Horse_Utility.Load_Horse_Info();
|
|
||||||
Pet_Utilities.Load_pet_Info();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
{
|
{
|
||||||
//loads the data to the variables upon loading the game.
|
//loads the data to the variables upon loading the game.
|
||||||
string myname = StardewValley.Game1.player.name;
|
string myname = StardewValley.Game1.player.name;
|
||||||
string mylocation = Path.Combine(Mod_Core.mod_path, "Save_Anywhere_Config");
|
string mylocation = Path.Combine(SaveAnywhere.mod_path, "Save_Anywhere_Config");
|
||||||
string mylocation2 = mylocation;
|
string mylocation2 = mylocation;
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
||||||
|
@ -33,7 +33,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
//write all of my info to a text file.
|
//write all of my info to a text file.
|
||||||
string myname = StardewValley.Game1.player.name;
|
string myname = StardewValley.Game1.player.name;
|
||||||
|
|
||||||
string mylocation = Path.Combine(Mod_Core.mod_path, "Save_Anywhere_Config");
|
string mylocation = Path.Combine(SaveAnywhere.mod_path, "Save_Anywhere_Config");
|
||||||
string mylocation2 = mylocation;
|
string mylocation2 = mylocation;
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using StardewModdingAPI;
|
|
||||||
using StardewValley;
|
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere
|
|
||||||
{
|
|
||||||
public class GameUtilities
|
|
||||||
{
|
|
||||||
public static bool passiveSave;
|
|
||||||
public static bool should_ship;
|
|
||||||
public static void save_game()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
|
|
||||||
if (Game1.player.currentLocation.name == "Sewer")
|
|
||||||
{
|
|
||||||
Log.Error("There is an issue saving in the Sewer. Blame the animals for not being saved to the player's save file.");
|
|
||||||
Log.Error("Your data has not been saved. Sorry for the issue.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//if a player has shipped an item, run this code.
|
|
||||||
if (Enumerable.Count<Item>((IEnumerable<Item>)Game1.getFarm().shippingBin) > 0)
|
|
||||||
{
|
|
||||||
should_ship = true;
|
|
||||||
// Game1.endOfNightMenus.Push((IClickableMenu)new ShippingMenu(Game1.getFarm().shippingBin));
|
|
||||||
// Game1.showEndOfNightStuff(); //shows the nightly shipping menu.
|
|
||||||
// Game1.getFarm().shippingBin.Clear(); //clears out the shipping bin to prevent exploits
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
shipping_check();
|
|
||||||
// Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu();
|
|
||||||
}
|
|
||||||
catch(Exception rrr)
|
|
||||||
{
|
|
||||||
Game1.showRedMessage("Can't save here. See log for error.");
|
|
||||||
Mod_Core.thisMonitor.Log(rrr.ToString(), LogLevel.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); //This command is what allows the player to save anywhere as it calls the saving function.
|
|
||||||
|
|
||||||
Player_Utilities.save_player_info();
|
|
||||||
Animal_Utilities.save_animal_info();
|
|
||||||
NPC_Utilities.Save_NPC_Info();
|
|
||||||
|
|
||||||
//grab the player's info
|
|
||||||
// player_map_name = StardewValley.Game1.player.currentLocation.name;
|
|
||||||
// player_tile_x = StardewValley.Game1.player.getTileX();
|
|
||||||
// player_tile_Y = StardewValley.Game1.player.getTileY();
|
|
||||||
// player_flop = false;
|
|
||||||
|
|
||||||
// MyWritter_Player(); //write my info to a text file
|
|
||||||
|
|
||||||
|
|
||||||
// MyWritter_Horse();
|
|
||||||
|
|
||||||
// DataLoader_Settings(); //load settings. Prevents acidental overwrite.
|
|
||||||
// MyWritter_Settings(); //save settings.
|
|
||||||
|
|
||||||
//Game1.warpFarmer(player_map_name, player_tile_x, player_tile_Y, player_flop); //refresh the player's location just incase. That will prove that they character's info was valid.
|
|
||||||
|
|
||||||
//so this is essentially the basics of the code...
|
|
||||||
// Log.Error("IS THIS BREAKING?");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void shipping_check()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Game1.activeClickableMenu != null) return;
|
|
||||||
if (should_ship == true)
|
|
||||||
{
|
|
||||||
Game1.activeClickableMenu = new New_Shipping_Menu(Game1.getFarm().shippingBin);
|
|
||||||
should_ship = false;
|
|
||||||
Game1.getFarm().shippingBin.Clear();
|
|
||||||
Game1.getFarm().lastItemShipped = null;
|
|
||||||
passiveSave = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,118 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using Microsoft.Xna.Framework;
|
|
||||||
using StardewModdingAPI;
|
|
||||||
using StardewValley;
|
|
||||||
using StardewValley.Characters;
|
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere
|
|
||||||
{
|
|
||||||
class Horse_Utility
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void Save_Horse_Info()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
Horse horse = Utility.findHorse();
|
|
||||||
|
|
||||||
|
|
||||||
if (horse == null)
|
|
||||||
{
|
|
||||||
//Game1.getFarm().characters.Add((NPC)new Horse(this.player_tile_x + 1, this.player_tile_Y + 1));
|
|
||||||
Mod_Core.thisMonitor.Log("NEIGH: No horse exists", LogLevel.Debug);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// else
|
|
||||||
// Game1.warpCharacter((NPC)horse, Game1.player.currentLocation.name, StardewValley.Game1.player.getTileLocationPoint(), false, true);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string myname = StardewValley.Game1.player.name;
|
|
||||||
|
|
||||||
string mylocation = Path.Combine(Mod_Core.animal_path, "Horse_Save_Info_");
|
|
||||||
string mylocation2 = mylocation + myname;
|
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
|
||||||
string[] mystring3 = new string[20];
|
|
||||||
if (!File.Exists(mylocation3))
|
|
||||||
{
|
|
||||||
|
|
||||||
Mod_Core.thisMonitor.Log("The horse save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Debug);
|
|
||||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
||||||
|
|
||||||
mystring3[0] = "Horse: Save_Anywhere Info. Editing this might break some things.";
|
|
||||||
mystring3[1] = "====================================================================================";
|
|
||||||
|
|
||||||
mystring3[2] = "Horse Current Map Name";
|
|
||||||
mystring3[3] = horse.currentLocation.name.ToString();
|
|
||||||
|
|
||||||
mystring3[4] = "Horse X Position";
|
|
||||||
mystring3[5] = horse.getTileX().ToString();
|
|
||||||
|
|
||||||
mystring3[6] = "Horse Y Position";
|
|
||||||
mystring3[7] = horse.getTileY().ToString();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File.WriteAllLines(mylocation3, mystring3);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
|
||||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
||||||
|
|
||||||
mystring3[0] = "Horse: Save_Anywhere Info. Editing this might break some things.";
|
|
||||||
mystring3[1] = "====================================================================================";
|
|
||||||
|
|
||||||
mystring3[2] = "Horse Current Map Name";
|
|
||||||
mystring3[3] = horse.currentLocation.name.ToString();
|
|
||||||
|
|
||||||
mystring3[4] = "Horse X Position";
|
|
||||||
mystring3[5] = horse.getTileX().ToString();
|
|
||||||
|
|
||||||
mystring3[6] = "Horse Y Position";
|
|
||||||
mystring3[7] = horse.getTileY().ToString();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File.WriteAllLines(mylocation3, mystring3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Load_Horse_Info()
|
|
||||||
{
|
|
||||||
Horse horse = Utility.findHorse();
|
|
||||||
if (horse == null)
|
|
||||||
{
|
|
||||||
Mod_Core.thisMonitor.Log("NEIGH: No horse exists", LogLevel.Debug);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// DataLoader_Settings();
|
|
||||||
//loads the data to the variables upon loading the game.
|
|
||||||
string myname = StardewValley.Game1.player.name;
|
|
||||||
string mylocation = Path.Combine(Mod_Core.animal_path, "Horse_Save_Info_");
|
|
||||||
string mylocation2 = mylocation + myname;
|
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
|
||||||
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string horse_map_name = "";
|
|
||||||
int horse_x;
|
|
||||||
int horse_y;
|
|
||||||
Point horse_point;
|
|
||||||
string[] readtext = File.ReadAllLines(mylocation3);
|
|
||||||
horse_map_name = Convert.ToString(readtext[3]);
|
|
||||||
horse_x = Convert.ToInt32(readtext[5]);
|
|
||||||
horse_y = Convert.ToInt32(readtext[7]);
|
|
||||||
horse_point.X = horse_x;
|
|
||||||
horse_point.Y = horse_y;
|
|
||||||
Game1.warpCharacter((NPC)horse, horse_map_name, horse_point, false, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ using StardewValley.Characters;
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere
|
namespace Omegasis.SaveAnywhere
|
||||||
{
|
{
|
||||||
public class Mod_Core : StardewModdingAPI.Mod
|
public class SaveAnywhere : Mod
|
||||||
{
|
{
|
||||||
|
|
||||||
public static string mod_path;
|
public static string mod_path;
|
||||||
|
@ -28,19 +28,20 @@ namespace Omegasis.SaveAnywhere
|
||||||
|
|
||||||
public override void Entry(IModHelper helper)
|
public override void Entry(IModHelper helper)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += KeyPressed_Save_Load_Menu;
|
{
|
||||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += PlayerEvents_LoadedGame;
|
ControlEvents.KeyPressed += KeyPressed_Save_Load_Menu;
|
||||||
StardewModdingAPI.Events.GameEvents.UpdateTick += Warp_Check;
|
SaveEvents.AfterLoad += PlayerEvents_LoadedGame;
|
||||||
StardewModdingAPI.Events.GameEvents.UpdateTick += PassiveSaveChecker;
|
GameEvents.UpdateTick += Warp_Check;
|
||||||
StardewModdingAPI.Events.TimeEvents.TimeOfDayChanged += NPC_scheduel_update;
|
GameEvents.UpdateTick += PassiveSaveChecker;
|
||||||
StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged;
|
TimeEvents.TimeOfDayChanged += NPC_scheduel_update;
|
||||||
StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_OnNewDay;
|
TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged;
|
||||||
mod_path = Helper.DirectoryPath;
|
TimeEvents.DayOfMonthChanged += TimeEvents_OnNewDay;
|
||||||
|
SaveAnywhere.mod_path = Helper.DirectoryPath;
|
||||||
npc_key_value_pair = new Dictionary<string, string>();
|
npc_key_value_pair = new Dictionary<string, string>();
|
||||||
thisMonitor = Monitor;
|
SaveAnywhere.thisMonitor = Monitor;
|
||||||
}
|
}
|
||||||
catch(Exception x)
|
catch (Exception x)
|
||||||
{
|
{
|
||||||
Monitor.Log(x.ToString());
|
Monitor.Log(x.ToString());
|
||||||
}
|
}
|
||||||
|
@ -48,24 +49,25 @@ namespace Omegasis.SaveAnywhere
|
||||||
|
|
||||||
private void PassiveSaveChecker(object sender, EventArgs e)
|
private void PassiveSaveChecker(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (GameUtilities.passiveSave == true && Game1.activeClickableMenu==null)
|
if (SaveUtilities.passiveSave == true && Game1.activeClickableMenu == null)
|
||||||
{
|
{
|
||||||
Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu();
|
Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu();
|
||||||
GameUtilities.passiveSave = false;
|
SaveUtilities.passiveSave = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//done
|
//done
|
||||||
private void TimeEvents_OnNewDay(object sender, EventArgsIntChanged e)
|
private void TimeEvents_OnNewDay(object sender, EventArgsIntChanged e)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
//Log.Info("Day of Month Changed");
|
//Log.Info("Day of Month Changed");
|
||||||
new_day = true;
|
SaveAnywhere.new_day = true;
|
||||||
string name = Game1.player.name;
|
string name = Game1.player.name;
|
||||||
Mod_Core.player_path = Path.Combine(Mod_Core.mod_path, "Save_Data", name);
|
SaveAnywhere.player_path = Path.Combine(SaveAnywhere.mod_path, "Save_Data", name);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Monitor.Log(err.ToString());
|
Monitor.Log(err.ToString());
|
||||||
}
|
}
|
||||||
|
@ -74,7 +76,8 @@ namespace Omegasis.SaveAnywhere
|
||||||
//done
|
//done
|
||||||
private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e)
|
private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
//new_day = true;
|
//new_day = true;
|
||||||
// Log.Info("Day of Month Changed");
|
// Log.Info("Day of Month Changed");
|
||||||
npc_key_value_pair.Clear();
|
npc_key_value_pair.Clear();
|
||||||
|
@ -83,12 +86,12 @@ namespace Omegasis.SaveAnywhere
|
||||||
foreach (var character in loc.characters)
|
foreach (var character in loc.characters)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!npc_key_value_pair.ContainsKey(character.name)) npc_key_value_pair.Add(character.name, parseSchedule(character));
|
if (!npc_key_value_pair.ContainsKey(character.name)) npc_key_value_pair.Add(character.name, parseSchedule(character));
|
||||||
// Monitor.Log(parseSchedule(character));
|
// Monitor.Log(parseSchedule(character));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Monitor.Log(err.ToString());
|
Monitor.Log(err.ToString());
|
||||||
}
|
}
|
||||||
|
@ -114,10 +117,10 @@ namespace Omegasis.SaveAnywhere
|
||||||
// MethodInfo dynMethod = typeof(NPC).GetMethod("prepareToDisembarkOnNewSchedulePath",BindingFlags.NonPublic | BindingFlags.Instance);
|
// MethodInfo dynMethod = typeof(NPC).GetMethod("prepareToDisembarkOnNewSchedulePath",BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
MethodInfo dynMethod2 = typeof(NPC).GetMethod("pathfindToNextScheduleLocation", BindingFlags.NonPublic | BindingFlags.Instance);
|
MethodInfo dynMethod2 = typeof(NPC).GetMethod("pathfindToNextScheduleLocation", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
|
||||||
if (npc_warp == false) return;
|
if (SaveAnywhere.npc_warp == false) return;
|
||||||
if (new_day == true) return;
|
if (SaveAnywhere.new_day == true) return;
|
||||||
List<StardewValley.Characters.Child> child_list = new List<StardewValley.Characters.Child>();
|
List<Child> child_list = new List<Child>();
|
||||||
child_list = StardewValley.Game1.player.getChildren();
|
child_list = Game1.player.getChildren();
|
||||||
foreach (var loc in Game1.locations)
|
foreach (var loc in Game1.locations)
|
||||||
{
|
{
|
||||||
foreach (var npc in loc.characters)
|
foreach (var npc in loc.characters)
|
||||||
|
@ -131,7 +134,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
if (npc.name == child_name.name) continue;
|
if (npc.name == child_name.name) continue;
|
||||||
}
|
}
|
||||||
if (npc.name == Game1.player.getPetName()) continue;
|
if (npc.name == Game1.player.getPetName()) continue;
|
||||||
Horse horse = StardewValley.Utility.findHorse();
|
Horse horse = Utility.findHorse();
|
||||||
if (horse != null)
|
if (horse != null)
|
||||||
{
|
{
|
||||||
if (npc.name == horse.name) continue;
|
if (npc.name == horse.name) continue;
|
||||||
|
@ -220,7 +223,8 @@ namespace Omegasis.SaveAnywhere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
if (Convert.ToInt32(valueArray2.ElementAt(0)) > Game1.timeOfDay) break;
|
if (Convert.ToInt32(valueArray2.ElementAt(0)) > Game1.timeOfDay) break;
|
||||||
end_map = Convert.ToString(valueArray2.ElementAt(1));
|
end_map = Convert.ToString(valueArray2.ElementAt(1));
|
||||||
x = Convert.ToInt32(valueArray2.ElementAt(2));
|
x = Convert.ToInt32(valueArray2.ElementAt(2));
|
||||||
|
@ -260,7 +264,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
once = true;
|
SaveAnywhere.once = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -529,7 +533,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
|
|
||||||
return key_value;
|
return key_value;
|
||||||
}
|
}
|
||||||
catch(Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Monitor.Log(err.ToString());
|
Monitor.Log(err.ToString());
|
||||||
return null;
|
return null;
|
||||||
|
@ -576,8 +580,8 @@ namespace Omegasis.SaveAnywhere
|
||||||
if (!Game1.isRaining && dictionary.ContainsKey("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
if (!Game1.isRaining && dictionary.ContainsKey("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
||||||
{
|
{
|
||||||
FieldInfo field = typeof(NPC).GetField("nameofTodaysSchedule", BindingFlags.NonPublic | BindingFlags.Instance);
|
FieldInfo field = typeof(NPC).GetField("nameofTodaysSchedule", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
field.SetValue(npc,"marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth));
|
field.SetValue(npc, "marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth));
|
||||||
return result="marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
return result = "marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
||||||
}
|
}
|
||||||
npc.followSchedule = false;
|
npc.followSchedule = false;
|
||||||
return null;
|
return null;
|
||||||
|
@ -586,33 +590,33 @@ namespace Omegasis.SaveAnywhere
|
||||||
{
|
{
|
||||||
if (dictionary.ContainsKey(Game1.currentSeason + "_" + Game1.dayOfMonth))
|
if (dictionary.ContainsKey(Game1.currentSeason + "_" + Game1.dayOfMonth))
|
||||||
{
|
{
|
||||||
return result=(Game1.currentSeason + "_" + Game1.dayOfMonth);
|
return result = (Game1.currentSeason + "_" + Game1.dayOfMonth);
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
for (i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); i > 0; i--)
|
for (i = (Game1.player.friendships.ContainsKey(npc.name) ? (Game1.player.friendships[npc.name][0] / 250) : -1); i > 0; i--)
|
||||||
{
|
{
|
||||||
if (dictionary.ContainsKey(Game1.dayOfMonth + "_" + i))
|
if (dictionary.ContainsKey(Game1.dayOfMonth + "_" + i))
|
||||||
{
|
{
|
||||||
return result=Game1.dayOfMonth + "_" + i;
|
return result = Game1.dayOfMonth + "_" + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey(string.Empty + Game1.dayOfMonth))
|
if (dictionary.ContainsKey(string.Empty + Game1.dayOfMonth))
|
||||||
{
|
{
|
||||||
return result=string.Empty + Game1.dayOfMonth;
|
return result = string.Empty + Game1.dayOfMonth;
|
||||||
}
|
}
|
||||||
if (npc.name.Equals("Pam") && Game1.player.mailReceived.Contains("ccVault"))
|
if (npc.name.Equals("Pam") && Game1.player.mailReceived.Contains("ccVault"))
|
||||||
{
|
{
|
||||||
return result="bus";
|
return result = "bus";
|
||||||
}
|
}
|
||||||
if (Game1.isRaining)
|
if (Game1.isRaining)
|
||||||
{
|
{
|
||||||
if (Game1.random.NextDouble() < 0.5 && dictionary.ContainsKey("rain2"))
|
if (Game1.random.NextDouble() < 0.5 && dictionary.ContainsKey("rain2"))
|
||||||
{
|
{
|
||||||
return result="rain2";
|
return result = "rain2";
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey("rain"))
|
if (dictionary.ContainsKey("rain"))
|
||||||
{
|
{
|
||||||
return result="rain";
|
return result = "rain";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<string> list = new List<string>
|
List<string> list = new List<string>
|
||||||
|
@ -626,26 +630,26 @@ namespace Omegasis.SaveAnywhere
|
||||||
list.Add(string.Empty + i);
|
list.Add(string.Empty + i);
|
||||||
if (dictionary.ContainsKey(string.Join("_", list)))
|
if (dictionary.ContainsKey(string.Join("_", list)))
|
||||||
{
|
{
|
||||||
return result=string.Join("_", list);
|
return result = string.Join("_", list);
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
list.RemoveAt(list.Count - 1);
|
list.RemoveAt(list.Count - 1);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey(string.Join("_", list)))
|
if (dictionary.ContainsKey(string.Join("_", list)))
|
||||||
{
|
{
|
||||||
return result=string.Join("_", list);
|
return result = string.Join("_", list);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
if (dictionary.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
||||||
{
|
{
|
||||||
return result=Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
return result = Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey(Game1.currentSeason))
|
if (dictionary.ContainsKey(Game1.currentSeason))
|
||||||
{
|
{
|
||||||
return result=Game1.currentSeason;
|
return result = Game1.currentSeason;
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
if (dictionary.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
||||||
{
|
{
|
||||||
return result="spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
return result = "spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
||||||
}
|
}
|
||||||
list.RemoveAt(list.Count - 1);
|
list.RemoveAt(list.Count - 1);
|
||||||
list.Add("spring");
|
list.Add("spring");
|
||||||
|
@ -655,14 +659,14 @@ namespace Omegasis.SaveAnywhere
|
||||||
list.Add(string.Empty + i);
|
list.Add(string.Empty + i);
|
||||||
if (dictionary.ContainsKey(string.Join("_", list)))
|
if (dictionary.ContainsKey(string.Join("_", list)))
|
||||||
{
|
{
|
||||||
return result=string.Join("_", list);
|
return result = string.Join("_", list);
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
list.RemoveAt(list.Count - 1);
|
list.RemoveAt(list.Count - 1);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey("spring"))
|
if (dictionary.ContainsKey("spring"))
|
||||||
{
|
{
|
||||||
return result="spring";
|
return result = "spring";
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -673,11 +677,12 @@ namespace Omegasis.SaveAnywhere
|
||||||
//done
|
//done
|
||||||
private void ShippingCheck(object sender, EventArgs e)
|
private void ShippingCheck(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
if (Game1.activeClickableMenu != null) return;
|
if (Game1.activeClickableMenu != null) return;
|
||||||
GameUtilities.shipping_check();
|
SaveUtilities.shipping_check();
|
||||||
}
|
}
|
||||||
catch(Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Monitor.Log(err.ToString());
|
Monitor.Log(err.ToString());
|
||||||
}
|
}
|
||||||
|
@ -688,9 +693,9 @@ namespace Omegasis.SaveAnywhere
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string name = StardewValley.Game1.player.name;
|
string name = Game1.player.name;
|
||||||
Mod_Core.player_path = Path.Combine(Mod_Core.mod_path, "Save_Data", name);
|
SaveAnywhere.player_path = Path.Combine(SaveAnywhere.mod_path, "Save_Data", name);
|
||||||
if (!Directory.Exists(Mod_Core.player_path))
|
if (!Directory.Exists(SaveAnywhere.player_path))
|
||||||
{
|
{
|
||||||
//Log.AsyncM(Save_Anywhere_V2.Mod_Core.player_path);
|
//Log.AsyncM(Save_Anywhere_V2.Mod_Core.player_path);
|
||||||
//Log.AsyncC("WOOPS");
|
//Log.AsyncC("WOOPS");
|
||||||
|
@ -699,13 +704,13 @@ namespace Omegasis.SaveAnywhere
|
||||||
|
|
||||||
// Log.AsyncY(Player_Utilities.has_player_warped_yet);
|
// Log.AsyncY(Player_Utilities.has_player_warped_yet);
|
||||||
|
|
||||||
if (Player_Utilities.has_player_warped_yet == false && Game1.player.isMoving() == true)
|
if (SaveUtilities.has_player_warped_yet == false && Game1.player.isMoving() == true)
|
||||||
{
|
{
|
||||||
//Log.AsyncM("Ok Good");
|
//Log.AsyncM("Ok Good");
|
||||||
Player_Utilities.warp_player();
|
SaveUtilities.warp_player();
|
||||||
Animal_Utilities.load_animal_info();
|
SaveUtilities.load_animal_info();
|
||||||
NPC_Utilities.Load_NPC_Info();
|
SaveUtilities.Load_NPC_Info();
|
||||||
Player_Utilities.has_player_warped_yet = true;
|
SaveUtilities.has_player_warped_yet = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -719,27 +724,30 @@ namespace Omegasis.SaveAnywhere
|
||||||
//done
|
//done
|
||||||
private void PlayerEvents_LoadedGame(object sender, EventArgs e)
|
private void PlayerEvents_LoadedGame(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
Player_Utilities.load_player_info();
|
{
|
||||||
|
SaveUtilities.load_player_info();
|
||||||
Config_Utilities.DataLoader_Settings();
|
Config_Utilities.DataLoader_Settings();
|
||||||
Config_Utilities.MyWritter_Settings();
|
Config_Utilities.MyWritter_Settings();
|
||||||
}
|
}
|
||||||
catch (Exception err) {
|
catch (Exception err)
|
||||||
|
{
|
||||||
Monitor.Log(err.ToString());
|
Monitor.Log(err.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KeyPressed_Save_Load_Menu(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
|
public void KeyPressed_Save_Load_Menu(object sender, EventArgsKeyPressed e)
|
||||||
{
|
{
|
||||||
if (e.KeyPressed.ToString() == Config_Utilities.key_binding) //if the key is pressed, load my cusom save function
|
if (e.KeyPressed.ToString() == Config_Utilities.key_binding) //if the key is pressed, load my cusom save function
|
||||||
{
|
{
|
||||||
if (Game1.activeClickableMenu != null) return;
|
if (Game1.activeClickableMenu != null) return;
|
||||||
try {
|
try
|
||||||
GameUtilities.save_game();
|
|
||||||
}
|
|
||||||
catch(Exception exe)
|
|
||||||
{
|
{
|
||||||
Mod_Core.thisMonitor.Log(exe.ToString(), LogLevel.Error);
|
SaveUtilities.save_game();
|
||||||
|
}
|
||||||
|
catch (Exception exe)
|
||||||
|
{
|
||||||
|
SaveAnywhere.thisMonitor.Log(exe.ToString(), LogLevel.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -775,7 +783,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name)["spring"]);
|
return parseMasterSchedule(npc, Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name)["spring"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (array[0].Contains("NOT"))
|
if (array[0].Contains("NOT"))
|
||||||
|
@ -803,7 +811,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
}
|
}
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name)["spring"]);
|
return parseMasterSchedule(npc, Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name)["spring"]);
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
@ -862,13 +870,13 @@ namespace Omegasis.SaveAnywhere
|
||||||
{
|
{
|
||||||
finalFacingDirection = 2;
|
finalFacingDirection = 2;
|
||||||
}
|
}
|
||||||
if (changeScheduleForLocationAccessibility(npc,ref text4, ref num6, ref num7, ref finalFacingDirection))
|
if (changeScheduleForLocationAccessibility(npc, ref text4, ref num6, ref num7, ref finalFacingDirection))
|
||||||
{
|
{
|
||||||
if (Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name).ContainsKey("default"))
|
if (Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name).ContainsKey("default"))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name)["default"]);
|
return parseMasterSchedule(npc, Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name)["default"]);
|
||||||
}
|
}
|
||||||
return parseMasterSchedule(npc,Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name)["spring"]);
|
return parseMasterSchedule(npc, Game1.content.Load<Dictionary<string, string>>("Characters\\schedules\\" + npc.name)["spring"]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -888,7 +896,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dictionary.Add(key, pathfindToNextScheduleLocation(npc,text3, point.X, point.Y, text4, num6, num7, finalFacingDirection, endBehavior, endMessage));
|
dictionary.Add(key, pathfindToNextScheduleLocation(npc, text3, point.X, point.Y, text4, num6, num7, finalFacingDirection, endBehavior, endMessage));
|
||||||
point.X = num6;
|
point.X = num6;
|
||||||
point.Y = num7;
|
point.Y = num7;
|
||||||
text3 = text4;
|
text3 = text4;
|
||||||
|
@ -898,7 +906,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<int, SchedulePathDescription> getSchedule(NPC npc,int dayOfMonth)
|
public Dictionary<int, SchedulePathDescription> getSchedule(NPC npc, int dayOfMonth)
|
||||||
{
|
{
|
||||||
if (!npc.name.Equals("Robin") || Game1.player.currentUpgrade != null)
|
if (!npc.name.Equals("Robin") || Game1.player.currentUpgrade != null)
|
||||||
{
|
{
|
||||||
|
@ -971,7 +979,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey("rain"))
|
if (dictionary.ContainsKey("rain"))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,dictionary["rain"]);
|
return parseMasterSchedule(npc, dictionary["rain"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<string> list = new List<string>
|
List<string> list = new List<string>
|
||||||
|
@ -985,26 +993,26 @@ namespace Omegasis.SaveAnywhere
|
||||||
list.Add(string.Empty + i);
|
list.Add(string.Empty + i);
|
||||||
if (dictionary.ContainsKey(string.Join("_", list)))
|
if (dictionary.ContainsKey(string.Join("_", list)))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,dictionary[string.Join("_", list)]);
|
return parseMasterSchedule(npc, dictionary[string.Join("_", list)]);
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
list.RemoveAt(list.Count - 1);
|
list.RemoveAt(list.Count - 1);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey(string.Join("_", list)))
|
if (dictionary.ContainsKey(string.Join("_", list)))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,dictionary[string.Join("_", list)]);
|
return parseMasterSchedule(npc, dictionary[string.Join("_", list)]);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
if (dictionary.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,dictionary[Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)]);
|
return parseMasterSchedule(npc, dictionary[Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)]);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey(Game1.currentSeason))
|
if (dictionary.ContainsKey(Game1.currentSeason))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,dictionary[Game1.currentSeason]);
|
return parseMasterSchedule(npc, dictionary[Game1.currentSeason]);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
if (dictionary.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,dictionary["spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)]);
|
return parseMasterSchedule(npc, dictionary["spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)]);
|
||||||
}
|
}
|
||||||
list.RemoveAt(list.Count - 1);
|
list.RemoveAt(list.Count - 1);
|
||||||
list.Add("spring");
|
list.Add("spring");
|
||||||
|
@ -1014,19 +1022,19 @@ namespace Omegasis.SaveAnywhere
|
||||||
list.Add(string.Empty + i);
|
list.Add(string.Empty + i);
|
||||||
if (dictionary.ContainsKey(string.Join("_", list)))
|
if (dictionary.ContainsKey(string.Join("_", list)))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,dictionary[string.Join("_", list)]);
|
return parseMasterSchedule(npc, dictionary[string.Join("_", list)]);
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
list.RemoveAt(list.Count - 1);
|
list.RemoveAt(list.Count - 1);
|
||||||
}
|
}
|
||||||
if (dictionary.ContainsKey("spring"))
|
if (dictionary.ContainsKey("spring"))
|
||||||
{
|
{
|
||||||
return parseMasterSchedule(npc,dictionary["spring"]);
|
return parseMasterSchedule(npc, dictionary["spring"]);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private bool changeScheduleForLocationAccessibility(NPC npc,ref string locationName, ref int tileX, ref int tileY, ref int facingDirection)
|
private bool changeScheduleForLocationAccessibility(NPC npc, ref string locationName, ref int tileX, ref int tileY, ref int facingDirection)
|
||||||
{
|
{
|
||||||
string a = locationName;
|
string a = locationName;
|
||||||
if (!(a == "JojaMart") && !(a == "Railroad"))
|
if (!(a == "JojaMart") && !(a == "Railroad"))
|
||||||
|
@ -1054,7 +1062,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SchedulePathDescription pathfindToNextScheduleLocation(NPC npc,string startingLocation, int startingX, int startingY, string endingLocation, int endingX, int endingY, int finalFacingDirection, string endBehavior, string endMessage)
|
private SchedulePathDescription pathfindToNextScheduleLocation(NPC npc, string startingLocation, int startingX, int startingY, string endingLocation, int endingX, int endingY, int finalFacingDirection, string endBehavior, string endMessage)
|
||||||
{
|
{
|
||||||
Stack<Point> stack = new Stack<Point>();
|
Stack<Point> stack = new Stack<Point>();
|
||||||
Point warpPointTarget = new Point(startingX, startingY);
|
Point warpPointTarget = new Point(startingX, startingY);
|
||||||
|
@ -1087,7 +1095,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
return new SchedulePathDescription(stack, finalFacingDirection, endBehavior, endMessage);
|
return new SchedulePathDescription(stack, finalFacingDirection, endBehavior, endMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> getLocationRoute(NPC npc,string startingLocation, string endingLocation)
|
private List<string> getLocationRoute(NPC npc, string startingLocation, string endingLocation)
|
||||||
{
|
{
|
||||||
FieldInfo field = typeof(NPC).GetField("routesFromLocationToLocation", BindingFlags.NonPublic | BindingFlags.Instance);
|
FieldInfo field = typeof(NPC).GetField("routesFromLocationToLocation", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
List<List<string>> s = (List<List<string>>)field.GetValue(npc);
|
List<List<string>> s = (List<List<string>>)field.GetValue(npc);
|
||||||
|
|
|
@ -1,198 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.Xna.Framework;
|
|
||||||
using StardewModdingAPI;
|
|
||||||
using StardewValley;
|
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere
|
|
||||||
{
|
|
||||||
class NPC_Utilities
|
|
||||||
{
|
|
||||||
public static string npc_name;
|
|
||||||
public static int npc_tile_x;
|
|
||||||
public static int npc_tile_y;
|
|
||||||
public static string npc_current_map_name;
|
|
||||||
public static System.Collections.Generic.List<List<string>> routesFromLocationToLocation = new List<List<string>>();
|
|
||||||
public static Microsoft.Xna.Framework.Point npc_point;
|
|
||||||
|
|
||||||
public static void Save_NPC_Info()
|
|
||||||
{
|
|
||||||
Mod_Core.npc_path = Path.Combine(Mod_Core.player_path, "NPC_Save_Info");
|
|
||||||
if (!Directory.Exists(Mod_Core.npc_path))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(Mod_Core.npc_path);
|
|
||||||
}
|
|
||||||
foreach (var location in Game1.locations)
|
|
||||||
{
|
|
||||||
foreach (var npc in location.characters)
|
|
||||||
{
|
|
||||||
if (npc.IsMonster == true) continue;
|
|
||||||
if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue;
|
|
||||||
npc_name = npc.name;
|
|
||||||
npc_current_map_name = location.name;
|
|
||||||
npc_tile_x = npc.getTileX();
|
|
||||||
npc_tile_y = npc.getTileY();
|
|
||||||
string mylocation = Path.Combine(Mod_Core.npc_path, npc.name);
|
|
||||||
string mylocation2 = mylocation;
|
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
|
||||||
string[] mystring3 = new string[20];
|
|
||||||
if (!File.Exists(mylocation3))
|
|
||||||
{
|
|
||||||
Mod_Core.thisMonitor.Log("Save Anywhere: The NPC save info for " + npc_name + " doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
|
||||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
||||||
|
|
||||||
mystring3[0] = "NPC: Save_Anywhere Info. Editing this might break some things.";
|
|
||||||
mystring3[1] = "====================================================================================";
|
|
||||||
|
|
||||||
mystring3[2] = "NPC Name";
|
|
||||||
mystring3[3] = npc_name.ToString();
|
|
||||||
|
|
||||||
mystring3[4] = "NPC Current Map Name";
|
|
||||||
mystring3[5] = npc_current_map_name.ToString();
|
|
||||||
|
|
||||||
mystring3[6] = "NPC X Position";
|
|
||||||
mystring3[7] = npc_tile_x.ToString();
|
|
||||||
|
|
||||||
mystring3[8] = "NPC Y Position";
|
|
||||||
mystring3[9] = npc_tile_y.ToString();
|
|
||||||
|
|
||||||
File.WriteAllLines(mylocation3, mystring3);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
|
||||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
||||||
mystring3[0] = "NPC: Save_Anywhere Info. Editing this might break some things.";
|
|
||||||
mystring3[1] = "====================================================================================";
|
|
||||||
|
|
||||||
mystring3[2] = "NPC Current Map Name";
|
|
||||||
mystring3[3] = npc_name.ToString();
|
|
||||||
|
|
||||||
mystring3[4] = "NPC Current Map Name";
|
|
||||||
mystring3[5] = npc_current_map_name.ToString();
|
|
||||||
|
|
||||||
mystring3[6] = "NPC X Position";
|
|
||||||
mystring3[7] = npc_tile_x.ToString();
|
|
||||||
|
|
||||||
mystring3[8] = "NPC Y Position";
|
|
||||||
mystring3[9] = npc_tile_y.ToString();
|
|
||||||
File.WriteAllLines(mylocation3, mystring3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Load_NPC_Info()
|
|
||||||
{
|
|
||||||
List<NPC> npc_list = new List<NPC>();
|
|
||||||
foreach (var location in Game1.locations)
|
|
||||||
{
|
|
||||||
foreach (var npc in location.characters)
|
|
||||||
{
|
|
||||||
if (npc.IsMonster == true) continue;
|
|
||||||
if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue;
|
|
||||||
if (npc is StardewValley.NPC || npc is StardewValley.Characters.Cat || npc is StardewValley.Characters.Dog) npc_list.Add(npc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach(var npc in npc_list) {
|
|
||||||
if (npc.IsMonster == true) continue;
|
|
||||||
if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue;
|
|
||||||
|
|
||||||
|
|
||||||
Mod_Core.npc_path = Path.Combine(Mod_Core.player_path, "NPC_Save_Info");
|
|
||||||
if (!Directory.Exists(Mod_Core.npc_path))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(Mod_Core.npc_path);
|
|
||||||
}
|
|
||||||
string mylocation = Path.Combine(Mod_Core.npc_path, npc.name);
|
|
||||||
string mylocation2 = mylocation;
|
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
|
||||||
string[] mystring3 = new string[20];
|
|
||||||
if (!File.Exists(mylocation3))
|
|
||||||
{
|
|
||||||
Mod_Core.thisMonitor.Log("Missing character file?!?", LogLevel.Error);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string[] readtext = File.ReadAllLines(mylocation3);
|
|
||||||
npc_name = Convert.ToString(readtext[3]);
|
|
||||||
npc_current_map_name = Convert.ToString(readtext[5]);
|
|
||||||
npc_tile_x = Convert.ToInt32(readtext[7]);
|
|
||||||
npc_tile_y = Convert.ToInt32(readtext[9]);
|
|
||||||
npc_point = new Microsoft.Xna.Framework.Point();
|
|
||||||
npc_point.X = npc_tile_x;
|
|
||||||
npc_point.Y = npc_tile_y;
|
|
||||||
if (npc_current_map_name == "" || npc_current_map_name == null) continue;
|
|
||||||
//Log.Info("Warped NPC" +npc_name);
|
|
||||||
Game1.warpCharacter((StardewValley.NPC)npc, npc_current_map_name, npc_point, false, true);
|
|
||||||
|
|
||||||
// npc.updateMovement(Game1.getLocationFromName(npc_current_map_name), Game1.currentGameTime);
|
|
||||||
//npc.moveCharacterOnSchedulePath();
|
|
||||||
// npc.dayUpdate(Game1.dayOfMonth);
|
|
||||||
//npc_update(npc, Game1.dayOfMonth);
|
|
||||||
|
|
||||||
// npc.DirectionsToNewLocation = pathfindToNextScheduleLocation(npc, npc.currentLocation.name, npc.getTileX(), npc.getTileY(), npc.currentLocation.name, 52, 99, 3, "", "");
|
|
||||||
// npc.updateMovement(npc.currentLocation,Game1.currentGameTime);
|
|
||||||
//npc.Schedule = npc.getSchedule(Game1.dayOfMonth);
|
|
||||||
//npc.moveCharacterOnSchedulePath();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Mod_Core.npc_warp = true;
|
|
||||||
}
|
|
||||||
private static Stack<Point> addToStackForSchedule(Stack<Point> original, Stack<Point> toAdd)
|
|
||||||
{
|
|
||||||
if (toAdd == null)
|
|
||||||
return original;
|
|
||||||
original = new Stack<Point>((IEnumerable<Point>)original);
|
|
||||||
while (original.Count > 0)
|
|
||||||
toAdd.Push(original.Pop());
|
|
||||||
return toAdd;
|
|
||||||
}
|
|
||||||
private static List<string> getLocationRoute(NPC npc, string startingLocation, string endingLocation)
|
|
||||||
{
|
|
||||||
foreach (List<string> list in routesFromLocationToLocation)
|
|
||||||
{
|
|
||||||
if (Enumerable.First<string>((IEnumerable<string>)list).Equals(startingLocation) && Enumerable.Last<string>((IEnumerable<string>)list).Equals(endingLocation) && (npc.gender == 0 || !list.Contains("BathHouse_MensLocker")) && (npc.gender != 0 || !list.Contains("BathHouse_WomensLocker")))
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
return (List<string>)null;
|
|
||||||
}
|
|
||||||
private static SchedulePathDescription pathfindToNextScheduleLocation(NPC npc,string startingLocation, int startingX, int startingY, string endingLocation, int endingX, int endingY, int finalFacingDirection, string endBehavior, string endMessage)
|
|
||||||
{
|
|
||||||
Stack<Point> stack = new Stack<Point>();
|
|
||||||
Point startPoint = new Point(startingX, startingY);
|
|
||||||
List<string> list = startingLocation.Equals(endingLocation) ? (List<string>)null : getLocationRoute(npc,startingLocation, endingLocation);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
for (int index = 0; index < Enumerable.Count<string>((IEnumerable<string>)list); ++index)
|
|
||||||
{
|
|
||||||
GameLocation locationFromName = Game1.getLocationFromName(list[index]);
|
|
||||||
if (index < Enumerable.Count<string>((IEnumerable<string>)list) - 1)
|
|
||||||
{
|
|
||||||
Point warpPointTo = locationFromName.getWarpPointTo(list[index + 1]);
|
|
||||||
if (warpPointTo.Equals(Point.Zero) || startPoint.Equals(Point.Zero))
|
|
||||||
throw new Exception("schedule pathing tried to find a warp point that doesn't exist.");
|
|
||||||
stack = addToStackForSchedule(stack, PathFindController.findPathForNPCSchedules(startPoint, warpPointTo, locationFromName, 30000));
|
|
||||||
startPoint = locationFromName.getWarpPointTarget(warpPointTo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
stack = addToStackForSchedule(stack, PathFindController.findPathForNPCSchedules(startPoint, new Point(endingX, endingY), locationFromName, 30000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (startingLocation.Equals(endingLocation))
|
|
||||||
stack = PathFindController.findPathForNPCSchedules(startPoint, new Point(endingX, endingY), Game1.getLocationFromName(startingLocation), 30000);
|
|
||||||
return new SchedulePathDescription(stack, finalFacingDirection, endBehavior, endMessage);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@ using StardewValley.Menus;
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere
|
namespace Omegasis.SaveAnywhere
|
||||||
{
|
{
|
||||||
public class New_Shipping_Menu : IClickableMenu
|
public class NewShippingMenu : IClickableMenu
|
||||||
{
|
{
|
||||||
public int currentPage = -1;
|
public int currentPage = -1;
|
||||||
public int currentTab = 0;
|
public int currentTab = 0;
|
||||||
|
@ -59,7 +59,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
private bool savedYet;
|
private bool savedYet;
|
||||||
private SaveGameMenu saveGameMenu;
|
private SaveGameMenu saveGameMenu;
|
||||||
|
|
||||||
public New_Shipping_Menu(List<Item> items)
|
public NewShippingMenu(List<Item> items)
|
||||||
: base(Game1.viewport.Width / 2 - 640, Game1.viewport.Height / 2 - 360, 1280, 720, false)
|
: base(Game1.viewport.Width / 2 - 640, Game1.viewport.Height / 2 - 360, 1280, 720, false)
|
||||||
{
|
{
|
||||||
this.parseItems(items);
|
this.parseItems(items);
|
||||||
|
@ -75,7 +75,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
for (int index = 0; index < 6; ++index)
|
for (int index = 0; index < 6; ++index)
|
||||||
{
|
{
|
||||||
List<ClickableTextureComponent> list = this.categories;
|
List<ClickableTextureComponent> list = this.categories;
|
||||||
ClickableTextureComponent textureComponent1 = new ClickableTextureComponent("texture"+Convert.ToString(index),new Rectangle(this.centerX + this.totalWidth / 2 - this.plusButtonWidth, this.centerY - 25 * Game1.pixelZoom * 3 + index * 27 * Game1.pixelZoom, this.plusButtonWidth, 11 * Game1.pixelZoom), "", this.getCategoryName(index), Game1.mouseCursors, new Rectangle(392, 361, 10, 11), (float)Game1.pixelZoom, false);
|
ClickableTextureComponent textureComponent1 = new ClickableTextureComponent("texture" + Convert.ToString(index), new Rectangle(this.centerX + this.totalWidth / 2 - this.plusButtonWidth, this.centerY - 25 * Game1.pixelZoom * 3 + index * 27 * Game1.pixelZoom, this.plusButtonWidth, 11 * Game1.pixelZoom), "", this.getCategoryName(index), Game1.mouseCursors, new Rectangle(392, 361, 10, 11), (float)Game1.pixelZoom, false);
|
||||||
textureComponent1.visible = index < 5 && Enumerable.Count<Item>((IEnumerable<Item>)this.categoryItems[index]) > 0;
|
textureComponent1.visible = index < 5 && Enumerable.Count<Item>((IEnumerable<Item>)this.categoryItems[index]) > 0;
|
||||||
ClickableTextureComponent textureComponent2 = textureComponent1;
|
ClickableTextureComponent textureComponent2 = textureComponent1;
|
||||||
list.Add(textureComponent2);
|
list.Add(textureComponent2);
|
||||||
|
@ -273,7 +273,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
catch (Exception rrr)
|
catch (Exception rrr)
|
||||||
{
|
{
|
||||||
Game1.showRedMessage("Can't save here. See log for error.");
|
Game1.showRedMessage("Can't save here. See log for error.");
|
||||||
Mod_Core.thisMonitor.Log(rrr.ToString(), LogLevel.Error);
|
SaveAnywhere.thisMonitor.Log(rrr.ToString(), LogLevel.Error);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -616,7 +616,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SpriteText.drawString(b, s, (int)location.X + Game1.tileSize * 5 / 4 + SpriteText.getWidthOfString(this.categoryItems[this.currentPage][index].Name + (this.categoryItems[this.currentPage][index].Stack <= 1 ? "" : " x" + (object)this.categoryItems[this.currentPage][index].Stack)), (int)location.Y + Game1.tileSize / 8, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1);
|
SpriteText.drawString(b, s, (int)location.X + Game1.tileSize * 5 / 4 + SpriteText.getWidthOfString(this.categoryItems[this.currentPage][index].Name + (this.categoryItems[this.currentPage][index].Stack <= 1 ? "" : " x" + (object)this.categoryItems[this.currentPage][index].Stack)), (int)location.Y + Game1.tileSize / 8, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1);
|
||||||
SpriteText.drawString(b, Convert.ToString(((this.categoryItems[this.currentPage][index] as StardewValley.Object).sellToStorePrice() * (this.categoryItems[this.currentPage][index] as StardewValley.Object).Stack)) +"g", (int)location.X + this.width - Game1.tileSize - SpriteText.getWidthOfString(Convert.ToString(((this.categoryItems[this.currentPage][index] as StardewValley.Object).sellToStorePrice() * (this.categoryItems[this.currentPage][index] as StardewValley.Object).Stack)) + "g"), (int)location.Y + Game1.pixelZoom * 3, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1);
|
SpriteText.drawString(b, Convert.ToString(((this.categoryItems[this.currentPage][index] as StardewValley.Object).sellToStorePrice() * (this.categoryItems[this.currentPage][index] as StardewValley.Object).Stack)) + "g", (int)location.X + this.width - Game1.tileSize - SpriteText.getWidthOfString(Convert.ToString(((this.categoryItems[this.currentPage][index] as StardewValley.Object).sellToStorePrice() * (this.categoryItems[this.currentPage][index] as StardewValley.Object).Stack)) + "g"), (int)location.Y + Game1.pixelZoom * 3, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1);
|
||||||
location.Y += (float)(Game1.tileSize + Game1.pixelZoom);
|
location.Y += (float)(Game1.tileSize + Game1.pixelZoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,138 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using StardewModdingAPI;
|
|
||||||
using StardewValley;
|
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere
|
|
||||||
{
|
|
||||||
class Pet_Utilities
|
|
||||||
{
|
|
||||||
public static string pet_name;
|
|
||||||
public static StardewValley.Character my_pet;
|
|
||||||
public static string pet_map_name;
|
|
||||||
public static int pet_tile_x;
|
|
||||||
public static int pet_tile_y;
|
|
||||||
public static bool is_pet_outside;
|
|
||||||
public static Microsoft.Xna.Framework.Point pet_point;
|
|
||||||
|
|
||||||
public static void save_pet_info()
|
|
||||||
{
|
|
||||||
if (Game1.player.hasPet() == false) return;
|
|
||||||
pet_name = Game1.player.getPetName();
|
|
||||||
foreach (var location in Game1.locations)
|
|
||||||
{
|
|
||||||
foreach (var npc in location.characters)
|
|
||||||
{
|
|
||||||
if (npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Cat)
|
|
||||||
{
|
|
||||||
pet_map_name = location.name;
|
|
||||||
pet_tile_x = npc.getTileX();
|
|
||||||
pet_tile_y = npc.getTileY();
|
|
||||||
is_pet_outside = location.isOutdoors;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
string myname = StardewValley.Game1.player.name;
|
|
||||||
string mylocation = Path.Combine(Mod_Core.animal_path, "Pet_Save_Info_");
|
|
||||||
string mylocation2 = mylocation + myname;
|
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
|
||||||
string[] mystring3 = new string[20];
|
|
||||||
if (!File.Exists(mylocation3))
|
|
||||||
{
|
|
||||||
|
|
||||||
Mod_Core.thisMonitor.Log("Save Anywhere: The pet save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Debug);
|
|
||||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
||||||
|
|
||||||
mystring3[0] = "Pet: Save_Anywhere Info. Editing this might break some things.";
|
|
||||||
mystring3[1] = "====================================================================================";
|
|
||||||
|
|
||||||
mystring3[2] = "Pet Current Map Name";
|
|
||||||
mystring3[3] = pet_map_name.ToString();
|
|
||||||
|
|
||||||
mystring3[4] = "Pet X Position";
|
|
||||||
mystring3[5] = pet_tile_x.ToString();
|
|
||||||
|
|
||||||
mystring3[6] = "Pet Y Position";
|
|
||||||
mystring3[7] = pet_tile_y.ToString();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File.WriteAllLines(mylocation3, mystring3);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
|
||||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
||||||
mystring3[0] = "Pet: Save_Anywhere Info. Editing this might break some things.";
|
|
||||||
mystring3[1] = "====================================================================================";
|
|
||||||
|
|
||||||
mystring3[2] = "Pet Current Map Name";
|
|
||||||
mystring3[3] = pet_map_name.ToString();
|
|
||||||
|
|
||||||
mystring3[4] = "Pet X Position";
|
|
||||||
mystring3[5] = pet_tile_x.ToString();
|
|
||||||
|
|
||||||
mystring3[6] = "Pet Y Position";
|
|
||||||
mystring3[7] = pet_tile_y.ToString();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File.WriteAllLines(mylocation3, mystring3);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Load_pet_Info()
|
|
||||||
{
|
|
||||||
if (Game1.player.hasPet() == false) return;
|
|
||||||
// DataLoader_Settings();
|
|
||||||
//loads the data to the variables upon loading the game.
|
|
||||||
string myname = StardewValley.Game1.player.name;
|
|
||||||
string mylocation = Path.Combine(Mod_Core.animal_path, "Pet_Save_Info_");
|
|
||||||
string mylocation2 = mylocation + myname;
|
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
|
||||||
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string[] readtext = File.ReadAllLines(mylocation3);
|
|
||||||
pet_map_name = Convert.ToString(readtext[3]);
|
|
||||||
pet_tile_x = Convert.ToInt32(readtext[5]);
|
|
||||||
pet_tile_y = Convert.ToInt32(readtext[7]);
|
|
||||||
get_pet();
|
|
||||||
pet_point = new Microsoft.Xna.Framework.Point();
|
|
||||||
pet_point.X = pet_tile_x;
|
|
||||||
pet_point.Y = pet_tile_y;
|
|
||||||
Game1.warpCharacter((StardewValley.NPC)my_pet, pet_map_name, pet_point, false, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void get_pet()
|
|
||||||
{
|
|
||||||
if (Game1.player.hasPet() == false) return;
|
|
||||||
foreach (var location in Game1.locations)
|
|
||||||
{
|
|
||||||
foreach (var npc in location.characters)
|
|
||||||
{
|
|
||||||
if (npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Cat)
|
|
||||||
{
|
|
||||||
pet_map_name = location.name;
|
|
||||||
pet_tile_x = npc.getTileX();
|
|
||||||
pet_tile_y = npc.getTileY();
|
|
||||||
is_pet_outside = location.isOutdoors;
|
|
||||||
my_pet = npc;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,165 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using StardewModdingAPI;
|
|
||||||
using StardewValley;
|
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere
|
|
||||||
{
|
|
||||||
class Player_Utilities
|
|
||||||
{
|
|
||||||
public static int player_x_tile;
|
|
||||||
public static int player_y_tile;
|
|
||||||
public static string players_current_map_name;
|
|
||||||
public static int player_game_time;
|
|
||||||
public static int player_facing_direction;
|
|
||||||
public static bool has_player_warped_yet;
|
|
||||||
public static void get_player_info()
|
|
||||||
{
|
|
||||||
get_x();
|
|
||||||
get_y();
|
|
||||||
get_current_map_name();
|
|
||||||
get_facing_direction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void get_x()
|
|
||||||
{
|
|
||||||
player_x_tile=Game1.player.getTileX();
|
|
||||||
}
|
|
||||||
public static void get_y()
|
|
||||||
{
|
|
||||||
player_y_tile = Game1.player.getTileY();
|
|
||||||
}
|
|
||||||
public static void get_current_map_name()
|
|
||||||
{
|
|
||||||
players_current_map_name = Game1.player.currentLocation.name;
|
|
||||||
}
|
|
||||||
public static void get_facing_direction()
|
|
||||||
{
|
|
||||||
player_facing_direction = Game1.player.facingDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void save_player_info()
|
|
||||||
{
|
|
||||||
get_player_info();
|
|
||||||
string name = StardewValley.Game1.player.name;
|
|
||||||
Mod_Core.player_path= Path.Combine(Mod_Core.mod_path, "Save_Data", name);
|
|
||||||
if (!Directory.Exists(Mod_Core.player_path)){
|
|
||||||
Directory.CreateDirectory(Mod_Core.player_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string mylocation = Path.Combine(Mod_Core.player_path, "Player_Save_Info_");
|
|
||||||
string mylocation2 = mylocation + name;
|
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
|
||||||
string[] mystring3 = new string[20];
|
|
||||||
if (!File.Exists(mylocation3))
|
|
||||||
{
|
|
||||||
Mod_Core.thisMonitor.Log("Save Anywhere: The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Info);
|
|
||||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
||||||
|
|
||||||
mystring3[0] = "Player: Save_Anywhere Info. Editing this might break some things.";
|
|
||||||
mystring3[1] = "====================================================================================";
|
|
||||||
|
|
||||||
mystring3[2] = "Player Current Game Time";
|
|
||||||
mystring3[3] = Game1.timeOfDay.ToString();
|
|
||||||
|
|
||||||
mystring3[4] = "Player Current Map Name";
|
|
||||||
mystring3[5] = players_current_map_name.ToString();
|
|
||||||
|
|
||||||
mystring3[6] = "Player X Position";
|
|
||||||
mystring3[7] = player_x_tile.ToString();
|
|
||||||
|
|
||||||
mystring3[8] = "Player Y Position";
|
|
||||||
mystring3[9] = player_y_tile.ToString();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File.WriteAllLines(mylocation3, mystring3);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
||||||
|
|
||||||
mystring3[0] = "Player: Save_Anywhere Info. Editing this might break some things.";
|
|
||||||
mystring3[1] = "====================================================================================";
|
|
||||||
|
|
||||||
mystring3[2] = "Player Current Game Time";
|
|
||||||
mystring3[3] = Game1.timeOfDay.ToString();
|
|
||||||
|
|
||||||
mystring3[4] = "Player Current Map Name";
|
|
||||||
mystring3[5] = players_current_map_name.ToString();
|
|
||||||
|
|
||||||
mystring3[6] = "Player X Position";
|
|
||||||
mystring3[7] = player_x_tile.ToString();
|
|
||||||
|
|
||||||
mystring3[8] = "Player Y Position";
|
|
||||||
mystring3[9] = player_y_tile.ToString();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File.WriteAllLines(mylocation3, mystring3);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void load_player_info()
|
|
||||||
{
|
|
||||||
string name = StardewValley.Game1.player.name;
|
|
||||||
Mod_Core.player_path = Path.Combine(Mod_Core.mod_path, "Save_Data", name);
|
|
||||||
if (!Directory.Exists(Mod_Core.player_path))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(Mod_Core.player_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string mylocation = Path.Combine(Mod_Core.player_path, "Player_Save_Info_");
|
|
||||||
string mylocation2 = mylocation + name;
|
|
||||||
string mylocation3 = mylocation2 + ".txt";
|
|
||||||
string[] mystring3 = new string[20];
|
|
||||||
|
|
||||||
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
|
||||||
{
|
|
||||||
// Console.WriteLine("Can't load custom save info since the file doesn't exist.");
|
|
||||||
Player_Utilities.has_player_warped_yet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Console.WriteLine("HEY THERE IM LOADING DATA");
|
|
||||||
|
|
||||||
string[] readtext = File.ReadAllLines(mylocation3);
|
|
||||||
player_game_time = Convert.ToInt32(readtext[3]);
|
|
||||||
players_current_map_name = Convert.ToString(readtext[5]);
|
|
||||||
player_x_tile = Convert.ToInt32(readtext[7]);
|
|
||||||
player_y_tile = Convert.ToInt32(readtext[9]);
|
|
||||||
Game1.timeOfDay = player_game_time;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void warp_player()
|
|
||||||
{
|
|
||||||
GameLocation new_location = Game1.getLocationFromName(players_current_map_name);
|
|
||||||
Game1.player.previousLocationName = Game1.player.currentLocation.name;
|
|
||||||
Game1.locationAfterWarp = new_location;
|
|
||||||
Game1.xLocationAfterWarp = player_x_tile;
|
|
||||||
Game1.yLocationAfterWarp = player_y_tile;
|
|
||||||
Game1.facingDirectionAfterWarp = player_facing_direction;
|
|
||||||
Game1.fadeScreenToBlack();
|
|
||||||
|
|
||||||
Game1.warpFarmer(players_current_map_name, player_x_tile, player_y_tile, false);
|
|
||||||
Mod_Core.thisMonitor.Log("WARP THE PLAYER");
|
|
||||||
Game1.player.faceDirection(player_facing_direction);
|
|
||||||
|
|
||||||
if (Directory.Exists(Mod_Core.player_path))
|
|
||||||
{
|
|
||||||
// Directory.Delete(player_path, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,15 +34,10 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Animal_Utilities.cs" />
|
<Compile Include="SaveUtilities.cs" />
|
||||||
<Compile Include="Config_Utilities.cs" />
|
<Compile Include="Config_Utilities.cs" />
|
||||||
<Compile Include="Horse_Utility.cs" />
|
|
||||||
<Compile Include="Mod_Core.cs" />
|
<Compile Include="Mod_Core.cs" />
|
||||||
<Compile Include="GameUtilities.cs" />
|
|
||||||
<Compile Include="New_Shipping_Menu.cs" />
|
<Compile Include="New_Shipping_Menu.cs" />
|
||||||
<Compile Include="NPC_Utilities.cs" />
|
|
||||||
<Compile Include="Pet_Utilities.cs" />
|
|
||||||
<Compile Include="Player_Utilities.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -0,0 +1,694 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using StardewModdingAPI;
|
||||||
|
using StardewValley;
|
||||||
|
using StardewValley.Characters;
|
||||||
|
using StardewValley.Menus;
|
||||||
|
|
||||||
|
namespace Omegasis.SaveAnywhere
|
||||||
|
{
|
||||||
|
/// <summary>Provides methods for saving and loading game data.</summary>
|
||||||
|
internal class SaveUtilities
|
||||||
|
{
|
||||||
|
public static bool passiveSave;
|
||||||
|
public static bool should_ship;
|
||||||
|
|
||||||
|
public static string npc_name;
|
||||||
|
public static int npc_tile_x;
|
||||||
|
public static int npc_tile_y;
|
||||||
|
public static string npc_current_map_name;
|
||||||
|
public static System.Collections.Generic.List<List<string>> routesFromLocationToLocation = new List<List<string>>();
|
||||||
|
public static Microsoft.Xna.Framework.Point npc_point;
|
||||||
|
|
||||||
|
public static string pet_name;
|
||||||
|
public static StardewValley.Character my_pet;
|
||||||
|
public static string pet_map_name;
|
||||||
|
public static int pet_tile_x;
|
||||||
|
public static int pet_tile_y;
|
||||||
|
public static bool is_pet_outside;
|
||||||
|
public static Microsoft.Xna.Framework.Point pet_point;
|
||||||
|
|
||||||
|
public static int player_x_tile;
|
||||||
|
public static int player_y_tile;
|
||||||
|
public static string players_current_map_name;
|
||||||
|
public static int player_game_time;
|
||||||
|
public static int player_facing_direction;
|
||||||
|
public static bool has_player_warped_yet;
|
||||||
|
|
||||||
|
public static void shipping_check()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Game1.activeClickableMenu != null) return;
|
||||||
|
if (SaveUtilities.should_ship == true)
|
||||||
|
{
|
||||||
|
Game1.activeClickableMenu = new NewShippingMenu(Game1.getFarm().shippingBin);
|
||||||
|
SaveUtilities.should_ship = false;
|
||||||
|
Game1.getFarm().shippingBin.Clear();
|
||||||
|
Game1.getFarm().lastItemShipped = null;
|
||||||
|
SaveUtilities.passiveSave = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save_game()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|
||||||
|
if (Game1.player.currentLocation.name == "Sewer")
|
||||||
|
{
|
||||||
|
Log.Error("There is an issue saving in the Sewer. Blame the animals for not being saved to the player's save file.");
|
||||||
|
Log.Error("Your data has not been saved. Sorry for the issue.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//if a player has shipped an item, run this code.
|
||||||
|
if (Enumerable.Count<Item>((IEnumerable<Item>)Game1.getFarm().shippingBin) > 0)
|
||||||
|
{
|
||||||
|
should_ship = true;
|
||||||
|
// Game1.endOfNightMenus.Push((IClickableMenu)new ShippingMenu(Game1.getFarm().shippingBin));
|
||||||
|
// Game1.showEndOfNightStuff(); //shows the nightly shipping menu.
|
||||||
|
// Game1.getFarm().shippingBin.Clear(); //clears out the shipping bin to prevent exploits
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
shipping_check();
|
||||||
|
// Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu();
|
||||||
|
}
|
||||||
|
catch (Exception rrr)
|
||||||
|
{
|
||||||
|
Game1.showRedMessage("Can't save here. See log for error.");
|
||||||
|
SaveAnywhere.thisMonitor.Log(rrr.ToString(), LogLevel.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); //This command is what allows the player to save anywhere as it calls the saving function.
|
||||||
|
|
||||||
|
SaveUtilities.save_player_info();
|
||||||
|
SaveUtilities.save_animal_info();
|
||||||
|
SaveUtilities.Save_NPC_Info();
|
||||||
|
|
||||||
|
//grab the player's info
|
||||||
|
// player_map_name = StardewValley.Game1.player.currentLocation.name;
|
||||||
|
// player_tile_x = StardewValley.Game1.player.getTileX();
|
||||||
|
// player_tile_Y = StardewValley.Game1.player.getTileY();
|
||||||
|
// player_flop = false;
|
||||||
|
|
||||||
|
// MyWritter_Player(); //write my info to a text file
|
||||||
|
|
||||||
|
|
||||||
|
// MyWritter_Horse();
|
||||||
|
|
||||||
|
// DataLoader_Settings(); //load settings. Prevents acidental overwrite.
|
||||||
|
// MyWritter_Settings(); //save settings.
|
||||||
|
|
||||||
|
//Game1.warpFarmer(player_map_name, player_tile_x, player_tile_Y, player_flop); //refresh the player's location just incase. That will prove that they character's info was valid.
|
||||||
|
|
||||||
|
//so this is essentially the basics of the code...
|
||||||
|
// Log.Error("IS THIS BREAKING?");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Save_Horse_Info()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
Horse horse = Utility.findHorse();
|
||||||
|
|
||||||
|
|
||||||
|
if (horse == null)
|
||||||
|
{
|
||||||
|
//Game1.getFarm().characters.Add((NPC)new Horse(this.player_tile_x + 1, this.player_tile_Y + 1));
|
||||||
|
SaveAnywhere.thisMonitor.Log("NEIGH: No horse exists", LogLevel.Debug);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// else
|
||||||
|
// Game1.warpCharacter((NPC)horse, Game1.player.currentLocation.name, StardewValley.Game1.player.getTileLocationPoint(), false, true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string myname = StardewValley.Game1.player.name;
|
||||||
|
|
||||||
|
string mylocation = Path.Combine(SaveAnywhere.animal_path, "Horse_Save_Info_");
|
||||||
|
string mylocation2 = mylocation + myname;
|
||||||
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
string[] mystring3 = new string[20];
|
||||||
|
if (!File.Exists(mylocation3))
|
||||||
|
{
|
||||||
|
|
||||||
|
SaveAnywhere.thisMonitor.Log("The horse save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Debug);
|
||||||
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||||
|
|
||||||
|
mystring3[0] = "Horse: Save_Anywhere Info. Editing this might break some things.";
|
||||||
|
mystring3[1] = "====================================================================================";
|
||||||
|
|
||||||
|
mystring3[2] = "Horse Current Map Name";
|
||||||
|
mystring3[3] = horse.currentLocation.name.ToString();
|
||||||
|
|
||||||
|
mystring3[4] = "Horse X Position";
|
||||||
|
mystring3[5] = horse.getTileX().ToString();
|
||||||
|
|
||||||
|
mystring3[6] = "Horse Y Position";
|
||||||
|
mystring3[7] = horse.getTileY().ToString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File.WriteAllLines(mylocation3, mystring3);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
||||||
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||||
|
|
||||||
|
mystring3[0] = "Horse: Save_Anywhere Info. Editing this might break some things.";
|
||||||
|
mystring3[1] = "====================================================================================";
|
||||||
|
|
||||||
|
mystring3[2] = "Horse Current Map Name";
|
||||||
|
mystring3[3] = horse.currentLocation.name.ToString();
|
||||||
|
|
||||||
|
mystring3[4] = "Horse X Position";
|
||||||
|
mystring3[5] = horse.getTileX().ToString();
|
||||||
|
|
||||||
|
mystring3[6] = "Horse Y Position";
|
||||||
|
mystring3[7] = horse.getTileY().ToString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File.WriteAllLines(mylocation3, mystring3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Load_Horse_Info()
|
||||||
|
{
|
||||||
|
Horse horse = Utility.findHorse();
|
||||||
|
if (horse == null)
|
||||||
|
{
|
||||||
|
SaveAnywhere.thisMonitor.Log("NEIGH: No horse exists", LogLevel.Debug);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// DataLoader_Settings();
|
||||||
|
//loads the data to the variables upon loading the game.
|
||||||
|
string myname = StardewValley.Game1.player.name;
|
||||||
|
string mylocation = Path.Combine(SaveAnywhere.animal_path, "Horse_Save_Info_");
|
||||||
|
string mylocation2 = mylocation + myname;
|
||||||
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string horse_map_name = "";
|
||||||
|
int horse_x;
|
||||||
|
int horse_y;
|
||||||
|
Point horse_point;
|
||||||
|
string[] readtext = File.ReadAllLines(mylocation3);
|
||||||
|
horse_map_name = Convert.ToString(readtext[3]);
|
||||||
|
horse_x = Convert.ToInt32(readtext[5]);
|
||||||
|
horse_y = Convert.ToInt32(readtext[7]);
|
||||||
|
horse_point.X = horse_x;
|
||||||
|
horse_point.Y = horse_y;
|
||||||
|
Game1.warpCharacter((NPC)horse, horse_map_name, horse_point, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save_animal_info()
|
||||||
|
{
|
||||||
|
SaveAnywhere.animal_path = Path.Combine(SaveAnywhere.player_path, "Animals");
|
||||||
|
if (!Directory.Exists(SaveAnywhere.animal_path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SaveAnywhere.animal_path);
|
||||||
|
|
||||||
|
}
|
||||||
|
SaveUtilities.Save_Horse_Info();
|
||||||
|
SaveUtilities.save_pet_info();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void load_animal_info()
|
||||||
|
{
|
||||||
|
SaveAnywhere.animal_path = Path.Combine(SaveAnywhere.player_path, "Animals");
|
||||||
|
if (!Directory.Exists(SaveAnywhere.animal_path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SaveAnywhere.animal_path);
|
||||||
|
|
||||||
|
}
|
||||||
|
SaveUtilities.Load_Horse_Info();
|
||||||
|
SaveUtilities.Load_pet_Info();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Save_NPC_Info()
|
||||||
|
{
|
||||||
|
SaveAnywhere.npc_path = Path.Combine(SaveAnywhere.player_path, "NPC_Save_Info");
|
||||||
|
if (!Directory.Exists(SaveAnywhere.npc_path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SaveAnywhere.npc_path);
|
||||||
|
}
|
||||||
|
foreach (var location in Game1.locations)
|
||||||
|
{
|
||||||
|
foreach (var npc in location.characters)
|
||||||
|
{
|
||||||
|
if (npc.IsMonster == true) continue;
|
||||||
|
if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue;
|
||||||
|
npc_name = npc.name;
|
||||||
|
npc_current_map_name = location.name;
|
||||||
|
npc_tile_x = npc.getTileX();
|
||||||
|
npc_tile_y = npc.getTileY();
|
||||||
|
string mylocation = Path.Combine(SaveAnywhere.npc_path, npc.name);
|
||||||
|
string mylocation2 = mylocation;
|
||||||
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
string[] mystring3 = new string[20];
|
||||||
|
if (!File.Exists(mylocation3))
|
||||||
|
{
|
||||||
|
SaveAnywhere.thisMonitor.Log("Save Anywhere: The NPC save info for " + npc_name + " doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
||||||
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||||
|
|
||||||
|
mystring3[0] = "NPC: Save_Anywhere Info. Editing this might break some things.";
|
||||||
|
mystring3[1] = "====================================================================================";
|
||||||
|
|
||||||
|
mystring3[2] = "NPC Name";
|
||||||
|
mystring3[3] = npc_name.ToString();
|
||||||
|
|
||||||
|
mystring3[4] = "NPC Current Map Name";
|
||||||
|
mystring3[5] = npc_current_map_name.ToString();
|
||||||
|
|
||||||
|
mystring3[6] = "NPC X Position";
|
||||||
|
mystring3[7] = npc_tile_x.ToString();
|
||||||
|
|
||||||
|
mystring3[8] = "NPC Y Position";
|
||||||
|
mystring3[9] = npc_tile_y.ToString();
|
||||||
|
|
||||||
|
File.WriteAllLines(mylocation3, mystring3);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
||||||
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||||
|
mystring3[0] = "NPC: Save_Anywhere Info. Editing this might break some things.";
|
||||||
|
mystring3[1] = "====================================================================================";
|
||||||
|
|
||||||
|
mystring3[2] = "NPC Current Map Name";
|
||||||
|
mystring3[3] = npc_name.ToString();
|
||||||
|
|
||||||
|
mystring3[4] = "NPC Current Map Name";
|
||||||
|
mystring3[5] = npc_current_map_name.ToString();
|
||||||
|
|
||||||
|
mystring3[6] = "NPC X Position";
|
||||||
|
mystring3[7] = npc_tile_x.ToString();
|
||||||
|
|
||||||
|
mystring3[8] = "NPC Y Position";
|
||||||
|
mystring3[9] = npc_tile_y.ToString();
|
||||||
|
File.WriteAllLines(mylocation3, mystring3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Load_NPC_Info()
|
||||||
|
{
|
||||||
|
List<NPC> npc_list = new List<NPC>();
|
||||||
|
foreach (var location in Game1.locations)
|
||||||
|
{
|
||||||
|
foreach (var npc in location.characters)
|
||||||
|
{
|
||||||
|
if (npc.IsMonster == true) continue;
|
||||||
|
if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue;
|
||||||
|
if (npc is StardewValley.NPC || npc is StardewValley.Characters.Cat || npc is StardewValley.Characters.Dog) npc_list.Add(npc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var npc in npc_list)
|
||||||
|
{
|
||||||
|
if (npc.IsMonster == true) continue;
|
||||||
|
if (npc is StardewValley.Monsters.Bat || npc is StardewValley.Monsters.BigSlime || npc is StardewValley.Monsters.Bug || npc is StardewValley.Monsters.Cat || npc is StardewValley.Monsters.Crow || npc is StardewValley.Monsters.Duggy || npc is StardewValley.Monsters.DustSpirit || npc is StardewValley.Monsters.Fireball || npc is StardewValley.Monsters.Fly || npc is StardewValley.Monsters.Ghost || npc is StardewValley.Monsters.GoblinPeasant || npc is StardewValley.Monsters.GoblinWizard || npc is StardewValley.Monsters.GreenSlime || npc is StardewValley.Monsters.Grub || npc is StardewValley.Monsters.LavaCrab || npc is StardewValley.Monsters.MetalHead || npc is StardewValley.Monsters.Monster || npc is StardewValley.Monsters.Mummy || npc is StardewValley.Monsters.RockCrab || npc is StardewValley.Monsters.RockGolem || npc is StardewValley.Monsters.Serpent || npc is StardewValley.Monsters.ShadowBrute || npc is StardewValley.Monsters.ShadowGirl || npc is StardewValley.Monsters.ShadowGuy || npc is StardewValley.Monsters.ShadowShaman || npc is StardewValley.Monsters.Skeleton || npc is StardewValley.Monsters.SkeletonMage || npc is StardewValley.Monsters.SkeletonWarrior || npc is StardewValley.Monsters.Spiker || npc is StardewValley.Monsters.SquidKid) continue;
|
||||||
|
|
||||||
|
|
||||||
|
SaveAnywhere.npc_path = Path.Combine(SaveAnywhere.player_path, "NPC_Save_Info");
|
||||||
|
if (!Directory.Exists(SaveAnywhere.npc_path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SaveAnywhere.npc_path);
|
||||||
|
}
|
||||||
|
string mylocation = Path.Combine(SaveAnywhere.npc_path, npc.name);
|
||||||
|
string mylocation2 = mylocation;
|
||||||
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
string[] mystring3 = new string[20];
|
||||||
|
if (!File.Exists(mylocation3))
|
||||||
|
{
|
||||||
|
SaveAnywhere.thisMonitor.Log("Missing character file?!?", LogLevel.Error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string[] readtext = File.ReadAllLines(mylocation3);
|
||||||
|
npc_name = Convert.ToString(readtext[3]);
|
||||||
|
npc_current_map_name = Convert.ToString(readtext[5]);
|
||||||
|
npc_tile_x = Convert.ToInt32(readtext[7]);
|
||||||
|
npc_tile_y = Convert.ToInt32(readtext[9]);
|
||||||
|
npc_point = new Microsoft.Xna.Framework.Point();
|
||||||
|
npc_point.X = npc_tile_x;
|
||||||
|
npc_point.Y = npc_tile_y;
|
||||||
|
if (npc_current_map_name == "" || npc_current_map_name == null) continue;
|
||||||
|
//Log.Info("Warped NPC" +npc_name);
|
||||||
|
Game1.warpCharacter((StardewValley.NPC)npc, npc_current_map_name, npc_point, false, true);
|
||||||
|
|
||||||
|
// npc.updateMovement(Game1.getLocationFromName(npc_current_map_name), Game1.currentGameTime);
|
||||||
|
//npc.moveCharacterOnSchedulePath();
|
||||||
|
// npc.dayUpdate(Game1.dayOfMonth);
|
||||||
|
//npc_update(npc, Game1.dayOfMonth);
|
||||||
|
|
||||||
|
// npc.DirectionsToNewLocation = pathfindToNextScheduleLocation(npc, npc.currentLocation.name, npc.getTileX(), npc.getTileY(), npc.currentLocation.name, 52, 99, 3, "", "");
|
||||||
|
// npc.updateMovement(npc.currentLocation,Game1.currentGameTime);
|
||||||
|
//npc.Schedule = npc.getSchedule(Game1.dayOfMonth);
|
||||||
|
//npc.moveCharacterOnSchedulePath();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SaveAnywhere.npc_warp = true;
|
||||||
|
}
|
||||||
|
private static Stack<Point> addToStackForSchedule(Stack<Point> original, Stack<Point> toAdd)
|
||||||
|
{
|
||||||
|
if (toAdd == null)
|
||||||
|
return original;
|
||||||
|
original = new Stack<Point>((IEnumerable<Point>)original);
|
||||||
|
while (original.Count > 0)
|
||||||
|
toAdd.Push(original.Pop());
|
||||||
|
return toAdd;
|
||||||
|
}
|
||||||
|
private static List<string> getLocationRoute(NPC npc, string startingLocation, string endingLocation)
|
||||||
|
{
|
||||||
|
foreach (List<string> list in routesFromLocationToLocation)
|
||||||
|
{
|
||||||
|
if (Enumerable.First<string>((IEnumerable<string>)list).Equals(startingLocation) && Enumerable.Last<string>((IEnumerable<string>)list).Equals(endingLocation) && (npc.gender == 0 || !list.Contains("BathHouse_MensLocker")) && (npc.gender != 0 || !list.Contains("BathHouse_WomensLocker")))
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
return (List<string>)null;
|
||||||
|
}
|
||||||
|
private static SchedulePathDescription pathfindToNextScheduleLocation(NPC npc, string startingLocation, int startingX, int startingY, string endingLocation, int endingX, int endingY, int finalFacingDirection, string endBehavior, string endMessage)
|
||||||
|
{
|
||||||
|
Stack<Point> stack = new Stack<Point>();
|
||||||
|
Point startPoint = new Point(startingX, startingY);
|
||||||
|
List<string> list = startingLocation.Equals(endingLocation) ? (List<string>)null : getLocationRoute(npc, startingLocation, endingLocation);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < Enumerable.Count<string>((IEnumerable<string>)list); ++index)
|
||||||
|
{
|
||||||
|
GameLocation locationFromName = Game1.getLocationFromName(list[index]);
|
||||||
|
if (index < Enumerable.Count<string>((IEnumerable<string>)list) - 1)
|
||||||
|
{
|
||||||
|
Point warpPointTo = locationFromName.getWarpPointTo(list[index + 1]);
|
||||||
|
if (warpPointTo.Equals(Point.Zero) || startPoint.Equals(Point.Zero))
|
||||||
|
throw new Exception("schedule pathing tried to find a warp point that doesn't exist.");
|
||||||
|
stack = addToStackForSchedule(stack, PathFindController.findPathForNPCSchedules(startPoint, warpPointTo, locationFromName, 30000));
|
||||||
|
startPoint = locationFromName.getWarpPointTarget(warpPointTo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
stack = addToStackForSchedule(stack, PathFindController.findPathForNPCSchedules(startPoint, new Point(endingX, endingY), locationFromName, 30000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (startingLocation.Equals(endingLocation))
|
||||||
|
stack = PathFindController.findPathForNPCSchedules(startPoint, new Point(endingX, endingY), Game1.getLocationFromName(startingLocation), 30000);
|
||||||
|
return new SchedulePathDescription(stack, finalFacingDirection, endBehavior, endMessage);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save_pet_info()
|
||||||
|
{
|
||||||
|
if (Game1.player.hasPet() == false) return;
|
||||||
|
pet_name = Game1.player.getPetName();
|
||||||
|
foreach (var location in Game1.locations)
|
||||||
|
{
|
||||||
|
foreach (var npc in location.characters)
|
||||||
|
{
|
||||||
|
if (npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Cat)
|
||||||
|
{
|
||||||
|
pet_map_name = location.name;
|
||||||
|
pet_tile_x = npc.getTileX();
|
||||||
|
pet_tile_y = npc.getTileY();
|
||||||
|
is_pet_outside = location.isOutdoors;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
string myname = StardewValley.Game1.player.name;
|
||||||
|
string mylocation = Path.Combine(SaveAnywhere.animal_path, "Pet_Save_Info_");
|
||||||
|
string mylocation2 = mylocation + myname;
|
||||||
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
string[] mystring3 = new string[20];
|
||||||
|
if (!File.Exists(mylocation3))
|
||||||
|
{
|
||||||
|
|
||||||
|
SaveAnywhere.thisMonitor.Log("Save Anywhere: The pet save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Debug);
|
||||||
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||||
|
|
||||||
|
mystring3[0] = "Pet: Save_Anywhere Info. Editing this might break some things.";
|
||||||
|
mystring3[1] = "====================================================================================";
|
||||||
|
|
||||||
|
mystring3[2] = "Pet Current Map Name";
|
||||||
|
mystring3[3] = pet_map_name.ToString();
|
||||||
|
|
||||||
|
mystring3[4] = "Pet X Position";
|
||||||
|
mystring3[5] = pet_tile_x.ToString();
|
||||||
|
|
||||||
|
mystring3[6] = "Pet Y Position";
|
||||||
|
mystring3[7] = pet_tile_y.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File.WriteAllLines(mylocation3, mystring3);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
||||||
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||||
|
mystring3[0] = "Pet: Save_Anywhere Info. Editing this might break some things.";
|
||||||
|
mystring3[1] = "====================================================================================";
|
||||||
|
|
||||||
|
mystring3[2] = "Pet Current Map Name";
|
||||||
|
mystring3[3] = pet_map_name.ToString();
|
||||||
|
|
||||||
|
mystring3[4] = "Pet X Position";
|
||||||
|
mystring3[5] = pet_tile_x.ToString();
|
||||||
|
|
||||||
|
mystring3[6] = "Pet Y Position";
|
||||||
|
mystring3[7] = pet_tile_y.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File.WriteAllLines(mylocation3, mystring3);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Load_pet_Info()
|
||||||
|
{
|
||||||
|
if (Game1.player.hasPet() == false) return;
|
||||||
|
// DataLoader_Settings();
|
||||||
|
//loads the data to the variables upon loading the game.
|
||||||
|
string myname = StardewValley.Game1.player.name;
|
||||||
|
string mylocation = Path.Combine(SaveAnywhere.animal_path, "Pet_Save_Info_");
|
||||||
|
string mylocation2 = mylocation + myname;
|
||||||
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string[] readtext = File.ReadAllLines(mylocation3);
|
||||||
|
pet_map_name = Convert.ToString(readtext[3]);
|
||||||
|
pet_tile_x = Convert.ToInt32(readtext[5]);
|
||||||
|
pet_tile_y = Convert.ToInt32(readtext[7]);
|
||||||
|
get_pet();
|
||||||
|
pet_point = new Microsoft.Xna.Framework.Point();
|
||||||
|
pet_point.X = pet_tile_x;
|
||||||
|
pet_point.Y = pet_tile_y;
|
||||||
|
Game1.warpCharacter((StardewValley.NPC)my_pet, pet_map_name, pet_point, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void get_pet()
|
||||||
|
{
|
||||||
|
if (Game1.player.hasPet() == false) return;
|
||||||
|
foreach (var location in Game1.locations)
|
||||||
|
{
|
||||||
|
foreach (var npc in location.characters)
|
||||||
|
{
|
||||||
|
if (npc is StardewValley.Characters.Dog || npc is StardewValley.Characters.Cat)
|
||||||
|
{
|
||||||
|
pet_map_name = location.name;
|
||||||
|
pet_tile_x = npc.getTileX();
|
||||||
|
pet_tile_y = npc.getTileY();
|
||||||
|
is_pet_outside = location.isOutdoors;
|
||||||
|
my_pet = npc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void get_player_info()
|
||||||
|
{
|
||||||
|
get_x();
|
||||||
|
get_y();
|
||||||
|
get_current_map_name();
|
||||||
|
get_facing_direction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void get_x()
|
||||||
|
{
|
||||||
|
player_x_tile = Game1.player.getTileX();
|
||||||
|
}
|
||||||
|
public static void get_y()
|
||||||
|
{
|
||||||
|
player_y_tile = Game1.player.getTileY();
|
||||||
|
}
|
||||||
|
public static void get_current_map_name()
|
||||||
|
{
|
||||||
|
players_current_map_name = Game1.player.currentLocation.name;
|
||||||
|
}
|
||||||
|
public static void get_facing_direction()
|
||||||
|
{
|
||||||
|
player_facing_direction = Game1.player.facingDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save_player_info()
|
||||||
|
{
|
||||||
|
get_player_info();
|
||||||
|
string name = StardewValley.Game1.player.name;
|
||||||
|
SaveAnywhere.player_path = Path.Combine(SaveAnywhere.mod_path, "Save_Data", name);
|
||||||
|
if (!Directory.Exists(SaveAnywhere.player_path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SaveAnywhere.player_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string mylocation = Path.Combine(SaveAnywhere.player_path, "Player_Save_Info_");
|
||||||
|
string mylocation2 = mylocation + name;
|
||||||
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
string[] mystring3 = new string[20];
|
||||||
|
if (!File.Exists(mylocation3))
|
||||||
|
{
|
||||||
|
SaveAnywhere.thisMonitor.Log("Save Anywhere: The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.", LogLevel.Info);
|
||||||
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||||
|
|
||||||
|
mystring3[0] = "Player: Save_Anywhere Info. Editing this might break some things.";
|
||||||
|
mystring3[1] = "====================================================================================";
|
||||||
|
|
||||||
|
mystring3[2] = "Player Current Game Time";
|
||||||
|
mystring3[3] = Game1.timeOfDay.ToString();
|
||||||
|
|
||||||
|
mystring3[4] = "Player Current Map Name";
|
||||||
|
mystring3[5] = players_current_map_name.ToString();
|
||||||
|
|
||||||
|
mystring3[6] = "Player X Position";
|
||||||
|
mystring3[7] = player_x_tile.ToString();
|
||||||
|
|
||||||
|
mystring3[8] = "Player Y Position";
|
||||||
|
mystring3[9] = player_y_tile.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File.WriteAllLines(mylocation3, mystring3);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||||
|
|
||||||
|
mystring3[0] = "Player: Save_Anywhere Info. Editing this might break some things.";
|
||||||
|
mystring3[1] = "====================================================================================";
|
||||||
|
|
||||||
|
mystring3[2] = "Player Current Game Time";
|
||||||
|
mystring3[3] = Game1.timeOfDay.ToString();
|
||||||
|
|
||||||
|
mystring3[4] = "Player Current Map Name";
|
||||||
|
mystring3[5] = players_current_map_name.ToString();
|
||||||
|
|
||||||
|
mystring3[6] = "Player X Position";
|
||||||
|
mystring3[7] = player_x_tile.ToString();
|
||||||
|
|
||||||
|
mystring3[8] = "Player Y Position";
|
||||||
|
mystring3[9] = player_y_tile.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File.WriteAllLines(mylocation3, mystring3);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void load_player_info()
|
||||||
|
{
|
||||||
|
string name = StardewValley.Game1.player.name;
|
||||||
|
SaveAnywhere.player_path = Path.Combine(SaveAnywhere.mod_path, "Save_Data", name);
|
||||||
|
if (!Directory.Exists(SaveAnywhere.player_path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SaveAnywhere.player_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string mylocation = Path.Combine(SaveAnywhere.player_path, "Player_Save_Info_");
|
||||||
|
string mylocation2 = mylocation + name;
|
||||||
|
string mylocation3 = mylocation2 + ".txt";
|
||||||
|
string[] mystring3 = new string[20];
|
||||||
|
|
||||||
|
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
||||||
|
{
|
||||||
|
// Console.WriteLine("Can't load custom save info since the file doesn't exist.");
|
||||||
|
SaveUtilities.has_player_warped_yet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Console.WriteLine("HEY THERE IM LOADING DATA");
|
||||||
|
|
||||||
|
string[] readtext = File.ReadAllLines(mylocation3);
|
||||||
|
player_game_time = Convert.ToInt32(readtext[3]);
|
||||||
|
players_current_map_name = Convert.ToString(readtext[5]);
|
||||||
|
player_x_tile = Convert.ToInt32(readtext[7]);
|
||||||
|
player_y_tile = Convert.ToInt32(readtext[9]);
|
||||||
|
Game1.timeOfDay = player_game_time;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warp_player()
|
||||||
|
{
|
||||||
|
GameLocation new_location = Game1.getLocationFromName(players_current_map_name);
|
||||||
|
Game1.player.previousLocationName = Game1.player.currentLocation.name;
|
||||||
|
Game1.locationAfterWarp = new_location;
|
||||||
|
Game1.xLocationAfterWarp = player_x_tile;
|
||||||
|
Game1.yLocationAfterWarp = player_y_tile;
|
||||||
|
Game1.facingDirectionAfterWarp = player_facing_direction;
|
||||||
|
Game1.fadeScreenToBlack();
|
||||||
|
|
||||||
|
Game1.warpFarmer(players_current_map_name, player_x_tile, player_y_tile, false);
|
||||||
|
SaveAnywhere.thisMonitor.Log("WARP THE PLAYER");
|
||||||
|
Game1.player.faceDirection(player_facing_direction);
|
||||||
|
|
||||||
|
if (Directory.Exists(SaveAnywhere.player_path))
|
||||||
|
{
|
||||||
|
// Directory.Delete(player_path, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue