2016-12-09 08:34:28 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2017-07-28 08:28:39 +08:00
|
|
|
|
using StardewModdingAPI;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-28 08:28:39 +08:00
|
|
|
|
namespace Omegasis.AutoSpeed
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public class AutoSpeed : Mod
|
|
|
|
|
{
|
|
|
|
|
int speed_int = 5;
|
|
|
|
|
public override void Entry(IModHelper helper)
|
|
|
|
|
{
|
|
|
|
|
//StardewModdingAPI.Events.GameEvents.UpdateTick += Events_UpdateTick;
|
|
|
|
|
StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
|
|
|
|
|
var configLocation = Path.Combine(helper.DirectoryPath, "AutoSpeed_Data.txt");
|
|
|
|
|
if (!File.Exists(configLocation))
|
|
|
|
|
{
|
|
|
|
|
speed_int = 1;
|
|
|
|
|
}
|
|
|
|
|
DataLoader();
|
|
|
|
|
// MyWritter();
|
|
|
|
|
Monitor.Log("AutoSpeed Initialization Completed",LogLevel.Info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
StardewValley.Game1.player.addedSpeed = speed_int;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataLoader()
|
|
|
|
|
{
|
|
|
|
|
//loads the data to the variables upon loading the game.
|
|
|
|
|
var mylocation = Path.Combine(Helper.DirectoryPath, "AutoSpeed_data.txt");
|
|
|
|
|
if (!File.Exists(mylocation)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
|
|
|
|
{
|
|
|
|
|
Monitor.Log("The config file for AutoSpeed was not found, guess I'll create it...",LogLevel.Warn);
|
2017-02-22 15:29:00 +08:00
|
|
|
|
MyWritter();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] readtext = File.ReadAllLines(mylocation);
|
|
|
|
|
speed_int = Convert.ToInt32(readtext[3]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyWritter()
|
|
|
|
|
{
|
|
|
|
|
//saves the BuildEndurance_data at the end of a new day;
|
|
|
|
|
var mylocation = Path.Combine(Helper.DirectoryPath, "AutoSpeed_data.txt");
|
|
|
|
|
string[] mystring3 = new string[20];
|
|
|
|
|
if (!File.Exists(mylocation))
|
|
|
|
|
{
|
|
|
|
|
Monitor.Log("The data file for AutoSpeed was not found, guess I'll create it when you sleep.",LogLevel.Info);
|
|
|
|
|
|
|
|
|
|
mystring3[0] = "Player: AutoSpeed Config:";
|
|
|
|
|
mystring3[1] = "====================================================================================";
|
|
|
|
|
mystring3[2] = "Player Added Speed:";
|
|
|
|
|
mystring3[3] = speed_int.ToString();
|
|
|
|
|
File.WriteAllLines(mylocation, mystring3);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mystring3[0] = "Player: AutoSpeed Config:";
|
|
|
|
|
mystring3[1] = "====================================================================================";
|
|
|
|
|
|
|
|
|
|
mystring3[2] = "Player Added Speed:";
|
|
|
|
|
mystring3[3] = speed_int.ToString();
|
|
|
|
|
|
|
|
|
|
File.WriteAllLines(mylocation, mystring3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} //end my function
|
2016-03-27 16:14:43 +08:00
|
|
|
|
}
|