2018-12-30 18:00:05 +08:00
|
|
|
using System;
|
2016-11-04 02:25:53 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2017-07-31 11:07:07 +08:00
|
|
|
using Omegasis.SaveAnywhere.Framework;
|
2016-11-04 02:25:53 +08:00
|
|
|
using StardewModdingAPI;
|
|
|
|
using StardewModdingAPI.Events;
|
2017-07-28 08:28:39 +08:00
|
|
|
using StardewValley;
|
2016-11-04 02:25:53 +08:00
|
|
|
using StardewValley.Characters;
|
2018-06-09 02:40:23 +08:00
|
|
|
using StardewValley.Monsters;
|
2016-11-04 02:25:53 +08:00
|
|
|
|
2017-07-28 08:28:39 +08:00
|
|
|
namespace Omegasis.SaveAnywhere
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <summary>The mod entry point.</summary>
|
2017-07-31 05:42:15 +08:00
|
|
|
public class SaveAnywhere : Mod
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
/*********
|
2019-01-06 15:23:07 +08:00
|
|
|
** Fields
|
2017-07-31 10:55:58 +08:00
|
|
|
*********/
|
2017-08-06 11:20:48 +08:00
|
|
|
/// <summary>The mod configuration.</summary>
|
|
|
|
private ModConfig Config;
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <summary>Provides methods for saving and loading game data.</summary>
|
2017-07-31 05:57:00 +08:00
|
|
|
private SaveManager SaveManager;
|
2017-07-31 10:55:58 +08:00
|
|
|
|
2017-08-06 11:00:37 +08:00
|
|
|
/// <summary>The parsed schedules by NPC name.</summary>
|
|
|
|
private readonly IDictionary<string, string> NpcSchedules = new Dictionary<string, string>();
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <summary>Whether villager schedules should be reset now.</summary>
|
|
|
|
private bool ShouldResetSchedules;
|
|
|
|
|
2017-08-06 11:17:51 +08:00
|
|
|
/// <summary>Whether we're performing a non-vanilla save (i.e. not by sleeping in bed).</summary>
|
|
|
|
private bool IsCustomSaving;
|
2017-05-14 06:27:24 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Used to access the Mod's helper from other files associated with the mod.</summary>
|
2018-01-11 05:14:19 +08:00
|
|
|
public static IModHelper ModHelper;
|
2018-12-30 18:00:05 +08:00
|
|
|
|
|
|
|
/// <summary>Used to access the Mod's monitor to allow for debug logging in other files associated with the mod.</summary>
|
2018-01-11 05:14:19 +08:00
|
|
|
public static IMonitor ModMonitor;
|
|
|
|
|
2018-06-09 02:40:23 +08:00
|
|
|
private List<Monster> monsters;
|
|
|
|
|
|
|
|
private bool customMenuOpen;
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
/*********
|
|
|
|
** Public methods
|
|
|
|
*********/
|
|
|
|
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
|
|
|
|
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
2016-12-09 08:34:28 +08:00
|
|
|
public override void Entry(IModHelper helper)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-08-06 11:20:48 +08:00
|
|
|
this.Config = helper.ReadConfig<ModConfig>();
|
2017-07-31 05:57:00 +08:00
|
|
|
|
2018-06-23 15:31:40 +08:00
|
|
|
this.SaveManager = new SaveManager(this.Helper, this.Helper.Reflection, onLoaded: () => this.ShouldResetSchedules = true);
|
|
|
|
|
2019-01-06 15:21:06 +08:00
|
|
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
|
|
|
helper.Events.GameLoop.Saved += this.OnSaved;
|
|
|
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
|
|
|
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
|
|
|
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
2018-06-09 02:40:23 +08:00
|
|
|
|
2018-01-11 05:14:19 +08:00
|
|
|
ModHelper = helper;
|
2018-12-30 18:00:05 +08:00
|
|
|
ModMonitor = this.Monitor;
|
|
|
|
this.customMenuOpen = false;
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2017-05-14 06:27:24 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
/*********
|
|
|
|
** Private methods
|
|
|
|
*********/
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
2017-07-31 09:58:48 +08:00
|
|
|
/// <param name="sender">The event sender.</param>
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <param name="e">The event arguments.</param>
|
|
|
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
2017-05-14 06:27:24 +08:00
|
|
|
{
|
2017-08-06 11:00:37 +08:00
|
|
|
// reset state
|
2017-08-06 11:17:51 +08:00
|
|
|
this.IsCustomSaving = false;
|
2017-08-06 11:00:37 +08:00
|
|
|
this.ShouldResetSchedules = false;
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// load positions
|
2017-08-06 11:19:38 +08:00
|
|
|
this.SaveManager.LoadData();
|
2017-05-14 06:27:24 +08:00
|
|
|
}
|
|
|
|
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary>
|
2017-08-06 11:17:51 +08:00
|
|
|
/// <param name="sender">The event sender.</param>
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <param name="e">The event arguments.</param>
|
|
|
|
private void OnSaved(object sender, SavedEventArgs e)
|
2017-08-06 11:17:51 +08:00
|
|
|
{
|
|
|
|
// clear custom data after a normal save (to avoid restoring old state)
|
2018-12-30 18:00:05 +08:00
|
|
|
if (!this.IsCustomSaving)
|
2017-08-06 11:17:51 +08:00
|
|
|
this.SaveManager.ClearData();
|
2018-12-10 17:33:10 +08:00
|
|
|
else
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
this.IsCustomSaving = false;
|
2018-12-10 17:33:10 +08:00
|
|
|
}
|
2017-08-06 11:17:51 +08:00
|
|
|
}
|
|
|
|
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <param name="sender">The event sender.</param>
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <param name="e">The event arguments.</param>
|
|
|
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
// let save manager run background logic
|
|
|
|
if (Context.IsWorldReady)
|
2018-05-19 05:24:59 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
if (!Game1.player.IsMainPlayer) return;
|
2017-07-31 10:55:58 +08:00
|
|
|
this.SaveManager.Update();
|
2018-05-19 05:24:59 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
|
|
|
|
// reset NPC schedules
|
|
|
|
if (Context.IsWorldReady && this.ShouldResetSchedules)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
this.ShouldResetSchedules = false;
|
|
|
|
this.ApplySchedules();
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2018-06-09 02:40:23 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
if (Game1.activeClickableMenu == null && !this.customMenuOpen) return;
|
|
|
|
if (Game1.activeClickableMenu == null && this.customMenuOpen)
|
2018-06-09 02:40:23 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
this.restoreMonsters();
|
2018-06-09 02:40:23 +08:00
|
|
|
this.customMenuOpen = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Game1.activeClickableMenu != null)
|
|
|
|
{
|
|
|
|
if (Game1.activeClickableMenu.GetType() == typeof(NewSaveGameMenu))
|
|
|
|
{
|
|
|
|
this.customMenuOpen = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Saves all monsters from the game world.</summary>
|
2018-06-09 02:40:23 +08:00
|
|
|
private void cleanMonsters()
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
this.monsters = new List<Monster>();
|
2018-06-09 02:40:23 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
foreach (var npc in Game1.player.currentLocation.characters)
|
2018-06-09 02:40:23 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
if (npc is Monster monster)
|
|
|
|
this.monsters.Add(monster);
|
2018-06-09 02:40:23 +08:00
|
|
|
}
|
2018-12-30 18:00:05 +08:00
|
|
|
catch { }
|
2018-06-09 02:40:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var monster in this.monsters)
|
|
|
|
Game1.player.currentLocation.characters.Remove(monster);
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Adds all saved monster back into the game world.</summary>
|
2018-06-09 02:40:23 +08:00
|
|
|
private void restoreMonsters()
|
|
|
|
{
|
|
|
|
foreach (var monster in this.monsters)
|
|
|
|
Game1.player.currentLocation.characters.Add(monster);
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <param name="sender">The event sender.</param>
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <param name="e">The event arguments.</param>
|
|
|
|
private void OnDayStarted(object sender, DayStartedEventArgs e)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
// reload NPC schedules
|
|
|
|
this.ShouldResetSchedules = true;
|
2016-11-04 02:25:53 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// update NPC schedules
|
|
|
|
this.NpcSchedules.Clear();
|
|
|
|
foreach (NPC npc in Utility.getAllCharacters())
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
if (!this.NpcSchedules.ContainsKey(npc.Name))
|
|
|
|
this.NpcSchedules.Add(npc.Name, this.ParseSchedule(npc));
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <param name="sender">The event sender.</param>
|
2019-01-06 15:21:06 +08:00
|
|
|
/// <param name="e">The event arguments.</param>
|
|
|
|
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-08-06 03:23:10 +08:00
|
|
|
if (!Context.IsPlayerFree)
|
2016-12-09 08:34:28 +08:00
|
|
|
return;
|
2016-11-04 02:25:53 +08:00
|
|
|
|
2017-08-06 11:22:15 +08:00
|
|
|
// initiate save (if valid context)
|
2019-01-06 15:21:06 +08:00
|
|
|
if (e.Button == this.Config.SaveKey)
|
2017-08-06 11:22:15 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
if (Game1.client == null)
|
2017-08-06 11:22:15 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
this.cleanMonsters();
|
2018-05-19 05:24:59 +08:00
|
|
|
// validate: community center Junimos can't be saved
|
|
|
|
|
|
|
|
if (Game1.player.currentLocation.getCharacters().OfType<Junimo>().Any())
|
|
|
|
{
|
|
|
|
Game1.addHUDMessage(new HUDMessage("The spirits don't want you to save here.", HUDMessage.error_type));
|
|
|
|
return;
|
|
|
|
}
|
2017-08-06 11:22:15 +08:00
|
|
|
|
2018-05-19 05:24:59 +08:00
|
|
|
// save
|
2018-12-10 17:33:10 +08:00
|
|
|
this.IsCustomSaving = true;
|
2018-05-19 05:24:59 +08:00
|
|
|
this.SaveManager.BeginSaveData();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
Game1.addHUDMessage(new HUDMessage("Only server hosts can save anywhere.", HUDMessage.error_type));
|
2018-05-19 05:24:59 +08:00
|
|
|
}
|
2017-08-06 11:22:15 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
}
|
2017-07-31 05:42:15 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <summary>Apply the NPC schedules to each NPC.</summary>
|
|
|
|
private void ApplySchedules()
|
|
|
|
{
|
|
|
|
if (Game1.weatherIcon == Game1.weather_festival || Game1.isFestival() || Game1.eventUp)
|
|
|
|
return;
|
2016-11-04 02:25:53 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// apply for each NPC
|
|
|
|
foreach (NPC npc in Utility.getAllCharacters())
|
|
|
|
{
|
|
|
|
if (npc.DirectionsToNewLocation != null || npc.isMoving() || npc.Schedule == null || npc.controller != null || npc is Horse)
|
|
|
|
continue;
|
2016-11-04 02:25:53 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// get raw schedule from XNBs
|
2018-05-01 09:21:31 +08:00
|
|
|
IDictionary<string, string> rawSchedule = this.GetRawSchedule(npc.Name);
|
2017-07-31 10:55:58 +08:00
|
|
|
if (rawSchedule == null)
|
|
|
|
continue;
|
2016-11-04 02:25:53 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// get schedule data
|
2018-12-30 18:00:05 +08:00
|
|
|
if (!this.NpcSchedules.TryGetValue(npc.Name, out string scheduleData) || string.IsNullOrEmpty(scheduleData))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2018-06-09 02:40:23 +08:00
|
|
|
//this.Monitor.Log("THIS IS AWKWARD");
|
2017-07-31 10:55:58 +08:00
|
|
|
continue;
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// get schedule script
|
2018-12-30 18:00:05 +08:00
|
|
|
if (!rawSchedule.TryGetValue(scheduleData, out string script))
|
2017-07-31 10:55:58 +08:00
|
|
|
continue;
|
2016-11-04 02:25:53 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// parse entries
|
|
|
|
string[] entries = script.Split('/');
|
|
|
|
int index = 0;
|
|
|
|
foreach (string _ in entries)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
string[] fields = entries[index].Split(' ');
|
|
|
|
|
|
|
|
// handle GOTO command
|
|
|
|
if (fields.Contains("GOTO"))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
for (int i = 0; i < fields.Length; i++)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
string s = fields[i];
|
|
|
|
if (s == "GOTO")
|
|
|
|
{
|
|
|
|
rawSchedule.TryGetValue(fields[i + 1], out script);
|
|
|
|
string[] newEntries = script.Split('/');
|
|
|
|
fields = newEntries[0].Split(' ');
|
|
|
|
}
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// parse schedule script
|
2016-11-04 02:25:53 +08:00
|
|
|
SchedulePathDescription schedulePathDescription;
|
|
|
|
try
|
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
if (Convert.ToInt32(fields[0]) > Game1.timeOfDay) break;
|
|
|
|
string endMap = Convert.ToString(fields[1]);
|
|
|
|
int x = Convert.ToInt32(fields[2]);
|
|
|
|
int y = Convert.ToInt32(fields[3]);
|
|
|
|
int endFacingDir = Convert.ToInt32(fields[4]);
|
2017-08-06 03:24:01 +08:00
|
|
|
|
|
|
|
schedulePathDescription = this.Helper.Reflection
|
2018-01-11 13:50:16 +08:00
|
|
|
.GetMethod(npc, "pathfindToNextScheduleLocation")
|
2018-05-01 09:21:31 +08:00
|
|
|
.Invoke<SchedulePathDescription>(npc.currentLocation.Name, npc.getTileX(), npc.getTileY(), endMap, x, y, endFacingDir, null, null);
|
2017-07-31 10:55:58 +08:00
|
|
|
index++;
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2018-12-30 18:00:05 +08:00
|
|
|
catch
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
npc.DirectionsToNewLocation = schedulePathDescription;
|
|
|
|
npc.controller = new PathFindController(npc.DirectionsToNewLocation.route, npc, Utility.getGameLocationOfCharacter(npc))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
finalFacingDirection = npc.DirectionsToNewLocation.facingDirection,
|
|
|
|
endBehaviorFunction = null
|
|
|
|
};
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
}
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <summary>Get an NPC's raw schedule data from the XNB files.</summary>
|
|
|
|
/// <param name="npcName">The NPC name whose schedules to read.</param>
|
|
|
|
/// <returns>Returns the NPC schedule if found, else <c>null</c>.</returns>
|
|
|
|
private IDictionary<string, string> GetRawSchedule(string npcName)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
return Game1.content.Load<Dictionary<string, string>>($"Characters\\schedules\\{npcName}");
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2018-12-30 18:00:05 +08:00
|
|
|
catch
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
/// <summary>Load the raw schedule data for an NPC.</summary>
|
|
|
|
/// <param name="npc">The NPC whose schedule to read.</param>
|
|
|
|
private string ParseSchedule(NPC npc)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
// set flags
|
2018-05-01 09:21:31 +08:00
|
|
|
if (npc.Name.Equals("Robin") || Game1.player.currentUpgrade != null)
|
|
|
|
npc.IsInvisible = false;
|
|
|
|
if (npc.Name.Equals("Willy") && Game1.stats.DaysPlayed < 2u)
|
|
|
|
npc.IsInvisible = true;
|
2016-11-04 02:25:53 +08:00
|
|
|
else if (npc.Schedule != null)
|
|
|
|
npc.followSchedule = true;
|
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// read schedule data
|
2018-05-01 09:21:31 +08:00
|
|
|
IDictionary<string, string> schedule = this.GetRawSchedule(npc.Name);
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule == null)
|
2016-11-04 02:25:53 +08:00
|
|
|
return "";
|
2017-07-31 05:42:15 +08:00
|
|
|
|
2017-07-31 10:55:58 +08:00
|
|
|
// do stuff
|
2016-11-04 02:25:53 +08:00
|
|
|
if (npc.isMarried())
|
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
string dayName = Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
2018-05-01 09:21:31 +08:00
|
|
|
if ((npc.Name.Equals("Penny") && (dayName.Equals("Tue") || dayName.Equals("Wed") || dayName.Equals("Fri"))) || (npc.Name.Equals("Maru") && (dayName.Equals("Tue") || dayName.Equals("Thu"))) || (npc.Name.Equals("Harvey") && (dayName.Equals("Tue") || dayName.Equals("Thu"))))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-08-06 03:24:01 +08:00
|
|
|
this.Helper.Reflection
|
2019-01-07 01:28:14 +08:00
|
|
|
.GetField<string>(npc, "nameOfTodaysSchedule")
|
2017-08-06 03:24:01 +08:00
|
|
|
.SetValue("marriageJob");
|
2017-07-31 10:55:58 +08:00
|
|
|
return "marriageJob";
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
if (!Game1.isRaining && schedule.ContainsKey("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-08-06 03:24:01 +08:00
|
|
|
this.Helper.Reflection
|
2019-01-07 01:28:14 +08:00
|
|
|
.GetField<string>(npc, "nameOfTodaysSchedule")
|
2017-08-06 03:24:01 +08:00
|
|
|
.SetValue("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth));
|
2017-07-31 10:55:58 +08:00
|
|
|
return "marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
npc.followSchedule = false;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey(Game1.currentSeason + "_" + Game1.dayOfMonth))
|
|
|
|
return Game1.currentSeason + "_" + Game1.dayOfMonth;
|
2016-11-04 02:25:53 +08:00
|
|
|
int i;
|
2018-12-30 18:00:05 +08:00
|
|
|
Game1.player.friendshipData.TryGetValue(npc.Name, out Friendship f);
|
|
|
|
for (i = (Game1.player.friendshipData.ContainsKey(npc.Name) ? (f.Points / 250) : -1); i > 0; i--)
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey(Game1.dayOfMonth + "_" + i))
|
|
|
|
return Game1.dayOfMonth + "_" + i;
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey(string.Empty + Game1.dayOfMonth))
|
|
|
|
return string.Empty + Game1.dayOfMonth;
|
2018-05-01 09:21:31 +08:00
|
|
|
if (npc.Name.Equals("Pam") && Game1.player.mailReceived.Contains("ccVault"))
|
2017-07-31 10:55:58 +08:00
|
|
|
return "bus";
|
2016-11-04 02:25:53 +08:00
|
|
|
if (Game1.isRaining)
|
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
if (Game1.random.NextDouble() < 0.5 && schedule.ContainsKey("rain2"))
|
|
|
|
return "rain2";
|
|
|
|
if (schedule.ContainsKey("rain"))
|
|
|
|
return "rain";
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
List<string> list = new List<string> { Game1.currentSeason, Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth) };
|
2018-12-30 18:00:05 +08:00
|
|
|
Game1.player.friendshipData.TryGetValue(npc.Name, out Friendship friendship);
|
2018-05-01 09:21:31 +08:00
|
|
|
i = (Game1.player.friendshipData.ContainsKey(npc.Name) ? (friendship.Points / 250) : -1);
|
2016-11-04 02:25:53 +08:00
|
|
|
while (i > 0)
|
|
|
|
{
|
|
|
|
list.Add(string.Empty + i);
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey(string.Join("_", list)))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
return string.Join("_", list);
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
i--;
|
|
|
|
list.RemoveAt(list.Count - 1);
|
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey(string.Join("_", list)))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
return string.Join("_", list);
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey(Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
return Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey(Game1.currentSeason))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
return Game1.currentSeason;
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey("spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
|
2016-11-04 02:25:53 +08:00
|
|
|
{
|
2017-07-31 10:55:58 +08:00
|
|
|
return "spring_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
list.RemoveAt(list.Count - 1);
|
|
|
|
list.Add("spring");
|
2018-12-30 18:00:05 +08:00
|
|
|
Game1.player.friendshipData.TryGetValue(npc.Name, out Friendship friendship2);
|
2018-05-01 09:21:31 +08:00
|
|
|
i = (Game1.player.friendshipData.ContainsKey(npc.Name) ? (friendship2.Points / 250) : -1);
|
2016-11-04 02:25:53 +08:00
|
|
|
while (i > 0)
|
|
|
|
{
|
|
|
|
list.Add(string.Empty + i);
|
2017-07-31 10:55:58 +08:00
|
|
|
if (schedule.ContainsKey(string.Join("_", list)))
|
|
|
|
return string.Join("_", list);
|
2016-11-04 02:25:53 +08:00
|
|
|
i--;
|
|
|
|
list.RemoveAt(list.Count - 1);
|
|
|
|
}
|
2018-12-30 18:00:05 +08:00
|
|
|
return schedule.ContainsKey("spring")
|
|
|
|
? "spring"
|
|
|
|
: null;
|
2016-11-04 02:25:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|