Merge pull request #39 from perkinslr/patch-1

Reset money to previous value before the save
This commit is contained in:
Joshua Navarro 2018-06-25 20:09:30 -07:00 committed by GitHub
commit 349d053727
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 2 deletions

View File

@ -100,6 +100,7 @@ namespace Omegasis.NightOwl
TimeEvents.TimeOfDayChanged += this.TimeEvents_TimeOfDayChanged;
TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted;
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
GameEvents.FourthUpdateTick += this.GameEvents_FourthUpdateTick;
GameEvents.UpdateTick += GameEvents_UpdateTick;
shouldWarpHorse = false;
@ -149,6 +150,28 @@ namespace Omegasis.NightOwl
this.WriteErrorLog();
}
}
/// <summary>The method invoked before the game saves.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void SaveEvents_BeforeSave(object sender, EventArgs e)
{
int collapseFee = 0;
string[] passOutFees = Game1.player.mailbox
.Where(p => p.Contains("passedOut"))
.ToArray();
for (int idx=0; idx<pofees.Length; idx++)
{
string[] msg = passOutFees[idx].Split(' ');
collapseFee += Int32.Parse(msg[1]);
}
if (this.Config.KeepMoneyAfterCollapse)
{
Game1.player.money += collapseFee;
}
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <param name="sender">The event sender.</param>
@ -180,8 +203,6 @@ namespace Omegasis.NightOwl
Game1.player.stamina = this.PreCollapseStamina;
if (this.Config.KeepHealthAfterCollapse)
Game1.player.health = this.PreCollapseHealth;
if (this.Config.KeepMoneyAfterCollapse)
Game1.player.money = this.PreCollapseMoney;
if (this.Config.KeepPositionAfterCollapse)
if (Game1.weddingToday == false)
{