/* SaveEvents_AfterLoad * Triggers after a save file is loaded. * Used to retrieve data and sometimes seed fish population. */ private void SaveEvents_AfterLoad(object sender, EventArgs e) { RealisticFishingData instance = this.Helper.ReadJsonFile <RealisticFishingData>($"data/{Constants.SaveFolderName}.json") ?? new RealisticFishingData(); this.NumFishCaughtToday = instance.NumFishCaughtToday; this.AllFishCaughtToday = instance.AllFishCaughtToday; this.fp = instance.fp; this.population = instance.fp.population; this.fp.CurrentFishIDCounter = instance.CurrentFishIDCounter; // Recover items in inventory if (!this.inventoryWasReconstructed) { this.RecoverItemsInInventory(instance); } // Recover items in chests if (!this.chestsWereReconstructed) { this.RecoverItemsInChests(instance); } this.Helper.WriteJsonFile($"data/{Constants.SaveFolderName}.json", instance); if (Tests.ShouldRunTests) { Tests.RunningTests = true; } }
/* SaveEvents_AfterCreate * Triggers after a save file is updated. * Used to retrieve data and seed the population of fish. */ private void SaveEvents_AfterCreate(object sender, EventArgs e) { RealisticFishingData instance = this.Helper.ReadJsonFile <RealisticFishingData>($"data/{Constants.SaveFolderName}.json") ?? new RealisticFishingData(); this.NumFishCaughtToday = instance.NumFishCaughtToday; this.AllFishCaughtToday = instance.AllFishCaughtToday; this.fp = instance.fp; this.population = instance.fp.population; this.fp.CurrentFishIDCounter = instance.CurrentFishIDCounter; this.Helper.WriteJsonFile($"data/{Constants.SaveFolderName}.json", instance); }