コード例 #1
0
        /// <summary>Raised after the game state is updated (≈60 times per second).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
        {
            if (!Context.IsPlayerFree)
            {
                return;
            }

            if (!SkinsReady)
            {
                this.LoadSkins();
            }

            // patch bus stop
            if (this.ReplaceBus && Game1.getLocationFromName("BusStop")?.map.Properties.ContainsKey("MA.Patched") == false)
            {
                MoreEvents.ActionTriggered += this.OnActionTriggered;
                this.Monitor.Log("Patching bus stop...", LogLevel.Trace);
                GameLocation bus = Game1.getLocationFromName("BusStop");
                bus.map.Properties.Add("MA.Patched", true);
                bus.map.AddTileSheet(new TileSheet("MorePetsTilesheet", bus.map, this.Helper.Content.GetActualAssetKey("assets/box.png"), new Size(2, 2), new Size(16, 16)));
                bus.SetTile(1, 2, "Front", 0, "MorePetsTilesheet");
                bus.SetTile(2, 2, "Front", 1, "MorePetsTilesheet");
                bus.SetTile(1, 3, "Buildings", 2, "MorePetsTilesheet");
                bus.SetTile(2, 3, "Buildings", 3, "MorePetsTilesheet");
                bus.SetTileProperty(1, 3, "Buildings", "Action", "MorePetsAdoption");
                bus.SetTileProperty(2, 3, "Buildings", "Action", "MorePetsAdoption");
            }

            // set pet skins
            foreach (Pet pet in GetAllPets())
            {
                if (pet.Manners > 0)
                {
                    AnimalSkin skin = this.GetSkin(pet);
                    if (skin != null && pet.Sprite.textureName.Value != skin.AssetKey)
                    {
                        pet.Sprite  = new AnimatedSprite(skin.AssetKey, 0, 32, 32);
                        pet.Manners = skin.ID;
                    }
                }
            }

            // set farm animal skins
            foreach (FarmAnimal animal in this.GetFarmAnimals())
            {
                AnimalSkin skin = this.GetSkin(animal);
                if (skin != null && animal.Sprite.textureName.Value != skin.AssetKey)
                {
                    animal.Sprite = new AnimatedSprite(skin.AssetKey, 0, animal.frontBackSourceRect.Width, animal.frontBackSourceRect.Height);
                    SkinMap[animal.myID.Value] = skin.ID;
                }
                else if (skin == null)
                {
                    SkinMap[animal.myID.Value] = 0;
                }
            }
        }
