private void OnDayStarted(object sender, DayStartedEventArgs e) { // Set up notification messages MESSAGE_EVERYTHING_FAILING = new KeyValuePair <string, int>(i18n.Get("status_message.ship_falling_apart"), 10); MESSAGE_LOSING_FISH = new KeyValuePair <string, int>(i18n.Get("status_message.losing_fish"), 9); MESSAGE_MAX_LEAKS = new KeyValuePair <string, int>(i18n.Get("status_message.taking_on_water"), 8); MESSAGE_MULTI_PROBLEMS = new KeyValuePair <string, int>(i18n.Get("status_message.lots_of_problems"), 7); MESSAGE_ENGINE_PROBLEM = new KeyValuePair <string, int>(i18n.Get("status_message.engine_failing"), 7); MESSAGE_NET_PROBLEM = new KeyValuePair <string, int>(i18n.Get("status_message.nets_torn"), 6); MESSAGE_LEAK_PROBLEM = new KeyValuePair <string, int>(i18n.Get("status_message.leak"), 5); todayDayOfWeek = SDate.Now().DayOfWeek.ToString(); Beach beach = Game1.getLocationFromName("Beach") as Beach; beach.modData[MURPHY_ON_TRIP] = "false"; IslandSouthEast island = Game1.getLocationFromName("IslandSouthEast") as IslandSouthEast; island.modData[MURPHY_ON_TRIP] = "false"; // Set Farmer moddata used for this mod EstablishPlayerData(); if (Context.IsMainPlayer) { // Must be a user set date (default Wednesday), the player's fishing level >= 3 and the bridge must be fixed on the beach if (!Game1.MasterPlayer.mailReceived.Contains("PeacefulEnd.FishingTrawler_WillyIntroducesMurphy") && Game1.MasterPlayer.FishingLevel >= config.minimumFishingLevel && beach.bridgeFixed && todayDayOfWeek == Game1.MasterPlayer.modData[MURPHY_DAY_TO_APPEAR]) { Monitor.Log($"Sending {Game1.MasterPlayer.Name} intro letter about Murphy!", LogLevel.Trace); Helper.Content.AssetEditors.Add(new CustomMail()); Game1.MasterPlayer.mailbox.Add("PeacefulEnd.FishingTrawler_WillyIntroducesMurphy"); } // Must be a user set island date (default Satuday), met Murphy and Ginger Island's resort must be built IslandSouth resort = Game1.getLocationFromName("IslandSouth") as IslandSouth; if (!Game1.MasterPlayer.mailReceived.Contains("PeacefulEnd.FishingTrawler_MurphyGingerIsland") && Game1.MasterPlayer.mailReceived.Contains("PeacefulEnd.FishingTrawler_WillyIntroducesMurphy") && resort.resortRestored && todayDayOfWeek == Game1.MasterPlayer.modData[MURPHY_DAY_TO_APPEAR_ISLAND]) { Monitor.Log($"Sending {Game1.MasterPlayer.Name} Ginger Island letter about Murphy!", LogLevel.Trace); Helper.Content.AssetEditors.Add(new CustomMail()); Game1.MasterPlayer.mailbox.Add("PeacefulEnd.FishingTrawler_MurphyGingerIsland"); } } // Reset ownership of boat, deckhands mainDeckhand = null; numberOfDeckhands = 0; // Set the reward chest Vector2 rewardChestPosition = new Vector2(-100, -100); Farm farm = Game1.getLocationFromName("Farm") as Farm; rewardChest = farm.objects.Values.FirstOrDefault(o => o.modData.ContainsKey(REWARD_CHEST_DATA_KEY)) as Chest; if (rewardChest is null) { Monitor.Log($"Creating reward chest {rewardChestPosition}", LogLevel.Trace); rewardChest = new Chest(true, rewardChestPosition) { Name = "Trawler Rewards" }; rewardChest.modData.Add(REWARD_CHEST_DATA_KEY, "true"); farm.setObject(rewardChestPosition, rewardChest); } // Create the trawler object for the beach var locationContext = (todayDayOfWeek == Game1.MasterPlayer.modData[MURPHY_DAY_TO_APPEAR_ISLAND] ? GameLocation.LocationContext.Island : GameLocation.LocationContext.Default); if (todayDayOfWeek == Game1.MasterPlayer.modData[MURPHY_DAY_TO_APPEAR_ISLAND]) { trawlerObject = new Trawler(island); } else { trawlerObject = new Trawler(beach); } // Create the TrawlerReward class _trawlerRewards.Value = new TrawlerRewards(rewardChest); // Add the surface location TrawlerSurface surfaceLocation = new TrawlerSurface(Path.Combine(ModResources.assetFolderPath, "Maps", "FishingTrawler.tmx"), TRAWLER_SURFACE_LOCATION_NAME) { IsOutdoors = true, IsFarm = false, locationContext = locationContext }; Game1.locations.Add(surfaceLocation); // Add the hull location TrawlerHull hullLocation = new TrawlerHull(Path.Combine(ModResources.assetFolderPath, "Maps", "TrawlerHull.tmx"), TRAWLER_HULL_LOCATION_NAME) { IsOutdoors = false, IsFarm = false, locationContext = locationContext }; Game1.locations.Add(hullLocation); // Add the cabin location TrawlerCabin cabinLocation = new TrawlerCabin(Path.Combine(ModResources.assetFolderPath, "Maps", "TrawlerCabin.tmx"), TRAWLER_CABIN_LOCATION_NAME) { IsOutdoors = false, IsFarm = false, locationContext = locationContext }; Game1.locations.Add(cabinLocation); // Verify our locations were added and establish our location variables _trawlerHull.Value = Game1.getLocationFromName(TRAWLER_HULL_LOCATION_NAME) as TrawlerHull; _trawlerSurface.Value = Game1.getLocationFromName(TRAWLER_SURFACE_LOCATION_NAME) as TrawlerSurface; _trawlerCabin.Value = Game1.getLocationFromName(TRAWLER_CABIN_LOCATION_NAME) as TrawlerCabin; }
private void OnDayStarted(object sender, DayStartedEventArgs e) { todayDayOfWeek = SDate.Now().DayOfWeek.ToString(); Beach beach = Game1.getLocationFromName("Beach") as Beach; beach.modData[MURPHY_ON_TRIP] = "false"; // Set Farmer moddata used for this mod EstablishPlayerData(); if (Context.IsMainPlayer) { // Must be a Wednesday, the player's fishing level >= 3 and the bridge must be fixed on the beach if (!Game1.MasterPlayer.mailReceived.Contains("PeacefulEnd.FishingTrawler_WillyIntroducesMurphy") && Game1.MasterPlayer.FishingLevel >= config.minimumFishingLevel && beach.bridgeFixed && todayDayOfWeek == Game1.MasterPlayer.modData[MURPHY_DAY_TO_APPEAR]) { Monitor.Log($"Sending {Game1.MasterPlayer.Name} intro letter about Murphy!", LogLevel.Trace); Helper.Content.AssetEditors.Add(new IntroMail()); Game1.MasterPlayer.mailbox.Add("PeacefulEnd.FishingTrawler_WillyIntroducesMurphy"); } } // Reset ownership of boat, deckhands mainDeckhand = null; numberOfDeckhands = 0; // Set the reward chest Vector2 rewardChestPosition = new Vector2(-100, -100); Farm farm = Game1.getLocationFromName("Farm") as Farm; rewardChest = farm.objects.Values.FirstOrDefault(o => o.modData.ContainsKey(REWARD_CHEST_DATA_KEY)) as Chest; if (rewardChest is null) { Monitor.Log($"Creating reward chest {rewardChestPosition}", LogLevel.Trace); rewardChest = new Chest(true, rewardChestPosition) { Name = "Trawler Rewards" }; rewardChest.modData.Add(REWARD_CHEST_DATA_KEY, "true"); farm.setObject(rewardChestPosition, rewardChest); } // Create the trawler object for the beach trawlerObject = new Trawler(beach); // Create the TrawlerReward class _trawlerRewards.Value = new TrawlerRewards(rewardChest); // Add the surface location TrawlerSurface surfaceLocation = new TrawlerSurface(Path.Combine(ModResources.assetFolderPath, "Maps", "FishingTrawler.tmx"), TRAWLER_SURFACE_LOCATION_NAME) { IsOutdoors = true, IsFarm = false }; Game1.locations.Add(surfaceLocation); // Add the hull location TrawlerHull hullLocation = new TrawlerHull(Path.Combine(ModResources.assetFolderPath, "Maps", "TrawlerHull.tmx"), TRAWLER_HULL_LOCATION_NAME) { IsOutdoors = false, IsFarm = false }; Game1.locations.Add(hullLocation); // Add the cabin location TrawlerCabin cabinLocation = new TrawlerCabin(Path.Combine(ModResources.assetFolderPath, "Maps", "TrawlerCabin.tmx"), TRAWLER_CABIN_LOCATION_NAME) { IsOutdoors = false, IsFarm = false }; Game1.locations.Add(cabinLocation); // Verify our locations were added and establish our location variables _trawlerHull.Value = Game1.getLocationFromName(TRAWLER_HULL_LOCATION_NAME) as TrawlerHull; _trawlerSurface.Value = Game1.getLocationFromName(TRAWLER_SURFACE_LOCATION_NAME) as TrawlerSurface; _trawlerCabin.Value = Game1.getLocationFromName(TRAWLER_CABIN_LOCATION_NAME) as TrawlerCabin; }