/********* ** Protected methods *********/ private void OnDayStarted(object s, EventArgs e) { this.Monitor.Log("DayStarted event, preparing custom minecarts...", LogLevel.Trace); if (Context.IsMultiplayer) { this.Monitor.Log("Multiplayer game detected, you are using Extended Minecarts at your own risk!", LogLevel.Warn); } ModEntry.Destinations = new Dictionary <string, ButtonFormComponent>(); foreach (KeyValuePair <string, string> item in ModEntry.DestinationData) { switch (item.Key) { case "Farm": if (!this.Config.FarmDestinationEnabled) { continue; } break; case "Desert": if (!this.Config.DesertDestinationEnabled) { continue; } break; case "Woods": if (!this.Config.WoodsDestinationEnabled) { continue; } break; case "Beach": if (!this.Config.BeachDestinationEnabled) { continue; } break; case "Forest": if (!this.Config.WizardDestinationEnabled) { continue; } break; } ModEntry.Destinations.Add(item.Key, new ButtonFormComponent(new Point(-1, 3 + 11 * ModEntry.Destinations.Count), 65, item.Value, (t, p, m) => this.AnswerResolver(item.Key))); } ModEntry.Menu = new FrameworkMenu(new Point(85, ModEntry.Destinations.Count * 11 + 22)); ModEntry.Menu.AddComponent(new LabelComponent(new Point(-3, -16), this.Helper.Translation.Get("choose-destination"))); foreach (ButtonFormComponent c in ModEntry.Destinations.Values) { ModEntry.Menu.AddComponent(c); } Dictionary <string, string> Status = new Dictionary <string, string>() { ["Farm"] = "Unknown", ["Desert"] = "Unknown", ["Woods"] = "Unknown", ["Forest"] = "Unknown", ["Beach"] = "Unknown" }; // # Farm if (this.Config.FarmDestinationEnabled && !this.Config.UseCustomFarmDestination) { try { GameLocation farm = Game1.getFarm(); if (!farm.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched")) { if (this.Config.AlternateFarmMinecart) { farm.SetTile(18, 5, "Front", 483, "untitled tile sheet"); farm.SetTile(19, 5, "Front", 484, "untitled tile sheet"); farm.SetTile(19, 5, "Buildings", 217, "untitled tile sheet"); farm.SetTile(20, 5, "Front", 485, "untitled tile sheet"); farm.SetTile(18, 6, "Buildings", 508, "untitled tile sheet"); farm.SetTile(19, 6, "Back", 509, "untitled tile sheet"); farm.SetTile(20, 6, "Buildings", 510, "untitled tile sheet"); farm.SetTile(18, 7, "Buildings", 533, "untitled tile sheet"); farm.SetTile(19, 7, "Back", 534, "untitled tile sheet"); farm.SetTile(20, 7, "Buildings", 535, "untitled tile sheet"); farm.SetTile(19, 6, "Buildings", 933, "untitled tile sheet"); farm.SetTile(19, 7, "Buildings", 958, "untitled tile sheet"); farm.SetTileProperty(19, 7, "Buildings", "Action", "MinecartTransport"); } else { // Clear annoying flower farm.removeTile(79, 12, "Buildings"); // Cut dark short farm.SetTile(77, 11, "Back", 375, "untitled tile sheet"); farm.SetTile(78, 11, "Back", 376, "untitled tile sheet"); farm.SetTile(79, 11, "Back", 376, "untitled tile sheet"); // Lay tracks farm.SetTile(78, 12, "Back", 729, "untitled tile sheet"); farm.SetTile(78, 13, "Back", 754, "untitled tile sheet"); farm.SetTile(78, 14, "Back", 755, "untitled tile sheet"); farm.SetTile(79, 12, "Back", 730, "untitled tile sheet"); // Trim grass farm.SetTile(77, 13, "Back", 175, "untitled tile sheet"); farm.SetTile(77, 14, "Back", 175, "untitled tile sheet"); farm.SetTile(77, 15, "Back", 175, "untitled tile sheet"); farm.SetTile(78, 15, "Back", 175, "untitled tile sheet"); farm.SetTile(79, 13, "Back", 175, "untitled tile sheet"); farm.SetTile(79, 14, "Back", 175, "untitled tile sheet"); farm.SetTile(79, 15, "Back", 175, "untitled tile sheet"); // Clean up fence farm.SetTile(78, 11, "Buildings", 436, "untitled tile sheet"); farm.removeTile(78, 14, "Buildings"); // Plop down minecart farm.SetTile(78, 12, "Buildings", 933, "untitled tile sheet"); farm.SetTile(78, 13, "Buildings", 958, "untitled tile sheet"); farm.SetTileProperty(78, 13, "Buildings", "Action", "MinecartTransport"); // Keep exit clear farm.setTileProperty(78, 14, "Back", "NoFurniture", "T"); } Status["Farm"] = "Patched"; farm.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true); } else { Status["Farm"] = "Skipped"; } } catch (Exception err) { this.Monitor.Log("Could not patch the Farm due to a unknown error", LogLevel.Error, err); } } else { Status["Farm"] = "Disabled"; } if (this.Config.DesertDestinationEnabled) { try { // # Desert GameLocation desert = Game1.getLocationFromName("Desert"); if (!desert.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched")) { TileSheet parent = Game1.getLocationFromName("Mountain").map.GetTileSheet("outdoors"); desert.map.AddTileSheet(new TileSheet("z_path_objects_custom_sheet", desert.map, parent.ImageSource, parent.SheetSize, parent.TileSize)); desert.map.DisposeTileSheets(Game1.mapDisplayDevice); desert.map.LoadTileSheets(Game1.mapDisplayDevice); if (this.Config.AlternateDesertMinecart) { // Backdrop desert.SetTile(33, 1, "Front", 221, "desert-new"); desert.SetTile(34, 1, "Front", 222, "desert-new"); desert.SetTile(35, 1, "Front", 223, "desert-new"); desert.SetTile(33, 2, "Front", 237, "desert-new"); desert.SetTile(34, 2, "Buildings", 254, "desert-new"); desert.SetTile(34, 2, "Front", 238, "desert-new"); desert.SetTile(35, 2, "Front", 239, "desert-new"); desert.SetTile(33, 3, "Buildings", 253, "desert-new"); desert.SetTile(34, 3, "Buildings", 254, "desert-new"); desert.SetTile(35, 3, "Buildings", 255, "desert-new"); desert.SetTile(33, 4, "Buildings", 269, "desert-new"); desert.SetTile(34, 4, "Back", 270, "desert-new"); desert.SetTile(35, 4, "Buildings", 271, "desert-new"); // Cart desert.SetTile(34, 3, "Front", 933, "z_path_objects_custom_sheet"); desert.SetTile(34, 4, "Buildings", 958, "z_path_objects_custom_sheet"); desert.SetTileProperty(34, 4, "Buildings", "Action", "MinecartTransport"); } else { // Backdrop desert.SetTile(33, 39, "Front", 221, "desert-new"); desert.SetTile(34, 39, "Front", 222, "desert-new"); desert.SetTile(35, 39, "Front", 223, "desert-new"); desert.SetTile(33, 40, "Front", 237, "desert-new"); desert.SetTile(34, 40, "Buildings", 254, "desert-new"); desert.SetTile(34, 40, "Front", 238, "desert-new"); desert.SetTile(35, 40, "Front", 239, "desert-new"); desert.SetTile(33, 41, "Buildings", 253, "desert-new"); desert.SetTile(34, 41, "Buildings", 254, "desert-new"); desert.SetTile(35, 41, "Buildings", 255, "desert-new"); desert.SetTile(33, 42, "Buildings", 269, "desert-new"); desert.SetTile(34, 42, "Back", 270, "desert-new"); desert.SetTile(35, 42, "Buildings", 271, "desert-new"); // Cart desert.SetTile(34, 41, "Front", 933, "z_path_objects_custom_sheet"); desert.SetTile(34, 42, "Buildings", 958, "z_path_objects_custom_sheet"); desert.SetTileProperty(34, 42, "Buildings", "Action", "MinecartTransport"); } Status["Desert"] = "Patched"; desert.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true); } else { Status["Desert"] = "Skipped"; } } catch (Exception err) { this.Monitor.Log("Could not patch the Desert due to a unknown error", LogLevel.Error, err); } } else { Status["Desert"] = "Disabled"; } if (this.Config.WoodsDestinationEnabled) { try { // # Woods GameLocation woods = Game1.getLocationFromName("Woods"); if (!woods.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched")) { woods.SetTile(46, 3, "Front", 933, "untitled tile sheet"); woods.SetTile(46, 4, "Buildings", 958, "untitled tile sheet"); woods.SetTileProperty(46, 4, "Buildings", "Action", "MinecartTransport"); Status["Woods"] = "Patched"; woods.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true); } else { Status["Woods"] = "Skipped"; } } catch (Exception err) { this.Monitor.Log("Could not patch the Woods due to a unknown error", LogLevel.Error, err); } } else { Status["Woods"] = "Disabled"; } if (this.Config.WizardDestinationEnabled) { try { // # Wizard GameLocation forest = Game1.getLocationFromName("Forest"); if (!forest.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched")) { forest.SetTile(13, 37, "Front", 483, "outdoors"); forest.SetTile(14, 37, "Front", 484, "outdoors"); forest.SetTile(14, 37, "Buildings", 217, "outdoors"); forest.SetTile(15, 37, "Front", 485, "outdoors"); forest.SetTile(13, 38, "Buildings", 508, "outdoors"); forest.SetTile(14, 38, "Back", 509, "outdoors"); forest.SetTile(15, 38, "Buildings", 510, "outdoors"); forest.SetTile(13, 39, "Buildings", 533, "outdoors"); forest.SetTile(15, 39, "Buildings", 535, "outdoors"); forest.SetTile(14, 38, "Buildings", 933, "outdoors"); forest.SetTile(14, 39, "Buildings", 958, "outdoors"); forest.SetTileProperty(14, 39, "Buildings", "Action", "MinecartTransport"); Status["Forest"] = "Patched"; forest.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true); } else { Status["Forest"] = "Skipped"; } } catch (Exception err) { this.Monitor.Log("Could not patch the Forest due to a unknown error", LogLevel.Error, err); } } else { Status["Forest"] = "Disabled"; } if (this.Config.BeachDestinationEnabled) { try { // # Beach GameLocation beach = Game1.getLocationFromName("Beach"); if (!beach.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched")) { TileSheet parent = Game1.getLocationFromName("Mountain").map.GetTileSheet("outdoors"); beach.map.AddTileSheet(new TileSheet("z_path_objects_custom_sheet", beach.map, parent.ImageSource, parent.SheetSize, parent.TileSize)); beach.map.DisposeTileSheets(Game1.mapDisplayDevice); beach.map.LoadTileSheets(Game1.mapDisplayDevice); beach.RemoveTile(67, 2, "Buildings"); beach.RemoveTile(67, 5, "Buildings"); beach.RemoveTile(67, 4, "Buildings"); beach.SetTile(67, 2, "Buildings", 933, "z_path_objects_custom_sheet"); beach.SetTile(67, 3, "Buildings", 958, "z_path_objects_custom_sheet"); beach.SetTileProperty(67, 3, "Buildings", "Action", "MinecartTransport"); Status["Beach"] = "Patched"; beach.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true); } else { Status["Beach"] = "Skipped"; } } catch (Exception err) { this.Monitor.Log("Could not patch the Beach due to a unknown error", LogLevel.Error, err); } } else { Status["Beach"] = "Disabled"; } this.Monitor.Log("Minecart status: " + string.Join(", ", Status.Select(item => $"{item.Key} ({item.Value})")) + '.', LogLevel.Trace); }
private void GameEvents_UpdateTick(object s, EventArgs e) { if (!Game1.hasLoadedGame || Game1.CurrentEvent != null) { return; } GameEvents.UpdateTick -= this.GameEvents_UpdateTick; MenuEvents.MenuChanged += this.MenuEvents_MenuChanged; Destinations = new Dictionary <string, ButtonFormComponent>(); foreach (KeyValuePair <string, string> item in DestinationData) { switch (item.Key) { case "Farm": if (!this.Config.FarmDestinationEnabled) { continue; } break; case "Desert": if (!this.Config.DesertDestinationEnabled) { continue; } break; case "Woods": if (!this.Config.WoodsDestinationEnabled) { continue; } break; case "Beach": if (!this.Config.BeachDestinationEnabled) { continue; } break; case "Forest": if (!this.Config.WizardDestinationEnabled) { continue; } break; } Destinations.Add(item.Key, new ButtonFormComponent(new Microsoft.Xna.Framework.Point(-1, 3 + 11 * Destinations.Count), 65, item.Value, (t, p, m) => AnswerResolver(item.Key))); } Menu = new FrameworkMenu(new Microsoft.Xna.Framework.Point(85, Destinations.Count * 11 + 22)); Menu.AddComponent(new LabelComponent(new Microsoft.Xna.Framework.Point(-3, -16), "Choose destination")); foreach (ButtonFormComponent c in Destinations.Values) { Menu.AddComponent(c); } // # Farm if (this.Config.FarmDestinationEnabled && !this.Config.UseCustomFarmDestination) { try { GameLocation farm = Game1.getFarm(); if (this.Config.AlternateFarmMinecart) { farm.SetTile(18, 5, "Front", 483, "untitled tile sheet"); farm.SetTile(19, 5, "Front", 484, "untitled tile sheet"); farm.SetTile(19, 5, "Buildings", 217, "untitled tile sheet"); farm.SetTile(20, 5, "Front", 485, "untitled tile sheet"); farm.SetTile(18, 6, "Buildings", 508, "untitled tile sheet"); farm.SetTile(19, 6, "Back", 509, "untitled tile sheet"); farm.SetTile(20, 6, "Buildings", 510, "untitled tile sheet"); farm.SetTile(18, 7, "Buildings", 533, "untitled tile sheet"); farm.SetTile(19, 7, "Back", 534, "untitled tile sheet"); farm.SetTile(20, 7, "Buildings", 535, "untitled tile sheet"); farm.SetTile(19, 6, "Buildings", 933, "untitled tile sheet"); farm.SetTile(19, 7, "Buildings", 958, "untitled tile sheet"); farm.SetTileProperty(19, 7, "Buildings", "Action", "MinecartTransport"); } else { // Clear annoying flower farm.removeTile(79, 12, "Buildings"); // Cut dark short farm.SetTile(77, 11, "Back", 375, "untitled tile sheet"); farm.SetTile(78, 11, "Back", 376, "untitled tile sheet"); farm.SetTile(79, 11, "Back", 376, "untitled tile sheet"); // Lay tracks farm.SetTile(78, 12, "Back", 729, "untitled tile sheet"); farm.SetTile(78, 13, "Back", 754, "untitled tile sheet"); farm.SetTile(78, 14, "Back", 755, "untitled tile sheet"); farm.SetTile(79, 12, "Back", 730, "untitled tile sheet"); // Trim grass farm.SetTile(77, 13, "Back", 175, "untitled tile sheet"); farm.SetTile(77, 14, "Back", 175, "untitled tile sheet"); farm.SetTile(77, 15, "Back", 175, "untitled tile sheet"); farm.SetTile(78, 15, "Back", 175, "untitled tile sheet"); farm.SetTile(79, 13, "Back", 175, "untitled tile sheet"); farm.SetTile(79, 14, "Back", 175, "untitled tile sheet"); farm.SetTile(79, 15, "Back", 175, "untitled tile sheet"); // Clean up fence farm.SetTile(78, 11, "Buildings", 436, "untitled tile sheet"); farm.removeTile(78, 14, "Buildings"); // Plop down minecart farm.SetTile(78, 12, "Buildings", 933, "untitled tile sheet"); farm.SetTile(78, 13, "Buildings", 958, "untitled tile sheet"); farm.SetTileProperty(78, 13, "Buildings", "Action", "MinecartTransport"); // Keep exit clear farm.setTileProperty(78, 14, "Back", "NoFurniture", "T"); } } catch (Exception err) { this.Monitor.Log("Could not patch the Farm due to a unknown error", LogLevel.Error, err); } } if (this.Config.DesertDestinationEnabled) { try { // # Desert GameLocation desert = Game1.getLocationFromName("Desert"); xTile.Tiles.TileSheet parent = Game1.getLocationFromName("Mountain").map.GetTileSheet("outdoors"); desert.map.AddTileSheet(new xTile.Tiles.TileSheet("z_path_objects_custom_sheet", desert.map, parent.ImageSource, parent.SheetSize, parent.TileSize)); desert.map.DisposeTileSheets(Game1.mapDisplayDevice); desert.map.LoadTileSheets(Game1.mapDisplayDevice); if (this.Config.AlternateDesertMinecart) { // Backdrop desert.SetTile(33, 1, "Front", 221, "desert-new"); desert.SetTile(34, 1, "Front", 222, "desert-new"); desert.SetTile(35, 1, "Front", 223, "desert-new"); desert.SetTile(33, 2, "Front", 237, "desert-new"); desert.SetTile(34, 2, "Buildings", 254, "desert-new"); desert.SetTile(34, 2, "Front", 238, "desert-new"); desert.SetTile(35, 2, "Front", 239, "desert-new"); desert.SetTile(33, 3, "Buildings", 253, "desert-new"); desert.SetTile(34, 3, "Buildings", 254, "desert-new"); desert.SetTile(35, 3, "Buildings", 255, "desert-new"); desert.SetTile(33, 4, "Buildings", 269, "desert-new"); desert.SetTile(34, 4, "Back", 270, "desert-new"); desert.SetTile(35, 4, "Buildings", 271, "desert-new"); // Cart desert.SetTile(34, 3, "Front", 933, "z_path_objects_custom_sheet"); desert.SetTile(34, 4, "Buildings", 958, "z_path_objects_custom_sheet"); desert.SetTileProperty(34, 4, "Buildings", "Action", "MinecartTransport"); } else { // Backdrop desert.SetTile(33, 39, "Front", 221, "desert-new"); desert.SetTile(34, 39, "Front", 222, "desert-new"); desert.SetTile(35, 39, "Front", 223, "desert-new"); desert.SetTile(33, 40, "Front", 237, "desert-new"); desert.SetTile(34, 40, "Buildings", 254, "desert-new"); desert.SetTile(34, 40, "Front", 238, "desert-new"); desert.SetTile(35, 40, "Front", 239, "desert-new"); desert.SetTile(33, 41, "Buildings", 253, "desert-new"); desert.SetTile(34, 41, "Buildings", 254, "desert-new"); desert.SetTile(35, 41, "Buildings", 255, "desert-new"); desert.SetTile(33, 42, "Buildings", 269, "desert-new"); desert.SetTile(34, 42, "Back", 270, "desert-new"); desert.SetTile(35, 42, "Buildings", 271, "desert-new"); // Cart desert.SetTile(34, 41, "Front", 933, "z_path_objects_custom_sheet"); desert.SetTile(34, 42, "Buildings", 958, "z_path_objects_custom_sheet"); desert.SetTileProperty(34, 42, "Buildings", "Action", "MinecartTransport"); } } catch (Exception err) { this.Monitor.Log("Could not patch the Desert due to a unknown error", LogLevel.Error, err); } } if (this.Config.WoodsDestinationEnabled) { try { // # Woods GameLocation woods = Game1.getLocationFromName("Woods"); woods.SetTile(46, 3, "Front", 933, "untitled tile sheet"); woods.SetTile(46, 4, "Buildings", 958, "untitled tile sheet"); woods.SetTileProperty(46, 4, "Buildings", "Action", "MinecartTransport"); } catch (Exception err) { this.Monitor.Log("Could not patch the Woods due to a unknown error", LogLevel.Error, err); } } if (this.Config.WizardDestinationEnabled) { try { // # Wizard GameLocation forest = Game1.getLocationFromName("Forest"); forest.SetTile(13, 37, "Front", 483, "outdoors"); forest.SetTile(14, 37, "Front", 484, "outdoors"); forest.SetTile(14, 37, "Buildings", 217, "outdoors"); forest.SetTile(15, 37, "Front", 485, "outdoors"); forest.SetTile(13, 38, "Buildings", 508, "outdoors"); forest.SetTile(14, 38, "Back", 509, "outdoors"); forest.SetTile(15, 38, "Buildings", 510, "outdoors"); forest.SetTile(13, 39, "Buildings", 533, "outdoors"); forest.SetTile(15, 39, "Buildings", 535, "outdoors"); forest.SetTile(14, 38, "Buildings", 933, "outdoors"); forest.SetTile(14, 39, "Buildings", 958, "outdoors"); forest.SetTileProperty(14, 39, "Buildings", "Action", "MinecartTransport"); } catch (Exception err) { this.Monitor.Log("Could not patch the Forest due to a unknown error", LogLevel.Error, err); } } if (this.Config.BeachDestinationEnabled) { try { // # Beach GameLocation beach = Game1.getLocationFromName("Beach"); xTile.Tiles.TileSheet parent = Game1.getLocationFromName("Mountain").map.GetTileSheet("outdoors"); beach.map.AddTileSheet(new xTile.Tiles.TileSheet("z_path_objects_custom_sheet", beach.map, parent.ImageSource, parent.SheetSize, parent.TileSize)); beach.map.DisposeTileSheets(Game1.mapDisplayDevice); beach.map.LoadTileSheets(Game1.mapDisplayDevice); beach.RemoveTile(67, 2, "Buildings"); beach.RemoveTile(67, 5, "Buildings"); beach.RemoveTile(67, 4, "Buildings"); beach.SetTile(67, 2, "Buildings", 933, "z_path_objects_custom_sheet"); beach.SetTile(67, 3, "Buildings", 958, "z_path_objects_custom_sheet"); beach.SetTileProperty(67, 3, "Buildings", "Action", "MinecartTransport"); } catch (Exception err) { this.Monitor.Log("Could not patch the Beach due to a unknown error", LogLevel.Error, err); } } }