コード例 #2
0
        private void GameEvents_UpdateTick(object s, EventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            // patch bus stop
            if (this.ReplaceBus && Game1.getLocationFromName("BusStop") != null)
            {
                this.Monitor.Log("Patching bus stop...", LogLevel.Trace);
                GameLocation bus = Game1.getLocationFromName("BusStop");
                bus.map.AddTileSheet(new TileSheet("MorePetsTilesheet", bus.map, this.Helper.Content.GetActualAssetKey("assets/box.png"), new Size(2, 2), new Size(16, 16)));
                bus.SetTile(1, 2, "Front", 0, "MorePetsTilesheet");
                bus.SetTile(2, 2, "Front", 1, "MorePetsTilesheet");
                bus.SetTile(1, 3, "Buildings", 2, "MorePetsTilesheet");
                bus.SetTile(2, 3, "Buildings", 3, "MorePetsTilesheet");
                bus.SetTileProperty(1, 3, "Buildings", "Action", "MorePetsAdoption");
                bus.SetTileProperty(2, 3, "Buildings", "Action", "MorePetsAdoption");
                this.ReplaceBus = false;
            }

            // set pet skins
            foreach (Pet pet in this.GetAllPets())
            {
                if (pet.Manners > 0 && !pet.updatedDialogueYet)
                {
                    AnimalSkin skin = this.GetSkin(pet);
                    if (skin != null)
                    {
                        pet.Sprite  = new AnimatedSprite(skin.AssetKey, 0, 32, 32);
                        pet.Manners = skin.ID;
                    }
                    pet.updatedDialogueYet = true;
                }
            }

            // set farm animal skins
            foreach (FarmAnimal animal in this.GetFarmAnimals())
            {
                AnimalSkin skin = this.GetSkin(animal);
                if (skin != null && animal.Sprite.textureName.Value != skin.AssetKey)
                {
                    animal.Sprite          = new AnimatedSprite(skin.AssetKey, 0, animal.frontBackSourceRect.Width, animal.frontBackSourceRect.Height);
                    animal.meatIndex.Value = skin.ID + 999;
                }
            }
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: tpf89/StardewMods
        internal void GameEvents_UpdateTick(object s, EventArgs e)
        {
            if (!Game1.hasLoadedGame || Game1.CurrentEvent != null || Game1.fadeToBlack)
            {
                return;
            }

            foreach (NPC npc in GetAllPets())
            {
                if (npc.manners > 0 && npc.updatedDialogueYet == false)
                {
                    try
                    {
                        var textures = npc is Dog ? DogTextures : CatTextures;
                        npc.sprite = new AnimatedSprite(textures[npc.manners], 0, 32, 32);
                    }
                    catch
                    {
                        Monitor.Log("Pet with unknown skin number found, using default: " + npc.manners, LogLevel.Error);
                    }
                    npc.updatedDialogueYet = true;
                }
            }
            if (replaceBus && Game1.getLocationFromName("BusStop") != null)
            {
                GameLocation bus = Game1.getLocationFromName("BusStop");
                bus.map.AddTileSheet(new TileSheet("MorePetsTilesheet", bus.map, "paths_objects_MorePetsTilesheet", new xTile.Dimensions.Size(2, 2), new xTile.Dimensions.Size(16, 16)));
                bus.SetTile(1, 2, "Front", 0, "MorePetsTilesheet");
                bus.SetTile(2, 2, "Front", 1, "MorePetsTilesheet");
                bus.SetTile(1, 3, "Buildings", 2, "MorePetsTilesheet");
                bus.SetTile(2, 3, "Buildings", 3, "MorePetsTilesheet");
                bus.SetTileProperty(1, 3, "Buildings", "Action", "MorePetsAdoption");
                bus.SetTileProperty(2, 3, "Buildings", "Action", "MorePetsAdoption");
                replaceBus = false;
            }
        }
コード例 #4
0
ファイル: MoreAnimalsMod.cs プロジェクト: vphong/StardewMods
        internal void GameEvents_UpdateTick(object s, EventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            if (replaceBus && Game1.getLocationFromName("BusStop") != null)
            {
                this.Monitor.Log("Patching bus stop...", LogLevel.Trace);
                GameLocation bus = Game1.getLocationFromName("BusStop");
                bus.map.AddTileSheet(new TileSheet("MorePetsTilesheet", bus.map, this.Helper.Content.GetActualAssetKey("box"), new xTile.Dimensions.Size(2, 2), new xTile.Dimensions.Size(16, 16)));
                bus.SetTile(1, 2, "Front", 0, "MorePetsTilesheet");
                bus.SetTile(2, 2, "Front", 1, "MorePetsTilesheet");
                bus.SetTile(1, 3, "Buildings", 2, "MorePetsTilesheet");
                bus.SetTile(2, 3, "Buildings", 3, "MorePetsTilesheet");
                bus.SetTileProperty(1, 3, "Buildings", "Action", "MorePetsAdoption");
                bus.SetTileProperty(2, 3, "Buildings", "Action", "MorePetsAdoption");
                replaceBus = false;
            }
            foreach (NPC npc in GetAllPets())
            {
                if (npc.manners > 0 && npc.updatedDialogueYet == false)
                {
                    try
                    {
                        string type = npc is Dog ? "dog" : "cat";
                        npc.sprite = new AnimatedSprite(this.Helper.Content.Load <Texture2D>($"skins/{type}_{npc.manners}"), 0, 32, 32);
                    }
                    catch
                    {
                        this.Monitor.Log("Pet with unknown skin number found, using default: " + npc.manners.ToString(), LogLevel.Error);
                    }
                    npc.updatedDialogueYet = true;
                }
            }
            if (Game1.getFarm() == null)
            {
                return;
            }
            Random random = new Random();

            foreach (FarmAnimal animal in Game1.getFarm().getAllFarmAnimals())
            {
                string str = animal.type;
                if (animal.age < animal.ageWhenMature)
                {
                    str = "Baby" + animal.type;
                }
                else if (animal.showDifferentTextureWhenReadyForHarvest && animal.currentProduce <= 0)
                {
                    str = "Sheared" + animal.type;
                }
                if (animal.meatIndex < 999)
                {
                    animal.meatIndex = Indexes[str][random.Next(0, Indexes[str].Count)] + 999;
                }
                else if (animal.meatIndex > 999)
                {
                    try
                    {
                        Texture2D texture = this.Helper.Content.Load <Texture2D>("skins/" + str + "_" + (animal.meatIndex - 999).ToString());
                        if (animal.sprite.Texture != texture)
                        {
                            animal.sprite = new AnimatedSprite(texture, 0, animal.frontBackSourceRect.Width, animal.frontBackSourceRect.Height);
                        }
                    }
                    catch
                    {
                        this.Monitor.Log("Animal with unknown skin number found, using default instead: " + (animal.meatIndex - 999).ToString(), LogLevel.Error);
                        if (str.Equals("BabyDuck"))
                        {
                            try
                            {
                                Texture2D texture = this.Helper.Content.Load <Texture2D>("skins/BabyDuck");
                                if (animal.sprite.Texture != texture)
                                {
                                    animal.sprite = new AnimatedSprite(texture, 0, animal.frontBackSourceRect.Width, animal.frontBackSourceRect.Height);
                                }
                            }
                            catch
                            {
                                this.Monitor.Log("Encounted a issue trying to override the default texture for baby ducks with the custom one, using vanilla.", LogLevel.Error);
                                Texture2D texture = Game1.content.Load <Texture2D>("Animals\\BabyWhite Chicken");
                                if (animal.sprite.Texture != texture)
                                {
                                    animal.sprite = new AnimatedSprite(texture, 0, animal.frontBackSourceRect.Width, animal.frontBackSourceRect.Height);
                                }
                            }
                        }
                        else
                        {
                            Texture2D texture = Game1.content.Load <Texture2D>("Animals\\" + str);
                            if (animal.sprite.Texture != texture)
                            {
                                animal.sprite = new AnimatedSprite(texture, 0, animal.frontBackSourceRect.Width, animal.frontBackSourceRect.Height);
                            }
                        }
                    }
                }
                else if (animal.type == "Duck" && animal.age < animal.ageWhenMature)
                {
                    try
                    {
                        Texture2D texture = this.Helper.Content.Load <Texture2D>("skins/BabyDuck");
                        if (animal.sprite.Texture != texture)
                        {
                            animal.sprite = new AnimatedSprite(texture, 0, animal.frontBackSourceRect.Width, animal.frontBackSourceRect.Height);
                        }
                    }
                    catch
                    {
                        this.Monitor.Log("Encounted a issue trying to override the default texture for baby ducks with the custom one, using vanilla.", LogLevel.Error);
                        Texture2D texture = Game1.content.Load <Texture2D>("Animals\\BabyWhite Chicken");
                        if (animal.sprite.Texture != texture)
                        {
                            animal.sprite = new AnimatedSprite(texture, 0, animal.frontBackSourceRect.Width, animal.frontBackSourceRect.Height);
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: ModEntry.cs プロジェクト: ZaRx485/smapi-mod-dump
        /*********
        ** 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);
        }
コード例 #6
0
        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);
                }
            }
        }