2017-07-28 08:28:39 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
2017-02-23 07:41:55 +08:00
|
|
|
|
using StardewModdingAPI;
|
|
|
|
|
using StardewValley;
|
|
|
|
|
using StardewValley.Characters;
|
|
|
|
|
|
2017-07-28 08:28:39 +08:00
|
|
|
|
namespace Omegasis.SaveAnywhere
|
2017-02-23 07:41:55 +08:00
|
|
|
|
{
|
|
|
|
|
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));
|
2017-05-14 06:27:24 +08:00
|
|
|
|
Mod_Core.thisMonitor.Log("NEIGH: No horse exists", LogLevel.Debug);
|
2017-02-23 07:41:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// else
|
|
|
|
|
// Game1.warpCharacter((NPC)horse, Game1.player.currentLocation.name, StardewValley.Game1.player.getTileLocationPoint(), false, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string myname = StardewValley.Game1.player.name;
|
|
|
|
|
|
2017-07-28 08:28:39 +08:00
|
|
|
|
string mylocation = Path.Combine(Mod_Core.animal_path, "Horse_Save_Info_");
|
2017-02-23 07:41:55 +08:00
|
|
|
|
string mylocation2 = mylocation + myname;
|
|
|
|
|
string mylocation3 = mylocation2 + ".txt";
|
|
|
|
|
string[] mystring3 = new string[20];
|
|
|
|
|
if (!File.Exists(mylocation3))
|
|
|
|
|
{
|
|
|
|
|
|
2017-05-14 06:27:24 +08:00
|
|
|
|
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);
|
2017-02-23 07:41:55 +08:00
|
|
|
|
//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)
|
|
|
|
|
{
|
2017-05-14 06:27:24 +08:00
|
|
|
|
Mod_Core.thisMonitor.Log("NEIGH: No horse exists", LogLevel.Debug);
|
2017-02-23 07:41:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// DataLoader_Settings();
|
|
|
|
|
//loads the data to the variables upon loading the game.
|
|
|
|
|
string myname = StardewValley.Game1.player.name;
|
2017-07-28 08:28:39 +08:00
|
|
|
|
string mylocation = Path.Combine(Mod_Core.animal_path, "Horse_Save_Info_");
|
2017-02-23 07:41:55 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|