Beispiel #1
0
        public void Edit <T>(IAssetData asset)
        {
            if (asset.AssetNameEquals("Strings/StringsFromCSFiles"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                data["ShopMenu.cs.11494"] = "Hiyo, poke. Did you bring coins? Gud. Me sell hats and umbrellas.";
            }
            if (asset.AssetNameEquals("Data/mail"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                data["hatter"] = "Hi.^^Me sell hats and umbrellas. Okay, poke?^^Come to old old old haus, poke. Bring coines.^^-hat mouse[#]Hiyo, Poke";

                if (JsonAssets != null)
                {
                    data["lewis_umbrella"] = "@,^I found this old umbrella lying around, I figure it could be useful to you on rainy days.  ^   Sincerely, Mr. Lewis";
                }
            }

            if (asset.AssetNameEquals("TileSheets/BuffsIcons"))
            {
                var editor = asset.AsImage();

                Texture2D sourceImage = this.Helper.Content.Load <Texture2D>("assets/WetBuff.png", ContentSource.ModFolder);
                editor.PatchImage(sourceImage, targetArea: new Rectangle(176, 32, 16, 16));
            }

            /*if (Config.enableWetness)
             * {
             *  if (asset.AssetNameEquals("Data/hats"))
             *  {
             *      IDictionary<int, string> data = asset.AsDictionary<int, string>().Data;
             *
             *      // 90% rain protection
             *      data[3] = "Sombrero/A festively decorated hat made from woven straw.\n\nProvides major rain protection./false/true";
             *      data[40] = "Living Hat/It absorbs moisture from your scalp. No watering needed!\n\nProvides major rain protection./false/true";
             *      data[42] = "Mushroom Cap/It smells earthy.\n\nProvides major rain protection./false/true";
             *
             *      // 50% rain protection
             *      data[66] = "Garbage Hat/It's a garbage can lid 'upcycled' into a hat...\n\nProvides moderate rain protection./false/true";
             *      data[78] = "Frog Hat/A slimy friend that lives on your dome.\n\nProvides moderate rain protection./hide/true";
             *      data[17] = "Sailor's Cap/It's fresh and starchy.\n\nProvides moderate rain protection./false/true";
             *      data[4] = "Straw Hat/Light and cool, it's a farmer's delight.\n\nProvides moderate rain protection./false/true";
             *      data[28] = "Sou'wester/The shape helps to keep sailors dry during storms.\n\nProvides moderate rain protection./false/true";
             *      data[55] = "Fishing Hat/The wide brim keeps you shaded when you're fishing on the riverbank.\n\nProvides moderate rain protection./false/true";
             *      data[71] = "Copper Pan/You place the copper pan on your head...\n\nProvides moderate rain protection./false/true";
             *      data[27] = "Hard Hat/Keep your dome in one piece.\n\nProvides moderate rain protection./false/true";
             *      data[75] = "Golden Helmet/It's half of a golden coconut.\n\nProvides moderate rain protection./false/true";
             *  }
             * }*/
            if (!fullRedraw)
            {
                if (asset.AssetNameEquals("Characters/Farmer/farmer_girl_base"))
                {
                    if (drawUmbrella)
                    {
                        asset.AsImage().PatchImage(umbrellaTexture);
                    }
                    if (drawRegularFarmer)
                    {
                        asset.AsImage().PatchImage(regularFarmerTexture);
                    }
                }
                if (asset.AssetNameEquals("Characters/Farmer/farmer_base"))
                {
                    if (drawUmbrella)
                    {
                        asset.AsImage().PatchImage(umbrellaTexture);
                    }
                    if (drawRegularFarmer)
                    {
                        asset.AsImage().PatchImage(regularFarmerTexture);
                    }
                }
                if (asset.AssetNameEquals("Characters/Farmer/farmer_base_bald"))
                {
                    if (drawUmbrella)
                    {
                        asset.AsImage().PatchImage(umbrellaTexture);
                    }
                    if (drawRegularFarmer)
                    {
                        asset.AsImage().PatchImage(regularFarmerTexture);
                    }
                }
                if (asset.AssetNameEquals("Characters/Farmer/farmer_girl_base_bald"))
                {
                    if (drawUmbrella)
                    {
                        asset.AsImage().PatchImage(umbrellaTexture);
                    }
                    if (drawRegularFarmer)
                    {
                        asset.AsImage().PatchImage(regularFarmerTexture);
                    }
                }
            }
            else
            {
                if (asset.AssetNameEquals("Characters/Farmer/farmer_girl_base"))
                {
                    asset.AsImage().PatchImage(this.Helper.Content.Load <Texture2D>("assets/farmer_base_girl.png", ContentSource.ModFolder));
                }
                if (asset.AssetNameEquals("Characters/Farmer/farmer_base"))
                {
                    asset.AsImage().PatchImage(this.Helper.Content.Load <Texture2D>("assets/farmer_base_boy.png", ContentSource.ModFolder));
                }
                if (asset.AssetNameEquals("Characters/Farmer/farmer_base_bald"))
                {
                    asset.AsImage().PatchImage(this.Helper.Content.Load <Texture2D>("assets/farmer_base_boy_bald.png", ContentSource.ModFolder));
                }
                if (asset.AssetNameEquals("Characters/Farmer/farmer_girl_base_bald"))
                {
                    asset.AsImage().PatchImage(this.Helper.Content.Load <Texture2D>("assets/farmer_base_girl_bald.png", ContentSource.ModFolder));
                }
            }
        }
Beispiel #2
0
        // Initialize letters
        public void Edit <T>(IAssetData asset)
        {
            asset.AsDictionary <string, string>().Set("robin1", "Hey there @,^you've been such a good customer since you've arrived here in town. So I've decided to give you a " + ModEntry.DISC_1 + "% discount!^^See you soon,^   -Robin, your favorite carpenter");
            asset.AsDictionary <string, string>().Set("robin2", "Hi @,^since you've been such a good friend (and customer!) to me, I've decided to give you a " + ModEntry.DISC_2 + "% discount!^^See you soon,^   -Robin, your favorite carpenter (and friend!)");
            asset.AsDictionary <string, string>().Set("robin3", "Hi! I'm really happy to be your friend, @!^From now on, whenever you go shopping at my place, I'll give you " + ModEntry.DISC_3 + "% off!^^I hope you swing by soon! I'll get all your stuff built in no time!^   -Robin, your friend and favorite carpenter");
            asset.AsDictionary <string, string>().Set("robinMaru", "Hey @,^since we're family now, I thought I should give you another discount of " + ModEntry.BONUS_DISC + "% at my store. Take good care of my kid!^^Love,^   -Robin");
            asset.AsDictionary <string, string>().Set("robinSebastian", "Hey @,^since we're family now, I thought I should give you another discount of " + ModEntry.BONUS_DISC + "% at my store. Take good care of my kid!^^Love,^   -Robin");

            asset.AsDictionary <string, string>().Set("marnie1", "Hey there @,^thank you for being such a good customer. Since you're going to be a regular, I've decided to give you " + ModEntry.DISC_1 + "% off for all your next purchases!^^Have a nice day,^   -Marnie");
            asset.AsDictionary <string, string>().Set("marnie2", "Hello @, my Aunt made me write this because she's busy. Anyway, she wants you to know that you're really nice or something and that she's giving you another discount. Not even sure if we can afford it. Come buy some hay or something. It's " + ModEntry.DISC_2 + "% off.^   -Shane");
            asset.AsDictionary <string, string>().Set("marnie3", "Hey dear,^you've been a really good friend and I'm really glad we're neighbours! Let me tell you something. From now on, you get " + ModEntry.DISC_3 + "% off of all the things you buy from me!^^Talk to you soon,^   -Marnie");
            asset.AsDictionary <string, string>().Set("marnieShane", "Hey @,^thought I should write you a letter. I want you to get a discount on my chickens. I talked to my Aunt and discussed it with her and she said she's fine with it. So we'll give you " + ModEntry.BONUS_DISC + "% on the chickens.^^Have a nice day,^   -Shane");

            asset.AsDictionary <string, string>().Set("pierre1", "Dear valued customer,^Thanks for choosing 'Pierre's', your local produce shoppe! Your loyalty is very appreciated. We are happy to announce that from now on, you will receive a rebate of " + ModEntry.DISC_1 + "% whenever you visit our store. See you soon!^   -Pierre^^P.S. Sorry for the stock message, @. Enjoy!");
            asset.AsDictionary <string, string>().Set("pierre2", "Dear valued customer,^Thanks for choosing 'Pierre's', your local produce shoppe! Your loyalty is very appreciated. We are happy to announce that from now on, you will receive a rebate of " + ModEntry.DISC_2 + "% whenever you visit our store. See you soon!^   -Pierre^^P.S. Sorry for the stock message, @. I'm really busy these days. Enjoy!");
            asset.AsDictionary <string, string>().Set("pierre3", "Dear valued customer,^Thanks for choosing 'Pierre's', your local produce shoppe! Your loyalty is very appreciated. We are happy to announce that from now on, you will receive a rebate of " + ModEntry.DISC_3 + "% whenever you visit our store. See you soon!^   -Pierre^^P.S. Sorry for the stock message, @. How are you, by the way? I'm doing quite well myself, haha! Enjoy!");
            asset.AsDictionary <string, string>().Set("pierreAbigail", "Hey, @!^Since we're kind of family now, Caroline made me give you a " + ModEntry.BONUS_DISC + "% discount on the store.  Anyway, I know Abby is a little wild, but she has a good heart. Treat her well.^^Take care,^   -Pierre");
            asset.AsDictionary <string, string>().Set("pierreCaroline", "Hey, @, I didn't know you were best friends with my wife. She told me to give you a " + ModEntry.BONUS_DISC + "% discount in our shop yesterday. You better stop by and shop often from now on!^^See you soon,^   -Pierre");

            asset.AsDictionary <string, string>().Set("harvey1", "Hello, @!^You've been a valued customer at my clinic. So I've decided to give you a " + ModEntry.DISC_1 + "% discount for my OTC medicine. Have a nice day!^   -Harvey^^PS: Don't forget to cover your mouth when you sneeze! Wash your hands often!");
            asset.AsDictionary <string, string>().Set("harvey2", "Hello, @!^I'm so glad to have a friend in town. If you need tonics or remedies, just come by the clinic. I'll give you a " + ModEntry.DISC_2 + "% discount. See you soon!^   -Harvey^^PS: Don't forget to cover your mouth when you sneeze! Wash your hands often! If you need anything, just visit the clinic.");
            asset.AsDictionary <string, string>().Set("harvey3", "Hello, @!^You've been such a good friend to me since you've arrived in town. If you need anything, just visit the clinic. I can give you a check-up before you go into the mines if you want. Oh and you get a " + ModEntry.DISC_3 + "% discount for my OTC medicines.^^Take care.^   -Harvey^^PS: Don't forget to cover your mouth when you sneeze! Wash your hands often! Don't forget to eat well! Oh, and don't overwork yourself.");
            asset.AsDictionary <string, string>().Set("harveyMarried", "Hey darling, I'm writing from my office because I forgot to tell you yesterday. Since we're married now, I'd like you to have a " + ModEntry.BONUS_DISC + "% discount on my over-the-counter medicines. It's not much, but I hope it helps you when you run off to the mines again.^^Take care,^   -your husband");

            asset.AsDictionary <string, string>().Set("gus1", "Hello, @!^Since you've become a regular at my place, I'll give you " + ModEntry.DISC_1 + "% off! Come by the Stardrop Saloon when you need any refreshments. I make different dishes every week!^   -Gus");
            asset.AsDictionary <string, string>().Set("gus2", "Hey there, @,^thanks for being a loyal friend and customer. I really appreciate you coming by so often. Listening to your stories is never dull, haha! Anyway, I want to give you " + ModEntry.DISC_2 + "% off when you buy refreshments at the bar.^^See you soon!^   -Gus");
            asset.AsDictionary <string, string>().Set("gus3", "Hey, @!^I'm really glad you moved into town. Want to hear great news? I went through the numbers and am now able to give you your deserved " + ModEntry.DISC_3 + "% rebate for everything you purchase at my Saloon! I hope you come by more often from now on.^   -Your friend Gus");

            asset.AsDictionary <string, string>().Set("clint1", "Hello, @^thanks for coming by my shop so often. You know what, I'll give you " + ModEntry.DISC_1 + "% off from now on. If you need your tools upgraded, I'm your man. You know, being a blacksmith and all. Anyway. Bye.^   -Clint");
            asset.AsDictionary <string, string>().Set("clint2", "Hey, @^thanks for helping me with Emily the other day. Even though it didn't help. Anyway, I wanted to tell you that you'll get a " + ModEntry.DISC_2 + "% discount on your upgrades and my shop. Take care.^   -Clint");
            asset.AsDictionary <string, string>().Set("clint3", "Hey, @!^You're really hitting the mines! Thanks to you, my business is going quite well. So well actually, that I can give you " + ModEntry.DISC_3 + "% off from now on! Don't tell anyone. Take care.^   -Clint");

            asset.AsDictionary <string, string>().Set("sandy1", "Hello, hello, sweetie! I'm so glad you come by so often, It's so boring out here. Just me and the heat and those coconuts...^Anyway, I'll give you " + ModEntry.DISC_1 + "% off, so come by more often, and buy lots of seeds! Bye, kid!^   ~Sandy^^PS: Please say hi to Emily from me!");
            asset.AsDictionary <string, string>().Set("sandy2", "Hi!~ How are you, sweetie? I'm writing you this because you're such a good friend. See, I've been doing better thanks to you! Come and get your " + ModEntry.DISC_2 + "% off now! Just kidding. But seriously, it's so boring and hot here. Come visit me!^And buy a bunch of seeds!^   ~Sandy^^PS: Say hi to Emily! She hasn't been here in ages!");
            asset.AsDictionary <string, string>().Set("sandy3", "Hey, hey! It's your bestie Sandy from the desert!^Hope the valley is cooler than here, hehe!^You know that you're a valued customer and friend, right? You should come by more often. I'll give you a " + ModEntry.DISC_3 + "% discount! Nothing happens out here, it's depressing, really. Anyway, see you soon, honey!^   ~Sandy^^PS: Greet Emily for me, will you!");

            asset.AsDictionary <string, string>().Set("willy1", "Hey there, @,^thanks for dropping by so often. I've considered expanding my shop, but let's leave that for now. I've decided to give you a " + ModEntry.DISC_1 + "% discount since you've been such a loyal customer. Take care.^   -Willy");
            asset.AsDictionary <string, string>().Set("willy2", "Hey there, fellow fishing enthusiast! Glad you decided to come here. If you ever need a new fishing pole or bait, swing by my shop by the beach, I'll give you " + ModEntry.DISC_2 + "% off!^^Have fun fishing and good luck!^   -Willy");
            asset.AsDictionary <string, string>().Set("willy3", "Hello, @!^The ocean's been exciting the past few days, fishing-wise!^The local fishing-community has expanded quite a lot since you've arrived here. I want to thank you by giving you a " + ModEntry.DISC_3 + "% discount in my shop. Have fun fishing!^   -Willy");

            String dwarfDisc1 = "a tenth";
            String dwarfDisc2 = "a quarter";
            String dwarfDisc3 = "a half";

            if (ModEntry.DISC_1 == 10)
            {
                dwarfDisc1 = "a tenth";
            }
            else if (ModEntry.DISC_1 == 20)
            {
                dwarfDisc1 = "a fifth";
            }
            else if (ModEntry.DISC_1 == 25)
            {
                dwarfDisc1 = "a quarter";
            }
            else if (ModEntry.DISC_1 == 50)
            {
                dwarfDisc1 = "a half";
            }
            else if (ModEntry.DISC_1 == 75)
            {
                dwarfDisc1 = "a three-quart";
            }
            else
            {
                dwarfDisc1 = ModEntry.DISC_1 + "%";
            }

            if (ModEntry.DISC_2 == 10)
            {
                dwarfDisc2 = "a tenth";
            }
            else if (ModEntry.DISC_2 == 20)
            {
                dwarfDisc2 = "a fifth";
            }
            else if (ModEntry.DISC_2 == 25)
            {
                dwarfDisc2 = "a quarter";
            }
            else if (ModEntry.DISC_2 == 50)
            {
                dwarfDisc2 = "a half";
            }
            else if (ModEntry.DISC_2 == 75)
            {
                dwarfDisc2 = "a three-quart";
            }
            else
            {
                dwarfDisc2 = ModEntry.DISC_2 + "%";
            }

            if (ModEntry.DISC_3 == 10)
            {
                dwarfDisc3 = "a tenth";
            }
            else if (ModEntry.DISC_3 == 20)
            {
                dwarfDisc3 = "a fifth";
            }
            else if (ModEntry.DISC_3 == 25)
            {
                dwarfDisc3 = "a quarter";
            }
            else if (ModEntry.DISC_3 == 50)
            {
                dwarfDisc3 = "a half";
            }
            else if (ModEntry.DISC_3 == 75)
            {
                dwarfDisc3 = "a three-quart";
            }
            else
            {
                dwarfDisc3 = ModEntry.DISC_3 + "%";
            }

            asset.AsDictionary <string, string>().Set("dwarf1", "I don't trust you, but you're a good customer. Keep " + dwarfDisc1 + " when you buy at my shop in the mines.");
            asset.AsDictionary <string, string>().Set("dwarf2", "I have lots of things for your mining pleasure, human. You can keep " + dwarfDisc2 + ".");
            asset.AsDictionary <string, string>().Set("dwarf3", "Come by my shop any time. The mine is lonely. You can keep " + dwarfDisc3 + " of your money when shopping.");

            asset.AsDictionary <string, string>().Set("krobus1", "You are not like other humans. You are very friendly. I will give you " + dwarfDisc1 + " for that.^   -Krobus");
            asset.AsDictionary <string, string>().Set("krobus2", "You are special, human. I get few visitors, and you're the good kind. Keep " + dwarfDisc2 + " when you shop.^   -Krobus");
            asset.AsDictionary <string, string>().Set("krobus3", "You are a good ... nlakh. What do humans call it? I believe the right word is 'fiend'. Thank you, @. I will grant you " + dwarfDisc3 + " of the price.^   -Krobus");

            asset.AsDictionary <string, string>().Set("wizard1", "Greetings, young adept.^It is time. I have foreseen what must be done and that you will be in need of my help. In other words, I'll give you a " + ModEntry.DISC_1 + "% discount when the time comes.^   -M. Rasmodius, Wizard");
            asset.AsDictionary <string, string>().Set("wizard2", "Greetings, young adept.^The spirits have changed their minds. You are in need of a greater discount when the time has arrived! I'll give you " + ModEntry.DISC_2 + "% off.^   -M. Rasmodius, Wizard");
            asset.AsDictionary <string, string>().Set("wizard3", "Greetings, young adept.^My arcane powers have increased. I have foreseen that I must grant you " + ModEntry.DISC_3 + "% off in total if the prophecies are to be fulfilled. Beware!^   -M. Rasmodius, Wizard");
        }
Beispiel #3
0
        /// <summary>Edit a matched asset.</summary>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
        public void Edit <T>(IAssetData asset)
        {
            var text = this.translations;

            // get dwarf discount terms
            string dwarfDisc1 = this.GetDwarfDiscountTerm(ModEntry.DISC_1);
            string dwarfDisc2 = this.GetDwarfDiscountTerm(ModEntry.DISC_2);
            string dwarfDisc3 = this.GetDwarfDiscountTerm(ModEntry.DISC_3);

            // inject letters
            var data = asset.AsDictionary <string, string>().Data;

            data["robin1"]         = text.Get("letter.robin1", new { discount = ModEntry.DISC_1 });
            data["robin2"]         = text.Get("letter.robin2", new { discount = ModEntry.DISC_2 });
            data["robin3"]         = text.Get("letter.robin3", new { discount = ModEntry.DISC_3 });
            data["robinMaru"]      = text.Get("letter.robin-maru", new { discount = ModEntry.BONUS_DISC });
            data["robinSebastian"] = text.Get("letter.robin-sebastian", new { discount = ModEntry.BONUS_DISC });

            data["marnie1"]     = text.Get("letter.marnie1", new { discount = ModEntry.DISC_1 });
            data["marnie2"]     = text.Get("letter.marnie2", new { discount = ModEntry.DISC_2 });
            data["marnie3"]     = text.Get("letter.marnie3", new { discount = ModEntry.DISC_3 });
            data["marnieShane"] = text.Get("letter.marnie-shane", new { discount = ModEntry.BONUS_DISC });

            data["pierre1"]        = text.Get("letter.pierre1", new { discount = ModEntry.DISC_1 });
            data["pierre2"]        = text.Get("letter.pierre2", new { discount = ModEntry.DISC_2 });
            data["pierre3"]        = text.Get("letter.pierre3", new { discount = ModEntry.DISC_3 });
            data["pierreAbigail"]  = text.Get("letter.pierre-abigail", new { discount = ModEntry.BONUS_DISC });
            data["pierreCaroline"] = text.Get("letter.pierre-caroline", new { discount = ModEntry.BONUS_DISC });

            data["harvey1"]       = text.Get("letter.harvey1", new { discount = ModEntry.DISC_1 });
            data["harvey2"]       = text.Get("letter.harvey2", new { discount = ModEntry.DISC_2 });
            data["harvey3"]       = text.Get("letter.harvey3", new { discount = ModEntry.DISC_3 });
            data["harveyMarried"] = text.Get("letter.harvey-married", new { discount = ModEntry.BONUS_DISC });

            data["gus1"] = text.Get("letter.gus1", new { discount = ModEntry.DISC_1 });
            data["gus2"] = text.Get("letter.gus2", new { discount = ModEntry.DISC_2 });
            data["gus3"] = text.Get("letter.gus3", new { discount = ModEntry.DISC_3 });

            data["clint1"] = text.Get("letter.clint1", new { discount = ModEntry.DISC_1 });
            data["clint2"] = text.Get("letter.clint2", new { discount = ModEntry.DISC_2 });
            data["clint3"] = text.Get("letter.clint3", new { discount = ModEntry.DISC_3 });

            data["sandy1"] = text.Get("letter.sandy1", new { discount = ModEntry.DISC_1 });
            data["sandy2"] = text.Get("letter.sandy2", new { discount = ModEntry.DISC_2 });
            data["sandy3"] = text.Get("letter.sandy3", new { discount = ModEntry.DISC_3 });

            data["willy1"] = text.Get("letter.willy1", new { discount = ModEntry.DISC_1 });
            data["willy2"] = text.Get("letter.willy2", new { discount = ModEntry.DISC_2 });
            data["willy3"] = text.Get("letter.willy3", new { discount = ModEntry.DISC_3 });

            data["dwarf1"] = text.Get("letter.dwarf1", new { discountTerm = dwarfDisc1 });
            data["dwarf2"] = text.Get("letter.dwarf2", new { discountTerm = dwarfDisc2 });
            data["dwarf3"] = text.Get("letter.dwarf3", new { discountTerm = dwarfDisc3 });

            data["krobus1"] = text.Get("letter.krobus1", new { discountTerm = dwarfDisc1 });
            data["krobus2"] = text.Get("letter.krobus2", new { discountTerm = dwarfDisc2 });
            data["krobus3"] = text.Get("letter.krobus3", new { discountTerm = dwarfDisc3 });

            data["wizard1"] = text.Get("letter.wizard1", new { discount = ModEntry.DISC_1 });
            data["wizard2"] = text.Get("letter.wizard2", new { discount = ModEntry.DISC_2 });
            data["wizard3"] = text.Get("letter.wizard3", new { discount = ModEntry.DISC_3 });
        }
Beispiel #4
0
        public void Edit <T>(IAssetData asset)
        {
            VoidshroomSpore.setIndex(); //get an item index for voidshroom spores if one isn't already set.
            CaveCarrotSeed.setIndex();
            CaveCarrot.setIndex();
            CaveCarrot.setCropIndex();
            if (asset.AssetNameEquals("Maps\\springobjects"))
            {
                IAssetDataForImage editor    = asset.AsImage();
                Texture2D          data      = editor.Data;
                Texture2D          texture2D = new Texture2D(Game1.graphics.GraphicsDevice, data.Width, Math.Max(data.Height, 4096));
                editor.ReplaceWith(texture2D);
                editor.PatchImage(data, new Rectangle?(), new Rectangle?(), PatchMode.Replace);
                try
                {
                    editor.PatchImage(TextureSet.voidShroomSpore, new Rectangle?(), new Rectangle?(this.objectRect(VoidshroomSpore.getIndex())), PatchMode.Replace);
                    editor.PatchImage(TextureSet.caveCarrotSeed, new Rectangle?(), new Rectangle?(this.objectRect(CaveCarrotSeed.getIndex())), PatchMode.Replace);
                }
                catch (Exception)
                {
                }
            }
            else if (asset.AssetNameEquals("Data\\ObjectInformation"))
            {
                IAssetDataForDictionary <int, string> editor = asset.AsDictionary <int, string>();

                IDictionary <int, string> data = editor.Data;
                if (!data.ContainsKey(VoidshroomSpore.getIndex()))
                {
                    int    voidShroomSporeIndex = VoidshroomSpore.getIndex();
                    String voidShroomSpore      = VoidshroomSpore.getObjectData();
                    this.log("Add voidshroom spore object data: " + voidShroomSporeIndex + ": " + voidShroomSpore);
                    data.Add(voidShroomSporeIndex, voidShroomSpore);
                }

                if (!data.ContainsKey(CaveCarrotSeed.getIndex()))
                {
                    int    caveCarrotSeedIndex = CaveCarrotSeed.getIndex();
                    String caveCarrotObject    = CaveCarrotSeed.getObjectData();
                    this.log("Add cave carrot seed object data: " + caveCarrotSeedIndex + ": " + caveCarrotObject);
                    data.Add(caveCarrotSeedIndex, caveCarrotObject);
                }

                if (!data.ContainsKey(CaveCarrotFlower.getIndex()))
                {
                    int    caveCarrotFlowerIndex  = CaveCarrotFlower.getIndex();
                    String caveCarrotFlowerObject = CaveCarrotFlower.getObjectData();
                    this.log("Add cave carrot flower 'seed' data: " + caveCarrotFlowerIndex + ": " + caveCarrotFlowerObject);
                    data.Add(caveCarrotFlowerIndex, caveCarrotFlowerObject);
                }
            }
            else if (asset.AssetNameEquals("Data\\Crops"))
            {
                IAssetDataForDictionary <int, string> editor = asset.AsDictionary <int, string>();
                IDictionary <int, string>             data   = editor.Data;

                int seedIndex = CaveCarrot.getIndex();
                this.log("seedIndex is: " + seedIndex);
                if (!data.ContainsKey(seedIndex))
                {
                    String cropData = CaveCarrot.getCropData();
                    this.monitor.Log("Loading crop data: " + cropData);
                    data.Add(CaveCarrot.getIndex(), cropData);
                }

                int caveCarrotFlowerIndex = CaveCarrotFlower.getIndex();
                this.log("seedIndex is: " + caveCarrotFlowerIndex);
                if (!data.ContainsKey(caveCarrotFlowerIndex))
                {
                    String cropData = CaveCarrotFlower.getCropData();
                    this.monitor.Log("Loading crop data: " + cropData);
                    data.Add(caveCarrotFlowerIndex, cropData);
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\crops"))
            {
                IAssetDataForImage editor    = asset.AsImage();
                Texture2D          data      = editor.Data;
                Texture2D          texture2D = new Texture2D(Game1.graphics.GraphicsDevice, data.Width, Math.Max(data.Height, 4096));
                editor.ReplaceWith(texture2D);
                editor.PatchImage(data, new Rectangle?(), new Rectangle?(), PatchMode.Replace);
                try
                {
                    int index = CaveCarrot.getCropIndex();
                    this.monitor.Log("Loading cave carrot crop texture.  Crop index: " + index);
                    editor.PatchImage(TextureSet.caveCarrotCrop, new Rectangle?(), new Rectangle?(this.cropRect(index)), PatchMode.Replace);

                    index = CaveCarrotFlower.getCropIndex();
                    this.monitor.Log("Loading cave carrot flower crop texture.  Crop index: " + index);
                    editor.PatchImage(TextureSet.caveCarrotFlowerCrop, new Rectangle?(), new Rectangle?(this.cropRect(index)), PatchMode.Replace);
                }
                catch (Exception)
                {
                }
            }
        }
Beispiel #5
0
        public void Edit <T>(IAssetData asset)
        {
            if (!Mod.instance.didInit)
            {
                return;
            }

            if (asset.AssetNameEquals("Data\\NPCGiftTastes"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                // TODO: This could be optimized from mn to... m + n?
                // Basically, iterate through objects and create Dictionary<NPC name, GiftData[]>
                // Iterate through objects, each section and add to dict[npc][approp. section]
                // Point is, I'm doing this the lazy way right now
                var newData = new Dictionary <string, string>(data);
                foreach (var npc in data)
                {
                    if (npc.Key.StartsWith("Universal_"))
                    {
                        continue;
                    }

                    string[] sections = npc.Value.Split('/');
                    if (sections.Length != 11)
                    {
                        Log.warn($"Bad gift taste data for {npc.Key}!");
                        continue;
                    }

                    string        loveStr    = sections[0];
                    List <string> loveIds    = new List <string>(sections[1].Split(' '));
                    string        likeStr    = sections[2];
                    List <string> likeIds    = new List <string>(sections[3].Split(' '));
                    string        dislikeStr = sections[4];
                    List <string> dislikeIds = new List <string>(sections[5].Split(' '));
                    string        hateStr    = sections[6];
                    List <string> hateIds    = new List <string>(sections[7].Split(' '));
                    string        neutralStr = sections[8];
                    List <string> neutralIds = new List <string>(sections[9].Split(' '));

                    foreach (var obj in Mod.instance.objects)
                    {
                        if (obj.GiftTastes == null)
                        {
                            continue;
                        }
                        if (obj.GiftTastes.Love != null && obj.GiftTastes.Love.Contains(npc.Key))
                        {
                            loveIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Like != null && obj.GiftTastes.Like.Contains(npc.Key))
                        {
                            likeIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Neutral != null && obj.GiftTastes.Neutral.Contains(npc.Key))
                        {
                            neutralIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Dislike != null && obj.GiftTastes.Dislike.Contains(npc.Key))
                        {
                            dislikeIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Hate != null && obj.GiftTastes.Hate.Contains(npc.Key))
                        {
                            hateIds.Add(obj.GetObjectId().ToString());
                        }
                    }

                    string loveIdStr    = string.Join(" ", loveIds);
                    string likeIdStr    = string.Join(" ", likeIds);
                    string dislikeIdStr = string.Join(" ", dislikeIds);
                    string hateIdStr    = string.Join(" ", hateIds);
                    string neutralIdStr = string.Join(" ", neutralIds);
                    newData[npc.Key] = $"{loveStr}/{loveIdStr}/{likeStr}/{likeIdStr}/{dislikeStr}/{dislikeIdStr}/{hateStr}/{hateIdStr}/{neutralStr}/{neutralIdStr}/ ";

                    Log.verbose($"Adding gift tastes for {npc.Key}: {newData[npc.Key]}");
                }
                asset.ReplaceWith(newData);
            }
        }
Beispiel #6
0
        private void EditAsset(ref IAssetData asset)
        {
            if (ModEntry.PrintRename)
            {
                Log.D($"Editing {asset.AssetName}",
                      ModEntry.Instance.Config.DebugMode);
            }
            if (asset.AssetNameEquals(@"Data/Bundles"))
            {
                // Make no changes for the new community centre bundle, but set our base values from the data
                // Do this even with community centre changes disabled, in case we join as farmhand to a player who has it enabled

                var data = asset.AsDictionary <string, string>().Data;
                Bundles.BundleStartIndex = 1 + data.Keys.ToList().Max(key => int.Parse(key.Split('/')[1]));
            }
            else if (asset.AssetNameEquals(@"Data/BigCraftablesInformation"))
            {
                var data = asset.AsDictionary <int, string>().Data;

                // Add localised names for new craftables
                foreach (var pair in data.Where(pair => pair.Value.Split('/')[0].StartsWith(ModEntry.ObjectPrefix)).ToList())
                {
                    var split    = pair.Value.Split('/');
                    var name     = split[0].Split(new[] { '.' }, 3);
                    var nameData = data[pair.Key];
                    split[4]       = i18n.Get($"item.{name[2]}.description").ToString();
                    split[8]       = i18n.Get($"item.{name[2]}.name").ToString();
                    data[pair.Key] = string.Join("/", split);
                    if (ModEntry.PrintRename)
                    {
                        Log.D($"Named craftable {name[2]} ({data[pair.Key].Split('/')[5]})", ModEntry.Instance.Config.DebugMode);
                    }
                }

                asset.AsDictionary <int, string>().ReplaceWith(data);
            }
            else if (asset.AssetNameEquals(@"Data/CookingRecipes"))
            {
                // Edit fields of vanilla recipes to use new ingredients

                if (ModEntry.JsonAssets == null || Game1.currentLocation == null)
                {
                    return;
                }

                var data = asset.AsDictionary <string, string>().Data;

                // Add localised names for new recipes
                // While this also happens in CookingMenu.ctor for English locales, it's efficient here for other locales
                foreach (var pair in data.Where(pair => pair.Key.StartsWith(ModEntry.ObjectPrefix)).ToList())
                {
                    var name     = pair.Key.Split(new[] { '.' }, 3);
                    var nameData = data[pair.Key];
                    var split    = new string[6];
                    data[pair.Key].Split('/').CopyTo(split, 0);
                    split[5]       = i18n.Get($"item.{name[2]}.name").ToString();
                    data[pair.Key] = string.Join("/", split);
                    if (ModEntry.PrintRename)
                    {
                        Log.D($"Named recipe {name[2]} ({data[pair.Key].Split('/')[5]})", ModEntry.Instance.Config.DebugMode);
                    }
                }
                asset.AsDictionary <string, string>().ReplaceWith(data);

                if (!Config.AddRecipeRebalancing)
                {
                    Log.D($"Did not edit {asset.AssetName}: New recipe scaling is disabled in config file.",
                          Config.DebugMode);
                    return;
                }

                try
                {
                    // Substitute in the actual custom ingredients for custom recipes if custom ingredients are enabled
                    var enabled = Config.AddNewCropsAndStuff;
                    Dictionary <string, string> recipeData = null;
                    if (enabled || ModEntry.UsingPPJACrops)
                    {
                        // Update recipe data for recipes planned to use vanilla objects or best-available common custom objects
                        recipeData = new Dictionary <string, string>
                        {
                            // Maki Roll: Sashimi 1 Seaweed 1 Rice 1
                            {
                                "Maki Roll",
                                "227 1 152 1 423 1"
                            },
                            // Coleslaw: Vinegar 1 Mayonnaise 1
                            {
                                "Coleslaw",
                                $"{ModEntry.JsonAssets.GetObjectId(ModEntry.CabbageName)} 1"
                                + " 419 1 306 1"
                            },
                            // Cookies: Flour 1 Category:Egg 1 Chocolate Bar 1
                            {
                                "Cookies",
                                "246 1 -5 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.ChocolateName)} 1"
                            },
                            // Pizza: Flour 2 Tomato 2 Cheese 2
                            {
                                "Pizza",
                                "246 2 256 2 424 2"
                            },
                        };

                        // Update recipe data for recipes planned to use custom objects exclusive to this mod
                        if (enabled)
                        {
                            var exclusiveCustomData = new Dictionary <string, string>
                            {
                                // Pink Cake: Cake 1 Melon 1
                                {
                                    "Pink Cake",
                                    $"{ModEntry.JsonAssets.GetObjectId(ModEntry.ObjectPrefix + "cake")} 1"
                                    + " 254 1"
                                },
                                // Chocolate Cake: Cake 1 Chocolate Bar 1
                                {
                                    "Chocolate Cake",
                                    $"{ModEntry.JsonAssets.GetObjectId(ModEntry.ObjectPrefix + "cake")} 1"
                                    + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.ChocolateName)} 1"
                                }
                            };
                            recipeData = recipeData.Union(exclusiveCustomData).ToDictionary(pair => pair.Key, pair => pair.Value);
                        }

                        foreach (var recipe in recipeData)
                        {
                            data[recipe.Key] = ModEntry.UpdateEntry(data[recipe.Key], new[] { recipe.Value });
                        }

                        if (ModEntry.PrintRename && recipeData != null)
                        {
                            Log.D(data.Where(pair => recipeData.ContainsKey(pair.Key))
                                  .Aggregate($"Edited {asset.AssetName}:", (s, pair) => $"{s}\n{pair.Key}: {pair.Value}"),
                                  ModEntry.Instance.Config.DebugMode);
                        }

                        recipeData = new Dictionary <string, string>
                        {
                            // Beet Burger: Bread 1 Beet 1 Onion 1 Red Cabbage 1
                            {
                                ModEntry.ObjectPrefix + "burger",
                                "216 1 284 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.OnionName)} 1"
                                + " 266 1"
                            },
                            // Cabbage Pot: Cabbage 2 Onion 2
                            {
                                ModEntry.ObjectPrefix + "cabbagepot",
                                $"{ModEntry.JsonAssets.GetObjectId(ModEntry.CabbageName)} 2"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.OnionName)} 2"
                            },
                            // Garden Pie: Flour 1 Cabbage 1 Onion 1 Tomato 1
                            {
                                ModEntry.ObjectPrefix + "gardenpie",
                                "246 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.CabbageName)} 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.OnionName)} 1"
                                + " 256 1"
                            },
                            // Hearty Stew: Carrot 2 Potato 1
                            {
                                ModEntry.ObjectPrefix + "stew",
                                $"{ModEntry.JsonAssets.GetObjectId(ModEntry.CarrotName)} 2"
                                + " 192 1"
                            },
                            // Hot Cocoa: Milk (Any) 1 Chocolate Bar 1
                            {
                                ModEntry.ObjectPrefix + "hotcocoa",
                                "-6 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.ChocolateName)} 1"
                            },
                            // Hot Pot Roast: Cranberry Sauce 1 Roots Platter 1 Stuffing 1 Onion 1
                            {
                                ModEntry.ObjectPrefix + "roast",
                                "238 1 244 1 239 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.OnionName)} 1"
                            },
                            // Hunter's Plate: Potato 1 Cabbage 1 Horseradish 1
                            {
                                ModEntry.ObjectPrefix + "hunters",
                                "192 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.CabbageName)} 1"
                                + " 16 1"
                            },
                            // Kebab: Tortilla 1 Tomato 1 Cabbage 1
                            {
                                ModEntry.ObjectPrefix + "kebab",
                                "229 1 256 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.CabbageName)} 1"
                            },
                            // Onion Soup: Onion 1 Garlic 1 Cheese 1
                            {
                                ModEntry.ObjectPrefix + "onionsoup",
                                $"{ModEntry.JsonAssets.GetObjectId(ModEntry.OnionName)} 1"
                                + " 248 1 424 1"
                            },
                            // Pineapple Skewers: Pineapple 1 Onion 1 Eggplant 1
                            {
                                ModEntry.ObjectPrefix + "skewers",
                                "832 1"
                                + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.OnionName)} 1"
                                + " 272 1"
                            },
                            // Redberry Pie: Flour 1 Sugar 1 Redberries 3

                            /*{
                             *      ModEntry.ObjectPrefix + "redberrypie",
                             *      "246 1 245 1"
                             + $" {ModEntry.JsonAssets.GetObjectId(ModEntry.ObjectPrefix + "redberry")} 3"
                             + },*/
                            // Tropical Salad: Pineapple 1 Apple 1 Pomegranate 1
                            {
                                ModEntry.ObjectPrefix + "tropicalsalad",
                                "832 1 613 1 637 1"
                            },
                        };
                        if (recipeData != null)
                        {
                            foreach (var recipe in recipeData)
                            {
                                data[recipe.Key] = ModEntry.UpdateEntry(data[recipe.Key], new[] { recipe.Value });
                            }
                        }
                    }

                    foreach (var recipe in data.ToDictionary(pair => pair.Key, pair => pair.Value))
                    {
                        var recipeSplit = data[recipe.Key].Split('/');

                        // Remove Oil from all cooking recipes in the game
                        var ingredients = recipeSplit[0].Split(' ');
                        if (!ingredients.Contains("247"))
                        {
                            continue;
                        }

                        recipeSplit[0] = ModEntry.UpdateEntry(recipeSplit[0],
                                                              ingredients.Where((ingredient, i) =>
                                                                                ingredient != "247" && (i <= 0 || ingredients[i - 1] != "247")).ToArray(),
                                                              false, true, 0, ' ');
                        data[recipe.Key] = ModEntry.UpdateEntry(data[recipe.Key], recipeSplit, false, true);
                    }

                    asset.AsDictionary <string, string>().ReplaceWith(data);

                    if (ModEntry.PrintRename && recipeData != null)
                    {
                        Log.D(data.Where(pair => recipeData.ContainsKey(pair.Key))
                              .Aggregate($"Edited {asset.AssetName}:", (s, pair) => $"{s}\n{pair.Key}: {pair.Value}"),
                              ModEntry.Instance.Config.DebugMode);
                    }

                    Log.D(data.Aggregate("", (str, recipe) => $"{str}\n{recipe.Key}: {recipe.Value}"),
                          Config.DebugMode);
                }
                catch (Exception e) when(e is ArgumentException || e is NullReferenceException || e is KeyNotFoundException)
                {
                    Log.D($"Did not patch {asset.AssetName}: {(!Config.DebugMode ? e.Message : e.ToString())}",
                          Config.DebugMode);
                }

                return;
            }

            if (asset.AssetNameEquals(@"Data/mail"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                data.Add(ModEntry.MailCookbookUnlocked, i18n.Get("mail.cookbook_unlocked"));

                // lol pan
                var whoops = "Umm, hello @."
                             + $"^There was a mix-up at the forge with your {i18n.Get("menu.cooking_equipment.name")}."
                             + $" This is a bit embarrassing, so I'll return your materials as an apology."
                             + "^Come back to the shop and we'll see about getting you that upgrade."
                             + "^ - Clint, the blacksmith"
                             + "^^^                     $ 1000g"
                             + " %item object 334 5 %% [#] Love of Cooking Meta Menu Mix-Up";
                data.Add(ModEntry.MailFryingPanWhoops, whoops);

                asset.ReplaceWith(data);

                return;
            }

            if (asset.AssetNameEquals(@"Data/ObjectInformation"))
            {
                // Edit fields of vanilla objects to revalue and recategorise some produce

                if (ModEntry.JsonAssets == null || ModEntry.IngredientBuffChart == null || Game1.currentLocation == null)
                {
                    return;
                }

                var data = asset.AsDictionary <int, string>().Data;

                // Add localised names and descriptions for new objects
                foreach (var pair in data.Where(pair => pair.Value.Split('/') is string[] split && split[0].StartsWith(ModEntry.ObjectPrefix)).ToList())
                {
                    var name = pair.Value.Split('/')[0].Split(new [] { '.' }, 3);
                    data[pair.Key] = ModEntry.UpdateEntry(data[pair.Key],
                                                          new[] { i18n.Get($"item.{name[2]}.name").ToString(),
                                                                  i18n.Get($"item.{name[2]}.description").ToString() },
                                                          false, false, 4);
                    if (ModEntry.PrintRename)
                    {
                        Log.D($"Named {name[2]} ({i18n.Get($"item.{name[2]}.name")})", ModEntry.Instance.Config.DebugMode);
                    }
                }
                asset.AsDictionary <int, string>().ReplaceWith(data);

                if (!Config.AddRecipeRebalancing)
                {
                    Log.D($"Did not edit {asset.AssetName}: New recipe scaling is disabled in config file.",
                          Config.DebugMode);
                    return;
                }

                try
                {
                    var objectData = new Dictionary <int, string[]>
                    {
                        { 206, new[] { null, null, "45" } },                                                          // Pizza
                        { 220, new[] { null, null, "60" } },                                                          // Chocolate Cake
                        { 221, new[] { null, null, "75" } },                                                          // Pink Cake
                        { 419, new[] { null, "220", "-300", "Basic -26" } },                                          // Vinegar
                        { 247, new[] { null, null, "-300", "Basic -26", null, i18n.Get("item.oil.description") } },   // Oil
                        { 432, new[] { null, null, "-300", null, null, i18n.Get("item.truffleoil.description") } },   // Truffle Oil
                        { 917, new[] { null, null, null, null, null, data[917].Split('/')[5].Split('.')[0] + '.' } }, // Qi Seasoning
                        //{ModEntry.JsonAssets.GetObjectId(ObjectPrefix + "sugarcane"), new[] {null, null, null, "Basic"}},
                    };

                    // Apply above recipe changes
                    foreach (var obj in objectData.Where(o => !ModEntry.ItemDefinitions["FoodsThatGiveLeftovers"].Contains(data[o.Key].Split('/')[0])))
                    {
                        data[obj.Key] = ModEntry.UpdateEntry(data[obj.Key], obj.Value);
                    }

                    if (Config.AddRecipeRebalancing)
                    {
                        RebuildBuffs(ref data);
                    }

                    asset.AsDictionary <int, string>().ReplaceWith(data);

                    if (ModEntry.PrintRename)
                    {
                        Log.D($"Edited {asset.AssetName}:" + data.Where(pair => objectData.ContainsKey(pair.Key))
                              .Aggregate("", (s, pair) => $"{s}\n{pair.Key}: {pair.Value}"),
                              ModEntry.Instance.Config.DebugMode);
                    }
                }
                catch (Exception e) when(e is ArgumentException || e is NullReferenceException || e is KeyNotFoundException)
                {
                    Log.D($"Did not patch {asset.AssetName}: {(!Config.DebugMode ? e.Message : e.ToString())}",
                          Config.DebugMode);
                }

                return;
            }

            if (asset.AssetNameEquals(@"Data/Events/Town"))
            {
                var data = asset.AsDictionary <string, string>().Data;

                var key   = data.Keys.FirstOrDefault(key => key.StartsWith("191393"));
                var value = data[key];
                data.Remove(key);
                data.Add("191393/n ccIsComplete/w sunny/H", value);

                asset.AsDictionary <string, string>().ReplaceWith(data);
            }

            if (asset.AssetNameEquals(@"Data/Monsters"))
            {
                if (ModEntry.JsonAssets == null || Game1.currentLocation == null)
                {
                    return;
                }
                if (!ModEntry.Instance.Config.AddNewCropsAndStuff)
                {
                    Log.D($"Did not edit {asset.AssetName}: New crops are disabled in config file.",
                          Config.DebugMode);
                    return;
                }
                if (!ModEntry.RedberriesEnabled)
                {
                    Log.D($"Did not edit {asset.AssetName}: Redberries not yet enabled in code.",
                          Config.DebugMode);
                    return;
                }

                try
                {
                    var data        = asset.AsDictionary <string, string>().Data;
                    var monsterData = new Dictionary <string, string[]>
                    {
                        { "Shadow Shaman", new[] { $"{ModEntry.JsonAssets.GetObjectId(ModEntry.ObjectPrefix + "redberry_seeds")} .0035"
                                                   + (ModEntry.NettlesEnabled ? $" {ModEntry.JsonAssets.GetObjectId(ModEntry.ObjectPrefix + "nettles")} .05" : "") } },
                        { "Wilderness Golem", new[] { $"{ModEntry.JsonAssets.GetObjectId(ModEntry.ObjectPrefix + "redberry_seeds")} .0065" } },
                        { "Mummy", new[] { $"{ModEntry.JsonAssets.GetObjectId(ModEntry.ObjectPrefix + "redberry_seeds")} .0022" } },
                        { "Pepper Rex", new[] { $"{ModEntry.JsonAssets.GetObjectId(ModEntry.ObjectPrefix + "redberry_seeds")} .02" } },
                    };
                    foreach (var monster in monsterData)
                    {
                        data[monster.Key] = ModEntry.UpdateEntry(data[monster.Key], monster.Value, append: true);
                    }

                    asset.AsDictionary <string, string>().ReplaceWith(data);

                    if (ModEntry.PrintRename)
                    {
                        Log.D($"Edited {asset.AssetName}:" + data.Where(pair => monsterData.ContainsKey(pair.Key))
                              .Aggregate("", (s, pair) => $"{s}\n{pair.Key}: {pair.Value}"),
                              ModEntry.Instance.Config.DebugMode);
                    }
                }
                catch (Exception e) when(e is ArgumentException || e is NullReferenceException || e is KeyNotFoundException)
                {
                    Log.D($"Did not patch {asset.AssetName}: {(!Config.DebugMode ? e.Message : e.ToString())}",
                          Config.DebugMode);
                }

                return;
            }

            if (asset.AssetNameEquals(@"LooseSprites/Cursors"))
            {
                // Home-cook a notification icon for under the HUD money tray:

                if (ModEntry.SpriteSheet == null)
                {
                    return;
                }

                // Prime a canvas as a clipboard to hold in sequence both a copy of the vanilla icon
                // and our custom icon to merge together into some particular open space in Cursors
                var data            = asset.AsImage().Data;
                var canvas          = new Color[NotificationIconTargetArea.Width * NotificationIconTargetArea.Height];
                var texture         = new Texture2D(Game1.graphics.GraphicsDevice, NotificationIconTargetArea.Width, NotificationIconTargetArea.Height);
                var vanillaIconArea = new Rectangle(383, 493, NotificationIconTargetArea.Width, NotificationIconTargetArea.Height);
                var targetArea      = NotificationIconTargetArea;

                // Patch in a copy of the vanilla quest log icon
                data.GetData(0, vanillaIconArea, canvas, 0, canvas.Length);
                texture.SetData(canvas);
                asset.AsImage().PatchImage(texture, null, targetArea, PatchMode.Replace);

                // Chroma-key our custom icon with colours from the vanilla icon
                var colorSampleA = canvas[NotificationIconTargetArea.Width * 5 + 1];
                var colorSampleB = canvas[NotificationIconTargetArea.Width * 11 + 1];

                var colorR = new Color(255, 0, 0);
                var colorC = new Color(255, 0, 255);
                var colorG = new Color(0, 255, 0);
                var colorA = new Color(0, 0, 0, 0);

                ModEntry.SpriteSheet.GetData(0, new Rectangle(0, 0, NotificationIconTargetArea.Width, NotificationIconTargetArea.Height), canvas, 0, canvas.Length);

                for (var i = 0; i < canvas.Length; ++i)
                {
                    if (canvas[i] == colorC)
                    {
                        canvas[i] = colorA;
                    }
                    else if (canvas[i] == colorG)
                    {
                        canvas[i] = colorSampleA;
                    }
                    else if (canvas[i] == colorR)
                    {
                        canvas[i] = colorSampleB;
                    }
                }

                // Patch in the custom icon over the vanilla icon copy
                texture.SetData(canvas);
                asset.AsImage().PatchImage(texture, null, targetArea, PatchMode.Overlay);

                // Patch in an alpha-shaded copy of the custom icon to use for the pulse animation
                var colorShade = new Color(0, 0, 0, 0.35f);

                for (var i = 0; i < canvas.Length; ++i)
                {
                    if (canvas[i] == colorSampleB)
                    {
                        canvas[i] = colorShade;
                    }
                    else if (canvas[i] == colorSampleA)
                    {
                        canvas[i] = colorA;
                    }
                }

                // Apply changes to the Cursors sheet
                texture.SetData(canvas);
                targetArea.X -= targetArea.Width;
                asset.AsImage().PatchImage(texture, null, targetArea, PatchMode.Overlay);
            }
            else if (asset.AssetNameEquals(@"LooseSprites/JunimoNote"))
            {
                // Add icons for a new community centre bundle

                if (!ModEntry.Instance.Config.AddCookingCommunityCentreBundles)
                {
                    Log.D($"Did not edit {asset.AssetName}: Community centre edits are disabled in config file.",
                          Config.DebugMode);
                    return;
                }

                var sourceArea = new Rectangle(160, 208, 32 * 3, 32);
                var destArea   = new Rectangle(544, 212, 32 * 3, 32);
                var destImage  = asset.AsImage();
                destImage.PatchImage(ModEntry.SpriteSheet, sourceArea, destArea, PatchMode.Replace);
                asset.ReplaceWith(destImage.Data);
            }
            else if (asset.AssetNameEquals(@"Maps/Beach") && false)
            {
                //if (!Config.AddCookingQuestline)
                {
                    Log.D($"Did not edit {asset.AssetName}: Cooking questline is disabled in config file.",
                          Config.DebugMode);
                    return;
                }

                // Add dock wares to the secret beach

                // . . .
            }
            else if (asset.AssetNameEquals(@"Maps/springobjects"))
            {
                // Patch in object icons where necessary

                if (ModEntry.JsonAssets == null)
                {
                    return;
                }

                if (true)
                {
                    return;
                }

                int       index;
                Rectangle sourceArea, destArea;
                var       destImage = asset.AsImage();

                // Pitta Bread
                index = ModEntry.JsonAssets.GetObjectId("Pitta Bread");
                if (index > 0)
                {
                    sourceArea = Game1.getSourceRectForStandardTileSheet(destImage.Data, 217, 16, 16);
                    destArea   = Game1.getSourceRectForStandardTileSheet(destImage.Data, index, 16, 16);
                    destImage.PatchImage(destImage.Data, sourceArea, destArea, PatchMode.Replace);
                }
                asset.ReplaceWith(destImage.Data);
            }
            else if (asset.AssetNameEquals(@"Maps/townInterior"))
            {
                // Patch in changes for the community centre

                if (!(Game1.currentLocation is StardewValley.Locations.CommunityCenter))
                {
                    return;
                }

                var image = asset.AsImage();

                // Openable fridge in the kitchen
                var destArea = Bundles.FridgeOpenedSpriteArea;                             // Target some unused area of the sheet for this location

                var sourceArea = new Rectangle(320, 224, destArea.Width, destArea.Height); // Apply base fridge sprite
                image.PatchImage(image.Data, sourceArea, destArea, PatchMode.Replace);

                sourceArea = new Rectangle(0, 192, 16, 32);                 // Patch in opened-door fridge sprite from mouseCursors sheet
                image.PatchImage(Game1.mouseCursors2, sourceArea, destArea, PatchMode.Overlay);

                // New star on the community centre bundle tracker wall
                if (!ModEntry.Instance.Config.AddCookingCommunityCentreBundles)
                {
                    Log.D($"Did not edit {asset.AssetName}: Community centre edits are disabled in config file.",
                          Config.DebugMode);
                }
                else
                {
                    sourceArea = new Rectangle(370, 705, 7, 7);
                    destArea   = new Rectangle(380, 710, sourceArea.Width, sourceArea.Height);
                    image.PatchImage(image.Data, sourceArea, destArea, PatchMode.Replace);
                }

                asset.ReplaceWith(image.Data);
            }
            else if (asset.AssetNameEquals(@"Strings/Locations"))
            {
                // Make changes to facilitate a new community centre bundle

                if (!ModEntry.Instance.Config.AddCookingCommunityCentreBundles)
                {
                    Log.D($"Did not edit {asset.AssetName}: Community centre edits are disabled in config file.",
                          Config.DebugMode);
                    return;
                }

                var data = asset.AsDictionary <string, string>().Data;

                // Add area name
                data["CommunityCenter_AreaName_" + Bundles.CommunityCentreAreaName] = i18n.Get("world.community_centre.kitchen");

                // Insert a new AreaCompletion line to account for our extra bundle
                const int newJunimoLineNumber = 3;
                for (var i = Bundles.CommunityCentreAreaNumber + 1; i > newJunimoLineNumber; --i)
                {
                    var below = data["CommunityCenter_AreaCompletion" + (i - 1)];
                    data["CommunityCenter_AreaCompletion" + i] = below;
                }
                data["CommunityCenter_AreaCompletion" + newJunimoLineNumber] = i18n.Get("world.community_centre.newjunimoline");

                asset.AsDictionary <string, string>().ReplaceWith(data);
            }
            else if (asset.AssetNameEquals(@"Strings/UI"))
            {
                // Make changes to facilitate a new community centre bundle

                if (!ModEntry.Instance.Config.AddCookingCommunityCentreBundles)
                {
                    Log.D($"Did not edit {asset.AssetName}: Community centre edits are disabled in config file.",
                          Config.DebugMode);
                    return;
                }

                var data = asset.AsDictionary <string, string>().Data;
                data["JunimoNote_Reward" + Bundles.CommunityCentreAreaName] = i18n.Get("world.community_centre.reward");
                asset.AsDictionary <string, string>().ReplaceWith(data);
            }
            else if (asset.AssetNameEquals(@"TileSheets/tools"))
            {
                // Patch in tool sprites for cooking equipment

                if (ModEntry.SpriteSheet == null)
                {
                    return;
                }

                if (!ModEntry.Instance.Config.AddCookingToolProgression)
                {
                    Log.D($"Did not edit {asset.AssetName}: Cooking equipment is disabled in config file.",
                          Config.DebugMode);
                    return;
                }

                var sourceArea = new Rectangle(192, 272, 16 * 4, 16);
                var destImage  = asset.AsImage();
                var destArea   = new Rectangle(272, 0, sourceArea.Width, sourceArea.Height);
                destImage.PatchImage(ModEntry.SpriteSheet, sourceArea, destArea, PatchMode.Replace);
                asset.ReplaceWith(destImage.Data);
            }
        }
Beispiel #7
0
        public void Edit <T>(IAssetData asset)
        {
            IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

            data["RegressionStart"] = "Dear @,^Welcome to town! Here are some veggies from the garden to tide you over while you move in! Also, sorry to be so forward, but living here might change you in ways you didn't expect. Just in case, I've also enclosed some... supplies. (You can buy more at Pierre's.) %item object 399 20 %% ^      <, Jodi";
        }
Beispiel #8
0
        public void Edit <T>(IAssetData asset)
        {
            if (asset.AssetNameEquals("Data\\ObjectInformation"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        Log.trace($"Injecting to objects: {obj.GetObjectId()}: {obj.GetObjectInformation()}");
                        data.Add(obj.GetObjectId(), obj.GetObjectInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting object information for {obj.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\Crops"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var crop in Mod.instance.crops)
                {
                    try
                    {
                        Log.trace($"Injecting to crops: {crop.GetSeedId()}: {crop.GetCropInformation()}");
                        data.Add(crop.GetSeedId(), crop.GetCropInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting crop for {crop.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\fruitTrees"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var fruitTree in Mod.instance.fruitTrees)
                {
                    try
                    {
                        Log.trace($"Injecting to fruit trees: {fruitTree.GetSaplingId()}: {fruitTree.GetFruitTreeInformation()}");
                        data.Add(fruitTree.GetSaplingId(), fruitTree.GetFruitTreeInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting fruit tree for {fruitTree.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\CookingRecipes"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        if (obj.Recipe == null)
                        {
                            continue;
                        }
                        if (obj.Category != ObjectData.Category_.Cooking)
                        {
                            continue;
                        }
                        Log.trace($"Injecting to cooking recipes: {obj.Name}: {obj.Recipe.GetRecipeString(obj)}");
                        data.Add(obj.Name, obj.Recipe.GetRecipeString(obj));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting cooking recipe for {obj.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\CraftingRecipes"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        if (obj.Recipe == null)
                        {
                            continue;
                        }
                        if (obj.Category == ObjectData.Category_.Cooking)
                        {
                            continue;
                        }
                        Log.trace($"Injecting to crafting recipes: {obj.Name}: {obj.Recipe.GetRecipeString(obj)}");
                        data.Add(obj.Name, obj.Recipe.GetRecipeString(obj));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting crafting recipe for {obj.Name}: {e}");
                    }
                }
                foreach (var big in Mod.instance.bigCraftables)
                {
                    try
                    {
                        if (big.Recipe == null)
                        {
                            continue;
                        }
                        Log.trace($"Injecting to crafting recipes: {big.Name}: {big.Recipe.GetRecipeString(big)}");
                        data.Add(big.Name, big.Recipe.GetRecipeString(big));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting crafting recipe for {big.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\BigCraftablesInformation"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var big in Mod.instance.bigCraftables)
                {
                    try
                    {
                        Log.trace($"Injecting to big craftables: {big.GetCraftableId()}: {big.GetCraftableInformation()}");
                        data.Add(big.GetCraftableId(), big.GetCraftableInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting object information for {big.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\hats"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var hat in Mod.instance.hats)
                {
                    try
                    {
                        Log.trace($"Injecting to hats: {hat.GetHatId()}: {hat.GetHatInformation()}");
                        data.Add(hat.GetHatId(), hat.GetHatInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting hat information for {hat.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\weapons"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var weapon in Mod.instance.weapons)
                {
                    try
                    {
                        Log.trace($"Injecting to weapons: {weapon.GetWeaponId()}: {weapon.GetWeaponInformation()}");
                        data.Add(weapon.GetWeaponId(), weapon.GetWeaponInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting weapon information for {weapon.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\NPCGiftTastes"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                // TODO: This could be optimized from mn to... m + n?
                // Basically, iterate through objects and create Dictionary<NPC name, GiftData[]>
                // Iterate through objects, each section and add to dict[npc][approp. section]
                // Point is, I'm doing this the lazy way right now
                var newData = new Dictionary <string, string>(data);
                foreach (var npc in data)
                {
                    if (npc.Key.StartsWith("Universal_"))
                    {
                        continue;
                    }

                    string[] sections = npc.Value.Split('/');
                    if (sections.Length != 11)
                    {
                        Log.warn($"Bad gift taste data for {npc.Key}!");
                        continue;
                    }

                    string        loveStr    = sections[0];
                    List <string> loveIds    = new List <string>(sections[1].Split(' '));
                    string        likeStr    = sections[2];
                    List <string> likeIds    = new List <string>(sections[3].Split(' '));
                    string        dislikeStr = sections[4];
                    List <string> dislikeIds = new List <string>(sections[5].Split(' '));
                    string        hateStr    = sections[6];
                    List <string> hateIds    = new List <string>(sections[7].Split(' '));
                    string        neutralStr = sections[8];
                    List <string> neutralIds = new List <string>(sections[9].Split(' '));

                    foreach (var obj in Mod.instance.objects)
                    {
                        if (obj.GiftTastes == null)
                        {
                            continue;
                        }
                        if (obj.GiftTastes.Love != null && obj.GiftTastes.Love.Contains(npc.Key))
                        {
                            loveIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Like != null && obj.GiftTastes.Like.Contains(npc.Key))
                        {
                            likeIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Neutral != null && obj.GiftTastes.Neutral.Contains(npc.Key))
                        {
                            neutralIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Dislike != null && obj.GiftTastes.Dislike.Contains(npc.Key))
                        {
                            dislikeIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Hate != null && obj.GiftTastes.Hate.Contains(npc.Key))
                        {
                            hateIds.Add(obj.GetObjectId().ToString());
                        }
                    }

                    string loveIdStr    = string.Join(" ", loveIds);
                    string likeIdStr    = string.Join(" ", likeIds);
                    string dislikeIdStr = string.Join(" ", dislikeIds);
                    string hateIdStr    = string.Join(" ", hateIds);
                    string neutralIdStr = string.Join(" ", neutralIds);
                    newData[npc.Key] = $"{loveStr}/{loveIdStr}/{likeStr}/{likeIdStr}/{dislikeStr}/{dislikeIdStr}/{hateStr}/{hateIdStr}/{neutralStr}/{neutralIdStr}/ ";

                    Log.trace($"Adding gift tastes for {npc.Key}: {newData[npc.Key]}");
                }
                asset.ReplaceWith(newData);
            }
            else if (asset.AssetNameEquals("Maps\\springobjects"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);

                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        Log.trace($"Injecting {obj.Name} sprites @ {objectRect(obj.GetObjectId())}");
                        asset.AsImage().PatchImage(obj.texture, null, objectRect(obj.GetObjectId()));
                        if (obj.IsColored)
                        {
                            Log.trace($"Injecting {obj.Name} color sprites @ {objectRect(obj.GetObjectId() + 1)}");
                            asset.AsImage().PatchImage(obj.textureColor, null, objectRect(obj.GetObjectId() + 1));
                        }
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {obj.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\crops"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);

                foreach (var crop in Mod.instance.crops)
                {
                    try
                    {
                        Log.trace($"Injecting {crop.Name} crop images @ {cropRect(crop.GetCropSpriteIndex())}");
                        asset.AsImage().PatchImage(crop.texture, null, cropRect(crop.GetCropSpriteIndex()));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting crop sprite for {crop.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\fruitTrees"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);

                foreach (var fruitTree in Mod.instance.fruitTrees)
                {
                    try
                    {
                        Log.trace($"Injecting {fruitTree.Name} fruit tree images @ {fruitTreeRect(fruitTree.GetFruitTreeIndex())}");
                        asset.AsImage().PatchImage(fruitTree.texture, null, fruitTreeRect(fruitTree.GetFruitTreeIndex()));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting fruit tree sprite for {fruitTree.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\Craftables") || asset.AssetNameEquals("TileSheets\\Craftables_indoor") || asset.AssetNameEquals("TileSheets\\Craftables_outdoor"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Big craftables are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var big in Mod.instance.bigCraftables)
                {
                    try
                    {
                        Log.trace($"Injecting {big.Name} sprites @ {bigCraftableRect(big.GetCraftableId())}");
                        asset.AsImage().PatchImage(big.texture, null, bigCraftableRect(big.GetCraftableId()));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {big.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Characters\\Farmer\\hats"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Hats are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var hat in Mod.instance.hats)
                {
                    try
                    {
                        Log.trace($"Injecting {hat.Name} sprites @ {hatRect(hat.GetHatId())}");
                        asset.AsImage().PatchImage(hat.texture, null, hatRect(hat.GetHatId()));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {hat.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\weapons"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Weapons are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var weapon in Mod.instance.weapons)
                {
                    try
                    {
                        Log.trace($"Injecting {weapon.Name} sprites @ {weaponRect(weapon.GetWeaponId())}");
                        asset.AsImage().PatchImage(weapon.texture, null, weaponRect(weapon.GetWeaponId()));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {weapon.Name}: {e}");
                    }
                }
            }
        }
        public void Edit <T>(IAssetData asset)
        {
            if (asset.AssetNameEquals("Data\\ObjectInformation"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                //MEAT
                MeatData = DataLoader.Helper.Data.ReadJsonFile <MeatData>("data\\meats.json") ?? new MeatData();
                DataLoader.Helper.Data.WriteJsonFile("data\\meats.json", MeatData);

                data[(int)Meat.Beef]    = Meat.Beef.GetObjectString();
                data[(int)Meat.Pork]    = Meat.Pork.GetObjectString();
                data[(int)Meat.Chicken] = Meat.Chicken.GetObjectString();
                data[(int)Meat.Duck]    = Meat.Duck.GetObjectString();
                data[(int)Meat.Rabbit]  = Meat.Rabbit.GetObjectString();
                data[(int)Meat.Mutton]  = Meat.Mutton.GetObjectString();
                data[(int)Meat.Ostrich] = Meat.Ostrich.GetObjectString();

                //COOKING

                data[(int)Cooking.Meatloaf]           = Cooking.Meatloaf.GetObjectString();
                data[(int)Cooking.OrangeChicken]      = Cooking.OrangeChicken.GetObjectString();
                data[(int)Cooking.MonteCristo]        = Cooking.MonteCristo.GetObjectString();
                data[(int)Cooking.BaconCheeseburger]  = Cooking.BaconCheeseburger.GetObjectString();
                data[(int)Cooking.RoastDuck]          = Cooking.RoastDuck.GetObjectString();
                data[(int)Cooking.RabbitAuVin]        = Cooking.RabbitAuVin.GetObjectString();
                data[(int)Cooking.SteakFajitas]       = Cooking.SteakFajitas.GetObjectString();
                data[(int)Cooking.GlazedHam]          = Cooking.GlazedHam.GetObjectString();
                data[(int)Cooking.SummerSausage]      = Cooking.SummerSausage.GetObjectString();
                data[(int)Cooking.SweetAndSourPork]   = Cooking.SweetAndSourPork.GetObjectString();
                data[(int)Cooking.RabbitStew]         = Cooking.RabbitStew.GetObjectString();
                data[(int)Cooking.WinterDuck]         = Cooking.WinterDuck.GetObjectString();
                data[(int)Cooking.SteakWithMushrooms] = Cooking.SteakWithMushrooms.GetObjectString();
                data[(int)Cooking.CowboyDinner]       = Cooking.CowboyDinner.GetObjectString();
                data[(int)Cooking.Bacon] = Cooking.Bacon.GetObjectString();
            }
            else if (asset.AssetNameEquals("Data\\Bundles"))
            {
                var    data  = asset.AsDictionary <string, string>().Data;
                string value = data["Pantry/4"];
                if (!ModConfig.DisableMeatInBlundle)
                {
                    if (!value.Contains("644 1 0") && value.Contains("/4/5"))
                    {
                        value = value.Insert(value.LastIndexOf("/4/5"), " 644 1 0");
                    }
                }
                else
                {
                    if (value.Contains(" 639 1 0 640 1 0 641 1 0 642 1 0 643 1 0"))
                    {
                        value = value.Replace(" 639 1 0 640 1 0 641 1 0 642 1 0 643 1 0", "");
                    }
                }

                data["Pantry/4"] = value;
            }
            else if (asset.AssetNameEquals("Data\\NPCGiftTastes"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                AddUniversalGiftTaste(data, Taste.Dislike, "-14");
                AddNpcGiftTaste(data, "Linus", Taste.Neutral, "-14");
                AddNpcGiftTaste(data, "Linus", Taste.Like, "643");
                AddNpcGiftTaste(data, "Linus", Taste.Love, "657", "662");
                AddNpcGiftTaste(data, "Pam", Taste.Dislike, "656", "665");
                AddNpcGiftTaste(data, "Pam", Taste.Neutral, "-14");
                AddNpcGiftTaste(data, "Pam", Taste.Love, "657");
                AddNpcGiftTaste(data, "Gus", Taste.Neutral, "-14");
                AddNpcGiftTaste(data, "Gus", Taste.Love, "653", "660");
                AddNpcGiftTaste(data, "Jodi", Taste.Hate, "652", "660");
                AddNpcGiftTaste(data, "Jodi", Taste.Neutral, "-14");
                AddNpcGiftTaste(data, "Jodi", Taste.Love, "661");
                AddNpcGiftTaste(data, "Jodi", Taste.Like, "640");
                AddNpcGiftTaste(data, "Kent", Taste.Neutral, "-14");
                AddNpcGiftTaste(data, "Kent", Taste.Like, "642");
                AddNpcGiftTaste(data, "Kent", Taste.Love, "656", "663");
                AddNpcGiftTaste(data, "Marnie", Taste.Hate, MeatDishes.Concat(new string[] { "-14" }).ToArray());
                AddNpcGiftTaste(data, "Evelyn", Taste.Hate, "-14");
                AddNpcGiftTaste(data, "Evelyn", Taste.Dislike, MeatDishes);
                AddNpcGiftTaste(data, "Emily", Taste.Hate, "-14");
                AddNpcGiftTaste(data, "Emily", Taste.Dislike, MeatDishes);
                AddNpcGiftTaste(data, "Alex", Taste.Like, "639");
                AddNpcGiftTaste(data, "Shane", Taste.Hate, "641", "653");
                AddNpcGiftTaste(data, "Shane", Taste.Love, "655", "658");
                AddNpcGiftTaste(data, "Leah", Taste.Hate, "644");
                AddNpcGiftTaste(data, "Leah", Taste.Dislike, "655", "660", "666");
                AddNpcGiftTaste(data, "Harvey", Taste.Dislike, "654", "655");
                AddNpcGiftTaste(data, "Harvey", Taste.Love, "657", "664");
                AddNpcGiftTaste(data, "Sam", Taste.Dislike, "662", "664");
                AddNpcGiftTaste(data, "Sebastian", Taste.Dislike, "665");
                AddNpcGiftTaste(data, "Sebastian", Taste.Love, "661");
                AddNpcGiftTaste(data, "Abigail", Taste.Love, "666");
                AddNpcGiftTaste(data, "Haley", Taste.Love, "657", "663");
                AddNpcGiftTaste(data, "Maru", Taste.Dislike, "659");
                AddNpcGiftTaste(data, "Maru", Taste.Love, "656");
                AddNpcGiftTaste(data, "Penny", Taste.Dislike, "657");
                AddNpcGiftTaste(data, "Penny", Taste.Love, "662");
                AddNpcGiftTaste(data, "Caroline", Taste.Love, "653", "661");
                AddNpcGiftTaste(data, "Clint", Taste.Dislike, "663");
                AddNpcGiftTaste(data, "Demetrius", Taste.Dislike, "660");
                AddNpcGiftTaste(data, "Demetrius", Taste.Love, "665");
                AddNpcGiftTaste(data, "George", Taste.Hate, "658");
                AddNpcGiftTaste(data, "George", Taste.Love, "662", "664");
                AddNpcGiftTaste(data, "Jas", Taste.Love, "659");
                AddNpcGiftTaste(data, "Lewis", Taste.Hate, "654");
                AddNpcGiftTaste(data, "Lewis", Taste.Love, "652", "659", "663");
                AddNpcGiftTaste(data, "Pierre", Taste.Dislike, "665");
                AddNpcGiftTaste(data, "Pierre", Taste.Love, "654", "661", "666");
                AddNpcGiftTaste(data, "Robin", Taste.Love, "652", "665");
                AddNpcGiftTaste(data, "Sandy", Taste.Hate, "661");
                AddNpcGiftTaste(data, "Vincent", Taste.Love, "659");
            }
            else if (asset.AssetNameEquals("Data\\FarmAnimals"))
            {
                AddCustomAnimalsTemplate((Dictionary <string, string>)(isLoadingFarmAnimals? asset.Data : null));
            }
        }
Beispiel #10
0
        /// <summary>Edit a matched asset.</summary>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
        public void Edit <T>(IAssetData asset)
        {
            string suffix      = Config.Suffix;
            string lowerSuffix = suffix.ToLower();
            IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

            if (asset.AssetNameEquals("Characters/Dialogue/MarriageDialogue"))
            {
                data["Rainy_Day_Sebastian"] = data["Rainy_Day_Sebastian"].Replace("farm", lowerSuffix);
                data["Indoor_Day_4"]        = data["Indoor_Day_4"].Replace("farm", lowerSuffix);
                data["Indoor_Day_Abigail"]  = data["Indoor_Day_Abigail"].Replace("farm", lowerSuffix);
                data["Indoor_Night_Sam"]    = data["Indoor_Night_Sam"].Replace("farm", lowerSuffix);
                data["Outdoor_1"]           = data["Outdoor_1"].Replace("farm", lowerSuffix);
                //data["Outdoor_2"] = data["//Outdoor_2"].Replace("farm", lowerSuffix);
                data["Outdoor_Leah"]    = data["Outdoor_Leah"].Replace("farm", lowerSuffix);
                data["Outdoor_Penny"]   = data["Outdoor_Penny"].Replace("farm", lowerSuffix);
                data["Outdoor_Harvey"]  = data["Outdoor_Harvey"].Replace("farm", lowerSuffix);
                data["Outdoor_Elliott"] = data["Outdoor_Elliott"].Replace("farm", lowerSuffix);
                data["Outdoor_Alex"]    = data["Outdoor_Alex"].Replace("farm", lowerSuffix);
                data["OneKid_2"]        = data["OneKid_2"].Replace("farm", lowerSuffix);
                data["Neutral_8"]       = data["Neutral_8"].Replace("farm", lowerSuffix);
                //data["spring_Sebastian"] = data["//spring_Sebastian"].Replace("farm", lowerSuffix);
                data["spring_Elliott"] = data["spring_Elliott"].Replace(@"%farm farm", @"%farm " + lowerSuffix);
                data["fall_Penny"]     = data["fall_Penny"].Replace("farm", lowerSuffix);
            }

            if (asset.AssetNameEquals("Characters/Dialogue/MarriageDialogueEmily"))
            {
                data["Indoor_Day_0"] = data["Indoor_Day_0"].Replace(@"%farm farm", @"%farm " + lowerSuffix);
                data["TwoKids_3"]    = data["TwoKids_3"].Replace("farm", lowerSuffix);
            }

            if (asset.AssetNameEquals("Characters/Dialogue/MarriageDialogueHarvey"))
            {
                data["Indoor_Night_3"] = data["Indoor_Night_3"].Replace(@"%farm farm", @"%farm " + lowerSuffix);
            }

            if (asset.AssetNameEquals("Characters/Dialogue/MarriageDialogueLeah"))
            {
                data["TwoKids_3"] = data["TwoKids_3"].Replace("farm", lowerSuffix);
                data["Neutral_8"] = data["Neutral_8"].Replace("farm", lowerSuffix);
                data["winter_28"] = data["winter_28"].Replace(@"%farm farm", @"%farm " + lowerSuffix);
            }

            if (asset.AssetNameEquals("Characters/Dialogue/Lewis"))
            {
                data["Town_57_40"]      = data["Town_57_40"].Replace("farm", lowerSuffix);
                data["Fri"]             = data["Fri"].Replace(@"%farm farm", @"%farm " + lowerSuffix);
                data["summer_Sun"]      = data["summer_Sun"].Replace("farm", lowerSuffix);
                data["fall_Town_57_40"] = data["fall_Town_57_40"].Replace("farm", lowerSuffix);
                data["fall_Fri"]        = data["fall_Fri"].Replace("farm", lowerSuffix);
                data["fall_12"]         = data["fall_12"].Replace("farm", lowerSuffix);
                data["fall_Sun"]        = data["fall_Sun"].Replace("farm", lowerSuffix);
                data["winter_Fri"]      = data["winter_Fri"].Replace("farm", lowerSuffix);
            }

            if (asset.AssetNameEquals("Data/Events/BusStop"))
            {
                data["60367/u 0"] = data["60367/u 0"].Replace("farm's", lowerSuffix + "'s");
                data["60367/u 0"] = data["60367/u 0"].Replace("%farm farm", "%farm " + lowerSuffix);
            }

            if (asset.AssetNameEquals("Data/Events/FarmHouse"))
            {
                data["558291/y 3/H"] = data["558291/y 3/H"].Replace("%farm Farm", "%farm " + suffix);
            }

            if (asset.AssetNameEquals("Strings/Locations"))
            {
                data["ScienceHouse_CarpenterMenu_Construct"] = data["ScienceHouse_CarpenterMenu_Construct"].Replace("Farm", suffix);
                data["Farm_WeedsDestruction"]              = data["Farm_WeedsDestruction"].Replace("farm", lowerSuffix);
                data["WitchHut_EvilShrineRightActivate"]   = data["WitchHut_EvilShrineRightActivate"].Replace("farm", lowerSuffix);
                data["WitchHut_EvilShrineRightDeActivate"] = data["WitchHut_EvilShrineRightDeActivate"].Replace("farm", lowerSuffix);
            }

            if (asset.AssetNameEquals("Strings/Notes"))
            {
                data["2"] = data["2"].Replace("farm", lowerSuffix);
                data["6"] = data["6"].Replace("farm", lowerSuffix);
            }

            if (asset.AssetNameEquals("Strings/SpeechBubbles"))
            {
                data["AnimalShop_Marnie_Greeting3"] = data["AnimalShop_Marnie_Greeting3"].Replace("Farm", suffix);
            }

            if (asset.AssetNameEquals("Strings/StringsFromCSFiles"))
            {
                data["Event.cs.1306"]           = data["Event.cs.1306"].Replace("farm", lowerSuffix);
                data["Event.cs.1308"]           = data["Event.cs.1308"].Replace("Farm", suffix);
                data["Event.cs.1315"]           = data["Event.cs.1315"].Replace("farm", lowerSuffix);
                data["Event.cs.1317"]           = data["Event.cs.1317"].Replace("Farm", suffix);
                data["Event.cs.1843"]           = data["Event.cs.1843"].Replace("farm", lowerSuffix);
                data["Farmer.cs.1972"]          = data["Farmer.cs.1972"].Replace("farm", lowerSuffix);
                data["Game1.cs.2782"]           = data["Game1.cs.2782"].Replace("farm", lowerSuffix);
                data["NPC.cs.4474"]             = data["NPC.cs.4474"].Replace("farm", lowerSuffix);
                data["NPC.cs.4485"]             = data["NPC.cs.4485"].Replace("Farm", suffix);
                data["Utility.cs.5229"]         = data["Utility.cs.5229"].Replace("farm", lowerSuffix);
                data["Utility.cs.5230"]         = data["Utility.cs.5230"].Replace("lowerFind", lowerSuffix);
                data["BlueprintsMenu.cs.10012"] = data["BlueprintsMenu.cs.10012"].Replace("Farm", suffix);
                data["CataloguePage.cs.10148"]  = data["CataloguePage.cs.10148"].Replace("farm", lowerSuffix);
                data["LoadGameMenu.cs.11019"]   = data["LoadGameMenu.cs.11019"].Replace("Farm", suffix);
                data["MapPage.cs.11064"]        = data["MapPage.cs.11064"].Replace("Farm", suffix);
                data["GrandpaStory.cs.12051"]   = data["GrandpaStory.cs.12051"].Replace("Farm", suffix);
                data["GrandpaStory.cs.12055"]   = data["GrandpaStory.cs.12055"].Replace("Farm", suffix);
                data["HoeDirt.cs.13919"]        = data["HoeDirt.cs.13919"].Replace("farm", lowerSuffix);
                data["Axe.cs.14023"]            = data["Axe.cs.14023"].Replace("farm", lowerSuffix);
            }

            if (asset.AssetNameEquals("Strings/StringsFromMaps"))
            {
                data["Forest.1"] = data["Forest.1"].Replace("Farm", suffix);
            }

            if (asset.AssetNameEquals("Strings/UI"))
            {
                data["Character_Farm"]             = data["Character_Farm"].Replace("Farm", suffix);
                data["Character_FarmNameSuffix"]   = data["Character_FarmNameSuffix"].Replace("Farm", suffix);
                data["Inventory_FarmName"]         = data["Inventory_FarmName"].Replace("Farm", suffix);
                data["CoopMenu_HostNewFarm"]       = data["CoopMenu_HostNewFarm"].Replace("Farm", suffix);
                data["CoopMenu_HostFile"]          = data["CoopMenu_HostFile"].Replace("Farm", suffix);
                data["CoopMenu_RevisitFriendFarm"] = data["CoopMenu_RevisitFriendFarm"].Replace("Farm", suffix);
                data["CoopMenu_JoinFriendFarm"]    = data["CoopMenu_JoinFriendFarm"].Replace("Farm", suffix);
                data["Chat_MuseumComplete"]        = data["Chat_MuseumComplete"].Replace("Farm", suffix);
                data["Chat_Museum40"]   = data["Chat_Museum40"].Replace("Farm", suffix);
                data["Chat_Earned15k"]  = data["Chat_Earned15k"].Replace("Farm", suffix);
                data["Chat_Earned50k"]  = data["Chat_Earned50k"].Replace("Farm", suffix);
                data["Chat_Earned250k"] = data["Chat_Earned250k"].Replace("Farm", suffix);
                data["Chat_Earned1m"]   = data["Chat_Earned1m"].Replace("Farm", suffix);
                data["Chat_Earned10m"]  = data["Chat_Earned10m"].Replace("Farm", suffix);
                data["Chat_Earned100m"] = data["Chat_Earned100m"].Replace("Farm", suffix);
            }
        }
Beispiel #11
0
 /// <summary>
 /// Adds the letter to mail.xnb from the i18n translations
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="asset"></param>
 public void Edit <T>(IAssetData asset)
 {
     asset.AsDictionary <string, string>().Data["FarmRearrangerMail"]
         = Helper.Translation.Get("robinletter");;
 }
Beispiel #12
0
        public void Edit <T>(IAssetData asset)
        {
            var data = asset.AsDictionary <string, string>().Data;

            data["WizardBirthdayMail"] = "= Esteemed @... = ^ ^The elementals have informed me that today marks the completion of your 26th revolution around the sun. Congratulations! ^ ^You have accomplished much in your twenty-six years, and I am sure you will accomplish much more.  ^ ^To celebrate the occasion, I have arranged an activity for you later today. Please meet me in the town square at 9:00 AM this morning to begin. ^ ^⁠— M. Rasmodius ^— (With some help from the \"ellen\"-mentals. <)";
        }
Beispiel #13
0
        /// <summary>Edit a matched asset.</summary>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
        public void Edit <T>(IAssetData asset)
        {
            // update community center bundles (mainly the quality crops bundle, but be compatible with other mods)
            if (asset.AssetNameEquals("Data/Bundles"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                // https://stackoverflow.com/a/31767807
                // .ToList is part of System.Linq
                // Without it, the loop would error after an assignment to a dictionary element
                foreach (string key in data.Keys.ToList())
                {
                    string[] fields            = data[key].Split(BUNDLE_FIELD_SEPARATOR);
                    string[] bundleIngredients = fields[2].Split(BUNDLE_INGREDIENT_SEPARATOR);
                    for (int i = 0; i < bundleIngredients.Length / BUNDLE_INGREDIENT_FIELDS; ++i)
                    {
                        int indexItemId   = i * BUNDLE_INGREDIENT_FIELDS;
                        int indexQuantity = i * BUNDLE_INGREDIENT_FIELDS + 1;
                        int indexQuality  = i * BUNDLE_INGREDIENT_FIELDS + 2;

                        string itemId   = bundleIngredients[indexItemId];
                        string quantity = bundleIngredients[indexQuantity];
                        string quality  = bundleIngredients[indexQuality];

                        // itemId -1 is a gold purchase, don't change anything here
                        if (itemId == "-1")
                        {
                            continue;
                        }

                        // quality is already regular, no adjustment needed
                        if (quality == "0")
                        {
                            continue;
                        }

                        // adjust amount -> multiply by rarity
                        int intQuality  = int.Parse(quality);
                        int intQuantity = int.Parse(quantity);
                        int newQuantity = intQuantity + intQuantity * intQuality * Config.BundleIngredientQualityMultiplicator;
                        if (newQuantity > MAX_ITEM_STACK_SIZE)
                        {
                            this.Monitor.Log($"A bundle ingredient would have exceeded the maximum stack size of {MAX_ITEM_STACK_SIZE}. It has been limited to {MAX_ITEM_STACK_SIZE}.", LogLevel.Warn);
                            this.Monitor.Log($"Bundle: {key} | itemId: {itemId} | adjusted quantity = {newQuantity} (= {quantity} + {quantity} * {quality} * {Config.BundleIngredientQualityMultiplicator}", LogLevel.Warn);
                            newQuantity = MAX_ITEM_STACK_SIZE;
                        }

                        bundleIngredients[indexQuantity] = newQuantity.ToString();
                        bundleIngredients[indexQuality]  = "0";
                    }

                    string newData = string.Join(BUNDLE_INGREDIENT_SEPARATOR.ToString(), bundleIngredients);

                    // nothing changed, no need to touch the data dictionary
                    if (newData == fields[2])
                    {
                        continue;
                    }

                    fields[2] = newData;
                    data[key] = string.Join(BUNDLE_FIELD_SEPARATOR.ToString(), fields);
                }
            }
        }
Beispiel #14
0
        public static void Edit <T>(IAssetData asset, ForageFantasy mod)
        {
            if (mod.Config.TapperDaysNeededChangesEnabled && asset.AssetNameEquals("Data/ObjectInformation"))
            {
                /*  here is the reasoning for the math
                 *
                 *  normal tapper:
                 *  maple syrup 9 days 200g
                 *  oak resin 7 days 150g
                 *  pine tar 5 days 100g
                 *
                 *  so 22,2g per day, 21,4g per day, 20g per day
                 *
                 *  heavy tapper:
                 *  maple syrup 4 days 200g
                 *  oak resin 3 days 150g
                 *  pine tar 2 days 100g
                 *
                 *  so 50g per day for all of them
                 *
                 *  ----
                 *
                 *  wanted values:
                 *  maple syrup 7 days 150g
                 *  oak resin 7 days 150g
                 *  pine tar 7 days 150g
                 *
                 *  so the calculation is:
                 *  newSellPrice = (int)Math.Round(daysNeeded * (150f / 7f), MidpointRounding.AwayFromZero);
                 */

                IDictionary <int, string> data = asset.AsDictionary <int, string>().Data;

                var priceChanges = new Dictionary <int, int>()
                {
                    { 724, mod.Config.MapleDaysNeeded }, { 725, mod.Config.OakDaysNeeded }, { 726, mod.Config.PineDaysNeeded }
                };

                foreach (var item in priceChanges)
                {
                    var entry    = data[item.Key];
                    var fields   = entry.Split('/');
                    var newPrice = TapperAndMushroomQualityLogic.GetTapperProductValueForDaysNeeded(item.Value);
                    fields[1]      = newPrice.ToString();
                    data[item.Key] = string.Join("/", fields);
                }
            }

            if (mod.Config.CommonFiddleheadFern)
            {
                if (asset.AssetNameEquals("Data/CraftingRecipes"))
                {
                    IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                    var entry  = data["Wild Seeds (Su)"];
                    var fields = entry.Split('/');
                    fields[0] = "396 1 398 1 402 1 259 1";
                    data["Wild Seeds (Su)"] = string.Join("/", fields);
                }

                if (asset.AssetNameEquals("Data/Locations"))
                {
                    IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                    var keys = data.Keys.ToList();

                    for (int i = 0; i < keys.Count; i++)
                    {
                        string   location = keys[i];
                        string[] fields   = data[location].Split('/');

                        switch (location)
                        {
                        case "BusStop":
                            fields[1] = "396 .6 398 .6 402 .6";
                            break;

                        case "Forest":
                            fields[1] = "396 .8 398 .8 259 .8";
                            break;

                        case "Mountain":
                            fields[1] = "396 .7 398 .7 259 .8";
                            break;

                        case "Backwoods":
                            fields[1] = "396 .7 398 .7 259 .8";
                            break;

                        case "Railroad":
                            fields[1] = "396 .6 398 .6 402 .6";
                            break;

                        case "Woods":
                            fields[1] = "259 .7 420 .7";
                            break;
                        }

                        data[location] = string.Join("/", fields);
                    }
                }
            }

            if (mod.Config.ForageSurvivalBurger)
            {
                var spring = mod.Helper.Translation.Get("SpringBurger");
                var summer = mod.Helper.Translation.Get("SummerBurger");
                var fall   = mod.Helper.Translation.Get("FallBurger");
                var winter = mod.Helper.Translation.Get("WinterBurger");

                if (asset.AssetNameEquals("Data/CookingRecipes"))
                {
                    IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                    data.Remove("Survival Burger");
                    data.Add("Survival Burger (Sp)", $"216 1 16 1 20 1 22 1/70 1/241 2/s Foraging 2/{spring}");
                    data.Add("Survival Burger (Su)", $"216 1 398 1 396 1 259 1/70 1/241 2/s Foraging 2/{summer}");
                    data.Add("Survival Burger (Fa)", $"216 1 404 1 406 1 408 1/70 1/241 2/s Foraging 2/{fall}");
                    data.Add("Survival Burger (Wi)", $"216 1 412 1 414 1 416 1/70 1/241 2/s Foraging 2/{winter}");
                }

                if (asset.AssetNameEquals("Data/CraftingRecipes"))
                {
                    IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                    data.Add("Survival Burger (Sp)", $"216 1 16 1 20 1 22 1/Field/241/false/s Foraging 2/{spring}");
                    data.Add("Survival Burger (Su)", $"216 1 398 1 396 1 259 1/Field/241/false/s Foraging 2/{summer}");
                    data.Add("Survival Burger (Fa)", $"216 1 404 1 406 1 408 1/Field/241/false/s Foraging 2/{fall}");
                    data.Add("Survival Burger (Wi)", $"216 1 412 1 414 1 416 1/Field/241/false/s Foraging 2/{winter}");
                }
            }
        }
Beispiel #15
0
        /// <summary>Edit a matched asset.</summary>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
        public void Edit <T>(IAssetData asset)
        {
            Monitor.Log("Editing asset " + asset.AssetName);
            if (asset.AssetNameEquals("Data/Events/HaleyHouse"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                data["195012/f Haley 2500/f Emily 2500/f Penny 2500/f Abigail 2500/f Leah 2500/f Maru 2500/o Abigail/o Penny/o Leah/o Emily/o Maru/o Haley/o Shane/o Harvey/o Sebastian/o Sam/o Elliott/o Alex/e 38/e 2123343/e 10/e 901756/e 54/e 15/k 195019"] = Regex.Replace(data["195012/f Haley 2500/f Emily 2500/f Penny 2500/f Abigail 2500/f Leah 2500/f Maru 2500/o Abigail/o Penny/o Leah/o Emily/o Maru/o Haley/o Shane/o Harvey/o Sebastian/o Sam/o Elliott/o Alex/e 38/e 2123343/e 10/e 901756/e 54/e 15/k 195019"], "(pause 1000/speak Maru \\\")[^$]+.a\\\"", $"$1{PHelper.Translation.Get("confrontation-female")}$h\"/emote Haley 21 true/emote Emily 21 true/emote Penny 21 true/emote Maru 21 true/emote Leah 21 true/emote Abigail 21").Replace("/dump girls 3", "");
                data["choseToExplain"]  = Regex.Replace(data["choseToExplain"], "(pause 1000/speak Maru \\\")[^$]+.a\\\"", $"$1{PHelper.Translation.Get("confrontation-female")}$h\"/emote Haley 21 true/emote Emily 21 true/emote Penny 21 true/emote Maru 21 true/emote Leah 21 true/emote Abigail 21").Replace("/dump girls 4", "");
                data["lifestyleChoice"] = Regex.Replace(data["lifestyleChoice"], "(pause 1000/speak Maru \\\")[^$]+.a\\\"", $"$1{PHelper.Translation.Get("confrontation-female")}$h\"/emote Haley 21 true/emote Emily 21 true/emote Penny 21 true/emote Maru 21 true/emote Leah 21 true/emote Abigail 21").Replace("/dump girls 4", "");
            }
            else if (asset.AssetNameEquals("Data/Events/Saloon"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                string aData = data["195013/f Shane 2500/f Sebastian 2500/f Sam 2500/f Harvey 2500/f Alex 2500/f Elliott 2500/o Abigail/o Penny/o Leah/o Emily/o Maru/o Haley/o Shane/o Harvey/o Sebastian/o Sam/o Elliott/o Alex/e 911526/e 528052/e 9581348/e 43/e 384882/e 233104/k 195099"];
                data["195013/f Shane 2500/f Sebastian 2500/f Sam 2500/f Harvey 2500/f Alex 2500/f Elliott 2500/o Abigail/o Penny/o Leah/o Emily/o Maru/o Haley/o Shane/o Harvey/o Sebastian/o Sam/o Elliott/o Alex/e 911526/e 528052/e 9581348/e 43/e 384882/e 233104/k 195099"] = Regex.Replace(aData, "(pause 1000/speak Sam \\\")[^$]+.a\\\"", $"$1{PHelper.Translation.Get("confrontation-male")}$h\"/emote Shane 21 true/emote Sebastian 21 true/emote Sam 21 true/emote Harvey 21 true/emote Alex 21 true/emote Elliott 21").Replace("/dump guys 3", "");
                aData = data["choseToExplain"];
                data["choseToExplain"] = Regex.Replace(aData, "(pause 1000/speak Sam \\\")[^$]+.a\\\"", $"$1{PHelper.Translation.Get("confrontation-male")}$h\"/emote Shane 21 true/emote Sebastian 21 true/emote Sam 21 true/emote Harvey 21 true/emote Alex 21 true/emote Elliott 21").Replace("/dump guys 4", "");
                aData          = data["crying"];
                data["crying"] = Regex.Replace(aData, "(pause 1000/speak Sam \\\")[^$]+.a\\\"", $"$1{PHelper.Translation.Get("confrontation-male")}$h\"/emote Shane 21 true/emote Sebastian 21 true/emote Sam 21 true/emote Harvey 21 true/emote Alex 21 true/emote Elliott 21").Replace("/dump guys 4", "");
            }
            else if (asset.AssetNameEquals("Strings/StringsFromCSFiles"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;
                data["NPC.cs.3985"] = Regex.Replace(data["NPC.cs.3985"], @"\.\.\.\$s.+", $"$n#$b#$c 0.5#{data["ResourceCollectionQuest.cs.13681"]}#{data["ResourceCollectionQuest.cs.13683"]}");
                Monitor.Log($"NPC.cs.3985 is set to \"{data["NPC.cs.3985"]}\"");
            }
            else if (asset.AssetNameEquals("Data/animationDescriptions"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;
                List <string> sleepKeys           = data.Keys.ToList().FindAll((s) => s.EndsWith("_Sleep"));
                foreach (string key in sleepKeys)
                {
                    if (!data.ContainsKey(key.ToLower()))
                    {
                        Monitor.Log($"adding {key.ToLower()} to animationDescriptions");
                        data.Add(key.ToLower(), data[key]);
                    }
                }
            }
            else if (asset.AssetNameEquals("Data/EngagementDialogue"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;
                if (!config.RomanceAllVillagers)
                {
                    return;
                }
                Farmer f = Game1.player;
                if (f == null)
                {
                    return;
                }
                foreach (string friend in f.friendshipData.Keys)
                {
                    if (!data.ContainsKey(friend + "0"))
                    {
                        data[friend + "0"] = "";
                    }
                    if (!data.ContainsKey(friend + "1"))
                    {
                        data[friend + "1"] = "";
                    }
                }
            }
            else if (asset.AssetName.StartsWith("Characters/schedules") || asset.AssetName.StartsWith("Characters\\schedules"))
            {
                IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;
                List <string> keys = new List <string>(data.Keys);
                foreach (string key in keys)
                {
                    data[$"marriage_{key}"] = data[key];
                }
            }
        }
Beispiel #16
0
        public void Edit <T>(IAssetData asset)
        {
            asset
            .AsDictionary <string, string>()
            .Set((id, data) =>
            {
                string[] fields = data.Split('/');

                if (!fields[0].Equals("animal"))
                {
                    int buildingPrice = -1;
                    string resources  = "";

                    if (fields.Length >= 18 && fields[17] != null)
                    {
                        buildingPrice = Int32.Parse(fields[17]);
                        resources     = fields[0];

                        // Check for friendship with Robin
                        int hearts = Game1.player.getFriendshipHeartLevelForNPC("Robin");

                        int percentage = 0;

                        if (hearts >= ModEntry.HEART_LEVEL_3)
                        {
                            percentage = ModEntry.DISC_3;
                        }
                        else if (hearts >= ModEntry.HEART_LEVEL_2)
                        {
                            percentage = ModEntry.DISC_2;
                        }
                        else if (hearts >= ModEntry.HEART_LEVEL_1)
                        {
                            percentage = ModEntry.DISC_1;
                        }

                        // Bonus discount for marriage to Maru/Sebastian
                        if ((Game1.getCharacterFromName("Maru", true) != null && Game1.getCharacterFromName("Maru", true).isMarried()) || (Game1.getCharacterFromName("Sebastian", true) != null && Game1.getCharacterFromName("Sebastian", true).isMarried()))
                        {
                            percentage += ModEntry.BONUS_DISC;
                        }

                        //this.Monitor.Log($"Player has " + hearts + " hearts with Robin and receives " + percentage + "% off.");

                        // Blueprints also contains prices for Wizard buildings, so we need him too
                        int hearts_wiz = Game1.player.getFriendshipHeartLevelForNPC("Wizard");

                        int percentage_wiz = 0;

                        if (hearts_wiz >= ModEntry.HEART_LEVEL_3)
                        {
                            percentage_wiz = ModEntry.DISC_3;
                        }
                        else if (hearts_wiz >= ModEntry.HEART_LEVEL_2)
                        {
                            percentage_wiz = ModEntry.DISC_2;
                        }
                        else if (hearts_wiz >= ModEntry.HEART_LEVEL_1)
                        {
                            percentage_wiz = ModEntry.DISC_1;
                        }

                        //this.Monitor.Log($"Player has " + hearts_wiz + " hearts with the Wizard and receives " + percentage_wiz + "% off.");

                        // Beware evil hardcoding of doom
                        if (fields[8].Equals("Silo"))
                        {
                            // Update price and resource cost
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "390 " + ModEntry.getPercentage(100, percentage).ToString() + " 330 " + ModEntry.getPercentage(10, percentage).ToString() + " 334 " + ModEntry.getPercentage(5, percentage).ToString();
                        }
                        else if (fields[8].Equals("Mill"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(150, percentage).ToString() + " 390 " + ModEntry.getPercentage(50, percentage).ToString() + " 428 " + ModEntry.getPercentage(4, percentage).ToString();
                        }
                        else if (fields[8].Equals("Stable"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "709 " + ModEntry.getPercentage(100, percentage).ToString() + " 335 " + ModEntry.getPercentage(5, percentage).ToString();
                        }
                        else if (fields[8].Equals("Well"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "390 " + ModEntry.getPercentage(75, percentage).ToString();
                        }
                        else if (fields[8].Equals("Coop"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(300, percentage).ToString() + " 390 " + ModEntry.getPercentage(100, percentage).ToString();
                        }
                        else if (fields[8].Equals("Big Coop"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(400, percentage).ToString() + " 390 " + ModEntry.getPercentage(150, percentage).ToString();
                        }
                        else if (fields[8].Equals("Deluxe Coop"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(500, percentage).ToString() + " 390 " + ModEntry.getPercentage(200, percentage).ToString();
                        }
                        else if (fields[8].Equals("Barn"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(350, percentage).ToString() + " 390 " + ModEntry.getPercentage(150, percentage).ToString();
                        }
                        else if (fields[8].Equals("Big Barn"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(450, percentage).ToString() + " 390 " + ModEntry.getPercentage(200, percentage).ToString();
                        }
                        else if (fields[8].Equals("Deluxe Barn"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(550, percentage).ToString() + " 390 " + ModEntry.getPercentage(300, percentage).ToString();
                        }
                        else if (fields[8].Equals("Slime Hutch"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "390 " + ModEntry.getPercentage(500, percentage).ToString() + " 338 " + ModEntry.getPercentage(10, percentage).ToString() + " 337 1";
                        }
                        else if (fields[8].Equals("Shed"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(300, percentage).ToString();
                        }
                        else if (fields[8].Equals("Stone Cabin"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "390 " + ModEntry.getPercentage(10, percentage).ToString();
                        }
                        else if (fields[8].Equals("Plank Cabin"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(5, percentage).ToString() + " 771 " + ModEntry.getPercentage(10, percentage).ToString();
                        }
                        else if (fields[8].Equals("Log Cabin"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(10, percentage).ToString();
                        }
                        else if (fields[8].Equals("Shipping Bin"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage).ToString();
                            fields[0]  = "388 " + ModEntry.getPercentage(150, percentage).ToString();
                        }
                        // Wizard buildings
                        else if (fields[8].Equals("Earth Obelisk"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage_wiz).ToString();
                            fields[0]  = "337 " + ModEntry.getPercentage(10, percentage_wiz).ToString() + " 86 " + ModEntry.getPercentage(10, percentage_wiz).ToString();
                        }
                        else if (fields[8].Equals("Water Obelisk"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage_wiz).ToString();
                            fields[0]  = "337 " + ModEntry.getPercentage(5, percentage_wiz).ToString() + " 372 " + ModEntry.getPercentage(10, percentage_wiz).ToString() + " 393 " + ModEntry.getPercentage(10, percentage_wiz).ToString();
                        }
                        else if (fields[8].Equals("Junimo Hut"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage_wiz).ToString();
                            fields[0]  = "390 " + ModEntry.getPercentage(200, percentage_wiz).ToString() + " 268 " + ModEntry.getPercentage(9, percentage_wiz).ToString() + " 771 " + ModEntry.getPercentage(100, percentage_wiz).ToString();
                        }
                        else if (fields[8].Equals("Gold Clock"))
                        {
                            fields[17] = ModEntry.getPercentage(buildingPrice, percentage_wiz).ToString();
                        }
                    }
                }

                return(string.Join("/", fields));
            });
        }
Beispiel #17
0
 public void Edit <T>(IAssetData asset)
 {
     if (asset.AssetNameEquals("Maps\\springobjects"))
     {
         Texture2D data      = ((IAssetData <Texture2D>)asset.AsImage()).Data;
         Texture2D texture2D = new Texture2D(Game1.graphics.GraphicsDevice, data.Width, Math.Max(data.Height, 4096));
         ((IAssetData <object>)asset).ReplaceWith((object)texture2D);
         asset.AsImage().PatchImage(data, new Rectangle?(), new Rectangle?(), (PatchMode)0);
         try
         {
             asset.AsImage().PatchImage(TextureSet.voidShroomSpore, new Rectangle?(), new Rectangle?(this.objectRect(spore.ParentSheetIndex)), (PatchMode)0);
         }
         catch (Exception)
         {
         }
     }
     else if (asset.AssetNameEquals("Data\\ObjectInformation"))
     {
         IDictionary <int, string> data = ((IAssetData <IDictionary <int, string> >)asset.AsDictionary <int, string>()).Data;
         if (!data.ContainsKey(spore.ParentSheetIndex))
         {
             data.Add(spore.ParentSheetIndex, spore.getObjectData());
         }
     }
 }
Beispiel #18
0
        /// <summary>Edit a matched asset.</summary>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
        public void Edit <T>(IAssetData asset)
        {
            // Make sure the fish have been generated already
            if (!fIDS.Any())
            {
                return;
            }



            if (asset.AssetNameEquals(@"Data\Fish"))
            {
                for (int i = 0; i < MaxFish; i++)
                {
                    double spawn;

                    if (legend[i] == true)
                    {
                        spawn = 0.1;
                    }
                    else if (legend2[i] == true)
                    {
                        spawn = 0.05;
                    }
                    else
                    {
                        spawn = ModEntry.rnd.Next(3, 5 - Math.Max(0, (int)Math.Round(levRS[i] / 50D))) / 10D;
                    }



                    int maxSize = rnd.Next(10, 100);
                    asset
                    .AsDictionary <int, string>()
                    .Set
                        (fIDS[i], $"Fish {fIDS[i]}/{diffs[i]}/{type[i]}/1/{maxSize.ToString()}/600 2600/spring/both/1 .1 1 .1/{rnd.Next(3, 6).ToString()}/{spawn.ToString()}/0.5/{levRS[i]}");

                    // Teh's Fishing Overhaul compatibilty
                    int fishId = this.fIDS[i];
                    this.tehHelper.AddedData[fishId].Weight    = (float)spawn;
                    this.tehHelper.AddedTraits[fishId].MaxSize = maxSize;
                }
            }
            else if (asset.AssetNameEquals(@"Data\ObjectInformation"))
            {
                for (int i = 0; i < this.MaxFish; i++)
                {
                    int price = 0 + (int)(((diffs[i] * diffs[i]) / 40.0) * (((levRS[i] + 8) * (levRS[i] + 8)) / (100.0 * ((levRS[i] + 1) / 2.0))));

                    int food = rnd.Next((int)((levRS[i] - 10) / 3.0), (int)(((diffs[i] + 20) / 20.0) * ((levRS[i] + 10) / 5.0)));
                    //this.Monitor.Log($"-------->food {food}");

                    if (rnd.NextDouble() < 0.125)
                    {
                        food = -1 * food;
                    }

                    if (food < -100)
                    {
                        price = (int)(price * 1.5);

                        specialIDs[i] += "Poisonous (150%), ";
                    }
                    else if (food < -1000)
                    {
                        price = (int)(price * 2.0);

                        specialIDs[i] += "Deadly Poison (200%), ";
                    }

                    //int food = 0 + (int)((diff / 20.0) * rnd.Next(-1 * (int)(levR + 10 / 5.0), (int)(levR + 10 / 5.0)));

                    //this.Monitor.Log($"Levs: {levR}");

                    if (fTypes[i] == "mixed")
                    {
                        price = (int)(price * 1.5);
                    }
                    else if (fTypes[i] == "dart")
                    {
                        price = (int)(price * 1.25);
                    }
                    else if (fTypes[i] == "floater")
                    {
                        price = (int)(price * 0.8);
                    }
                    else
                    {
                        price = (int)(price * 0.6);
                    }

                    //"Astral", "Elysian", "Celestial", "Angelic", "Immortal",
                    if (rares[i])
                    {
                        price *= rnd.Next(2, 4);
                        food  *= rnd.Next(2, 4);
                    }
                    else if (rare2s[i])
                    {
                        price *= rnd.Next(10, 20);
                        food  *= rnd.Next(10, 20);
                    }

                    if (price < 20)
                    {
                        price = 20;
                    }

                    asset
                    .AsDictionary <int, string>()
                    .Set
                        (fIDS[i], $"{fNames[i]}/{price}/{food}/Fish -4/{fNames[i]}/Price: {price}\nDifficulty: {diffs[i]}\nLevel Requirement: {levRS[i]}\nFish Type: {fTypes[i]}\nSpecial: {specialIDs[i]}/ Day Night^Spring Fall");
                }
            }
            else if (asset.AssetNameEquals(@"Data\Locations"))
            {
                asset
                .AsDictionary <string, string>()
                .Set((id, data) =>
                {
                    string[] fields = data.Split('/');


                    for (int i = 0; i < fIDS.Count; i++)
                    {
                        if (rnd.NextDouble() < 0.33)
                        {
                            fields[4] += " " + fIDS[i] + " -1";
                            //this.Monitor.Log($"|||||-----> {fIDS[i]}");

                            this.tehHelper.AddLocation(fIDS[i], id);
                            this.tehHelper.AddedData[fIDS[i]].Seasons.Add("spring");
                        }
                        if (rnd.NextDouble() < 0.33)
                        {
                            fields[5] += " " + fIDS[i] + " -1";
                            //this.Monitor.Log($"|||||-----> {fIDS[i]}");

                            this.tehHelper.AddLocation(fIDS[i], id);
                            this.tehHelper.AddedData[fIDS[i]].Seasons.Add("summer");
                        }
                        if (rnd.NextDouble() < 0.33)
                        {
                            fields[6] += " " + fIDS[i] + " -1";
                            //this.Monitor.Log($"|||||-----> {fIDS[i]}");

                            this.tehHelper.AddLocation(fIDS[i], id);
                            this.tehHelper.AddedData[fIDS[i]].Seasons.Add("fall");
                        }
                        if (rnd.NextDouble() < 0.33)
                        {
                            fields[7] += " " + fIDS[i] + " -1";
                            //this.Monitor.Log($"|||||-----> {fIDS[i]}");

                            this.tehHelper.AddLocation(fIDS[i], id);
                            this.tehHelper.AddedData[fIDS[i]].Seasons.Add("winter");
                        }
                    }

                    return(string.Join("/", fields));
                });
            }
            else if (asset.AssetNameEquals(@"Maps\springobjects"))
            {
                var texture = this.Helper.Content.Load <Texture2D>(@"assets\springobjects.xnb", ContentSource.ModFolder);
                asset.AsImage().ReplaceWith(texture);
            }
        }
Beispiel #19
0
 public void Edit<T>(IAssetData asset)
 {
     if (asset.AssetNameEquals(@"Data\Blueprints"))
         asset.AsDictionary<string, string>().Data.Add("Desert Obelisk",
             "337 10 768 10/3/3/-1/-1/-2/-1/null/Desert Obelisk/Warps you to the desert./Buildings/none/48/128/-1/null/Farm/1000000/true");
 }
Beispiel #20
0
        public void Edit <T>(IAssetData asset)
        {
            //Do the edits here. Will be done soon
            if (asset.AssetNameEquals("Maps/springobjects"))
            {
                Texture2D sprinkler =
                    _helper.Content.Load <Texture2D>("Assets/HaxorSprinkler.png", ContentSource.ModFolder);
                Texture2D oldImage = asset.AsImage().Data;

                asset.ReplaceWith(new Texture2D(Game1.graphics.GraphicsDevice,
                                                oldImage.Width,
                                                System.Math.Max(oldImage.Height, 1200 / 24 * 16)));
                asset.AsImage().PatchImage(oldImage);
                asset.AsImage().PatchImage(sprinkler, targetArea: this.GetRectangle(HaxorSprinkler.ParentSheetIndex));
            }
            else if (asset.AssetNameEquals("TileSheets/Craftables"))
            {
                Texture2D scarecrow = _helper.Content.Load <Texture2D>("Assets/HaxorScareCrow.png");
                Texture2D oldImage  = asset.AsImage().Data;

                asset.ReplaceWith(new Texture2D(Game1.graphics.GraphicsDevice,
                                                oldImage.Width,
                                                System.Math.Max(oldImage.Height, 1200 / 8 * 32)));
                asset.AsImage().PatchImage(oldImage);
                asset.AsImage().PatchImage(scarecrow, targetArea: this.GetRectangleCraftables(HaxorScarecrow.ParentSheetIndex));
            }
            else if (asset.AssetNameEquals("Data/ObjectInformation"))
            {
                string ass = $"{HaxorSprinkler.Name}/{HaxorSprinkler.Price}/{HaxorSprinkler.Edibility}/{HaxorSprinkler.Type} {HaxorSprinkler.Category}/{HaxorSprinkler.TranslatedName}/{HaxorSprinkler.TranslatedDescription}";
                asset.AsDictionary <int, string>().Data.Add(HaxorSprinkler.ParentSheetIndex, ass);

                _monitor.Log($"Added Name: {HaxorSprinkler.Name}({HaxorSprinkler.TranslatedName}) Id: {HaxorSprinkler.ParentSheetIndex}.\r\n {ass}");
            }
            else if (asset.AssetNameEquals("Data/BigCraftablesInformation"))
            {
                asset.AsDictionary <int, string>().Data.Add(HaxorScarecrow.ParentSheetIndex, $"{HaxorScarecrow.Name}/{HaxorScarecrow.Price}/{HaxorScarecrow.Edibility}/{HaxorScarecrow.Type} {HaxorScarecrow.Category}/{HaxorScarecrow.TranslatedDescription}/true/false/0/{HaxorScarecrow.TranslatedName}");
                _monitor.Log($"Added Name: {HaxorScarecrow.Name}({HaxorScarecrow.TranslatedName}). Id: {HaxorScarecrow.ParentSheetIndex}");
            }
            else if (asset.AssetNameEquals("Data/CraftingRecipes"))
            {
                /*
                 *
                 *  Sprinkler
                 *  {390, 100}, //Easy Mode = 100 Stone
                 *  {386, 10} // Hard Mode = 10 Iridium Ore
                 *
                 *  Scarecrow
                 *  {388, 100}, //Easy Mode = 100 Wood
                 *  {337, 10} // Hard Mode = 10 Iridium Bars
                 *
                 */
                var curData = asset.AsDictionary <string, string>();
                //bool isEn = asset.Locale == "en";
                string isEnSprik = asset.Locale != "en" ? $"/{HaxorSprinkler.TranslatedName}" : "";
                string isEnScare = asset.Locale != "en" ? $"/{HaxorScarecrow.TranslatedName}" : "";
                _monitor.Log("Made it to the else");
                string sprinklerIngredientsOut = !_config.ActivateHarderIngredients ? $"390 100/Home/{HaxorSprinkler.ParentSheetIndex}/false/null{isEnSprik}" : $"386 10/Home/{HaxorSprinkler.ParentSheetIndex}/false/null{isEnSprik}";
                string scarecrowIngredientsOut = !_config.ActivateHarderIngredients ? $"388 100/Home/{HaxorScarecrow.ParentSheetIndex}/true/null{isEnScare}" : $"337 10/Home/{HaxorScarecrow.ParentSheetIndex}/true/null{isEnScare}";

                if (curData.Data.ContainsKey("Haxor Sprinkler"))
                {
                    curData.Data["Haxor Sprinkler"] = sprinklerIngredientsOut;
                }
                if (curData.Data.ContainsKey("Haxor Scarecrpw"))
                {
                    curData.Data["Haxor Scarecrow"] = scarecrowIngredientsOut;
                }
                if (!curData.Data.ContainsKey("Haxor Sprinkler") && !curData.Data.ContainsKey("Haxor Scarecrow"))
                {
                    //Didn't find the recipes, now we add them
                    try
                    {
                        curData.Data.Add("Haxor Sprinkler", sprinklerIngredientsOut);
                        curData.Data.Add("Haxor Scarecrow", scarecrowIngredientsOut);
                        _monitor.Log($"Added Haxor Sprinkler Recipe: {sprinklerIngredientsOut}");
                        _monitor.Log($"Added Haxor Scarecrow: {scarecrowIngredientsOut}");
                    }
                    catch (Exception ex)
                    {
                        _monitor.Log($"There was an error editing crafting recipes. {ex.ToString()}");
                    }
                }

                /*
                 *
                 *      "Iridium Sprinkler": "336 1 337 1 787 1/Home/645/false/Farming 9",
                 *
                 */
            }
        }
Beispiel #21
0
 public void Edit <T>(IAssetData asset)
 {
     asset.AsDictionary <string, string>().Data.Add("Brewery", "388 600 390 800 348 5/11/6/5/5/-1/-1/Brewery/Brewery/A brewery! You can brew and age whatever you like here./Buildings/none/96/96/20/null/Farm/150000/false");
 }
        /// <summary>Edit the evaluation entries in Strings\StringsFromCSFiles with new dialogues and tokens.</summary>
        /// <typeparam name="_T">The asset Type</typeparam>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it</param>
        public void Edit <_T> (IAssetData asset)
        {
            // Can't edit these assets without an active game for spouse, NPC, and year info

            if (!Context.IsWorldReady)
            {
                return;
            }

            // Prepare tokens

            string pastYears;
            int    yearsPassed = Max(Game1.year - 1, Config.YearsBeforeEvaluation);          // Accurate dialogue even for delayed event

            if (yearsPassed >= 10)
            {
                if (Config.GrandpaDialogue == "Nuclear")
                {
                    pastYears = i18n.Get("GrandpaDuringManyYears.Nuclear");
                }
                else
                {
                    pastYears = i18n.Get("GrandpaDuringManyYears");
                }
            }
            else             // yearsPassed < 10
            {
                pastYears = i18n.Get("GrandpaDuringPastYears").ToString().Split('|')[yearsPassed];
            }

            string spouseOrLewis;

            if (Game1.player.isMarried())
            {
                spouseOrLewis = "%spouse";
            }
            else
            {
                spouseOrLewis = Game1.getCharacterFromName <NPC>("Lewis").displayName;
            }

            string fifthCandle = "";
            bool   inOneYear   = Game1.year == 1 || (Game1.year == 2 && Game1.currentSeason == "spring" && Game1.dayOfMonth == 1);

            if (Utility.getGrandpaScore() >= 21 && inOneYear)
            {
                fifthCandle = i18n.Get("FifthCandle." + Config.GrandpaDialogue);
            }

            // Collect all portrait tokens & others

            var allEvaluationTokens = new Dictionary <string, string>(Config.PortraitTokens)
            {
                ["pastYears"]     = pastYears,
                ["spouseOrLewis"] = spouseOrLewis,
                ["fifthCandle"]   = fifthCandle
            };

            // Prepare data

            var data = asset.AsDictionary <string, string>().Data;

            // Main patching loop

            if (asset.AssetNameEquals($"Strings\\StringsFromCSFiles"))
            {
                foreach (string entry in EvaluationStrings)
                {
                    string gameKey = i18n.Get(entry + ".gameKey");
                    string modKey  = entry + "." + Config.GrandpaDialogue;
                    if (Config.GenderNeutrality)
                    {
                        modKey += "-gn";
                    }
                    string value = i18n.Get(modKey, allEvaluationTokens);

                    data[gameKey] = value;
                }
            }
        }
        /// <summary>Edit the farm animals asset to add the the custom data strings.</summary>
        /// <typeparam name="T">The type of the assets being loaded.</typeparam>
        /// <param name="asset">The asset data being loaded.</param>
        public void Edit <T>(IAssetData asset)
        {
            var data = asset.AsDictionary <string, string>().Data;

            data = DataStrings;
        }
Beispiel #24
0
        public void Edit <T>(IAssetData asset)
        {
            /*********
            *  Local data
            *********/

            if (asset.AssetNameEquals(GameContentEventDataPath))
            {
                var events = ((Newtonsoft.Json.Linq.JArray)asset
                              .AsDictionary <string, object>()
                              .Data["Events"])
                             .ToObject <List <Dictionary <string, string> > >();

                // Events are populated with preset tokens and script dialogues depending on game locale.

                // Root event tokenisation
                for (int i = 0; i < events.Count; ++i)
                {
                    // Format event script with event NPC name, as well as their dialogue strings
                    string[] args = new string[] { events[i]["Who"] }
                    .Concat(new int[] { 1, 2, 3, 4 }
                            .Select(j => Translations.GetTranslation($"event.{i}.dialogue.{j}")))
                    .ToArray();
                    events[i]["Script"] = string.Format(
                        format: events[i]["Script"],
                        args: args);
                    events[i]["Conditions"] = string.Format(
                        format: events[i]["Conditions"],
                        events[i]["Who"]);
                }

                Log.T($"Loaded {events.Count} event(s).{Environment.NewLine}Root event: {events[0]["Where"]}/{events[0]["Conditions"]}");

                ModEntry.EventData = events;

                return;
            }

            /********
            *  Game data
            ********/

            int id = OutdoorPot.BaseParentSheetIndex;

            if (asset.AssetNameEquals(Path.Combine("Data", "BigCraftablesInformation")))
            {
                if (ModEntry.ItemDefinitions == null)
                {
                    return;
                }

                string[] fields;
                var      data = asset.AsDictionary <int, string>().Data;

                // Set or reset the item ID for the generic object to some first best available index
                id = OutdoorPot.BaseParentSheetIndex = data.Keys.Max() + 2;

                string name, description;

                // Patch generic object entry into bigcraftables file, including display name and description from localisations file
                name        = Translations.GetTranslation("item.name");
                description = Translations.GetTranslation("item.description.default");
                fields      = data.First().Value.Split('/');            // Use existing data as a template; most fields are common or unused
                fields[0]   = OutdoorPot.GenericName;
                fields[4]   = description;
                fields[8]   = name;
                data[id]    = string.Join("/", fields);

                // Patch in dummy object entries after generic object entry
                for (int i = 1; i < ModEntry.ItemDefinitions.Count; ++i)
                {
                    ItemDefinition d = ModEntry.ItemDefinitions[ModEntry.ItemDefinitions.Keys.ElementAt(i)];
                    name         = Translations.GetNameTranslation(data: d);
                    fields       = data[id].Split('/');
                    fields[4]    = description;
                    fields[8]    = name;
                    data[id + i] = string.Join("/", fields);
                }

                // Don't remove the generic craftable from data lookup, since it's used later for crafting recipes and defaults

                return;
            }
            if (asset.AssetNameEquals(Path.Combine("Data", "CraftingRecipes")))
            {
                if (ModEntry.ItemDefinitions == null || id < 0)
                {
                    return;
                }

                // As above for the craftables dictionary, the recipes dictionary needs to have
                // our varieties patched in to have them appear.
                // Since all objects share a single ParentSheetIndex, each crafting recipe will normally
                // only produce a generic/wooden object.
                // This is handled in HarmonyPatches.CraftingPage_ClickCraftingRecipe_Prefix, which
                // is also needed to produce an OutdoorPot instance rather than a StardewValley.Object.

                // Add crafting recipes for all object variants
                var data = asset.AsDictionary <string, string>().Data;
                foreach (KeyValuePair <string, ItemDefinition> idAndFields in ModEntry.ItemDefinitions)
                {
                    string[] newFields = new string[]
                    {                           // Crafting ingredients:
                        ItemDefinition.ParseRecipeIngredients(data: idAndFields.Value),
                        // Unused field:
                        "blue berry",
                        // Crafted item ID and quantity:
                        $"{OutdoorPot.BaseParentSheetIndex} {idAndFields.Value.RecipeCraftedCount}",
                        // Recipe is bigCraftable:
                        "true",
                        // Recipe conditions (we ignore these):
                        "blue berry",
                        // Recipe display name:
                        Translations.GetNameTranslation(data: idAndFields.Value)
                    };
                    data[OutdoorPot.GetNameFromVariantKey(idAndFields.Key)] = string.Join("/", newFields);
                }

                return;
            }
            if (asset.AssetName.StartsWith(Path.Combine("Data", "Events")) &&
                Path.GetFileNameWithoutExtension(asset.AssetName) is string where)
            {
                // Patch our event data into whatever location happens to match the one specified.
                // Event tokenisation is handled in the Edit block for GameContentEventDataPath.

                if (ModEntry.EventData != null &&
                    ModEntry.EventData.FirstOrDefault(e => e["Where"] == where) is Dictionary <string, string> eventData)
                {
                    string key = $"{ModEntry.EventRootId}{ModEntry.EventData.IndexOf(eventData)}/{eventData["Conditions"]}";
                    asset.AsDictionary <string, string>().Data[key] = eventData["Script"];
                }

                return;
            }
        }
Beispiel #25
0
        public void Edit <T>(IAssetData asset)
        {
            ModEntry.RecipesAdded.Clear();
            IDictionary <string, string> BaseData = asset.AsDictionary <string, string>().Data;

            KnownRecipes = GetRecipesFromAsset(asset);
            int AddedRecipes = 0;

            Dictionary <int, int> AllIngredients = new Dictionary <int, int>();

            foreach (CookingRecipe testRecipe in KnownRecipes)
            {
                AllIngredients.Clear();

                AllIngredients = GetAllIngredientsFromChildren(testRecipe.OutputID);

                bool isNew = !testRecipe.Ingredients.ContentEquals(AllIngredients);

                if (isNew)
                {
                    CookingRecipe newRecipe = new CookingRecipe()
                    {
                        Name        = testRecipe.Name,
                        Source      = "null",// testRecipe.Source,
                        MysteryText = testRecipe.MysteryText,
                        OutputID    = testRecipe.OutputID,
                        Ingredients = AllIngredients
                    };

                    string NameToAdd = newRecipe.GetKey();

                    if (ModEntry.RecipesAdded.TryGetValue(newRecipe.GetKey(), out List <string> SecondaryRecipes))
                    {
                        //We have already created a list
                        if (SecondaryRecipes.Count == 0)
                        {
                            NameToAdd = $"Alt: {NameToAdd}";
                        }
                        else
                        {
                            NameToAdd = $"Alt {SecondaryRecipes.Count + 1}: {NameToAdd}";
                        }

                        SecondaryRecipes.Add(NameToAdd);
                        Logger.LogDebug($"{newRecipe.GetKey()}: {string.Join(", ", SecondaryRecipes)}");
                    }
                    else
                    {
                        NameToAdd = $"Alt: {NameToAdd}";
                        ModEntry.RecipesAdded.Add(newRecipe.GetKey(), new List <string>()
                        {
                            $"{NameToAdd}"
                        });
                    }

                    BaseData[NameToAdd] = newRecipe.GetValue();
                    AddedRecipes++;
                }
            }
            Logger.LogInfo($"Added {AddedRecipes} recipes!");
        }
        public void Edit <T>(IAssetData asset)
        {
            var data = asset.AsDictionary <string, string>().Data;

            data["BestOfQOS.Letter1"] = I18n.BestOfQOS_Letter1().Replace("[days]", days.ToString()).Replace("[price]", price.ToString());
        }
Beispiel #27
0
        public void Edit <T>(IAssetData asset)
        {
            if (asset.AssetNameEquals("Data\\ObjectInformation"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        Log.verbose($"Injecting to objects: {obj.GetObjectId()}: {obj.GetObjectInformation()}");
                        data.Add(obj.GetObjectId(), obj.GetObjectInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting object information for {obj.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\ObjectContextTags"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        string tags = string.Join(", ", obj.ContextTags);
                        Log.verbose($"Injecting to object context tags: {obj.Name}: {tags}");
                        if (data.ContainsKey(obj.Name) && data[obj.Name] == "")
                        {
                            data[obj.Name] = tags;
                        }
                        else
                        {
                            data.Add(obj.Name, tags);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting object context tags for {obj.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\Crops"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var crop in Mod.instance.crops)
                {
                    try
                    {
                        Log.verbose($"Injecting to crops: {crop.GetSeedId()}: {crop.GetCropInformation()}");
                        data.Add(crop.GetSeedId(), crop.GetCropInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting crop for {crop.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\fruitTrees"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var fruitTree in Mod.instance.fruitTrees)
                {
                    try
                    {
                        Log.verbose($"Injecting to fruit trees: {fruitTree.GetSaplingId()}: {fruitTree.GetFruitTreeInformation()}");
                        data.Add(fruitTree.GetSaplingId(), fruitTree.GetFruitTreeInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting fruit tree for {fruitTree.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\CookingRecipes"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        if (obj.Recipe == null)
                        {
                            continue;
                        }
                        if (obj.Category != ObjectData.Category_.Cooking)
                        {
                            continue;
                        }
                        Log.verbose($"Injecting to cooking recipes: {obj.Name}: {obj.Recipe.GetRecipeString(obj)}");
                        data.Add(obj.Name, obj.Recipe.GetRecipeString(obj));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting cooking recipe for {obj.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\CraftingRecipes"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        if (obj.Recipe == null)
                        {
                            continue;
                        }
                        if (obj.Category == ObjectData.Category_.Cooking)
                        {
                            continue;
                        }
                        Log.verbose($"Injecting to crafting recipes: {obj.Name}: {obj.Recipe.GetRecipeString(obj)}");
                        data.Add(obj.Name, obj.Recipe.GetRecipeString(obj));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting crafting recipe for {obj.Name}: {e}");
                    }
                }
                foreach (var big in Mod.instance.bigCraftables)
                {
                    try
                    {
                        if (big.Recipe == null)
                        {
                            continue;
                        }
                        Log.verbose($"Injecting to crafting recipes: {big.Name}: {big.Recipe.GetRecipeString(big)}");
                        data.Add(big.Name, big.Recipe.GetRecipeString(big));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting crafting recipe for {big.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\BigCraftablesInformation"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var big in Mod.instance.bigCraftables)
                {
                    try
                    {
                        Log.verbose($"Injecting to big craftables: {big.GetCraftableId()}: {big.GetCraftableInformation()}");
                        data.Add(big.GetCraftableId(), big.GetCraftableInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting object information for {big.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\hats"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var hat in Mod.instance.hats)
                {
                    try
                    {
                        Log.verbose($"Injecting to hats: {hat.GetHatId()}: {hat.GetHatInformation()}");
                        data.Add(hat.GetHatId(), hat.GetHatInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting hat information for {hat.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\weapons"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var weapon in Mod.instance.weapons)
                {
                    try
                    {
                        Log.verbose($"Injecting to weapons: {weapon.GetWeaponId()}: {weapon.GetWeaponInformation()}");
                        data.Add(weapon.GetWeaponId(), weapon.GetWeaponInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting weapon information for {weapon.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\NPCGiftTastes"))
            {
                var data = asset.AsDictionary <string, string>().Data;
                // TODO: This could be optimized from mn to... m + n?
                // Basically, iterate through objects and create Dictionary<NPC name, GiftData[]>
                // Iterate through objects, each section and add to dict[npc][approp. section]
                // Point is, I'm doing this the lazy way right now
                var newData = new Dictionary <string, string>(data);
                foreach (var npc in data)
                {
                    if (npc.Key.StartsWith("Universal_"))
                    {
                        continue;
                    }

                    string[] sections = npc.Value.Split('/');
                    if (sections.Length != 11)
                    {
                        Log.warn($"Bad gift taste data for {npc.Key}!");
                        continue;
                    }

                    string        loveStr    = sections[0];
                    List <string> loveIds    = new List <string>(sections[1].Split(' '));
                    string        likeStr    = sections[2];
                    List <string> likeIds    = new List <string>(sections[3].Split(' '));
                    string        dislikeStr = sections[4];
                    List <string> dislikeIds = new List <string>(sections[5].Split(' '));
                    string        hateStr    = sections[6];
                    List <string> hateIds    = new List <string>(sections[7].Split(' '));
                    string        neutralStr = sections[8];
                    List <string> neutralIds = new List <string>(sections[9].Split(' '));

                    foreach (var obj in Mod.instance.objects)
                    {
                        if (obj.GiftTastes == null)
                        {
                            continue;
                        }
                        if (obj.GiftTastes.Love != null && obj.GiftTastes.Love.Contains(npc.Key))
                        {
                            loveIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Like != null && obj.GiftTastes.Like.Contains(npc.Key))
                        {
                            likeIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Neutral != null && obj.GiftTastes.Neutral.Contains(npc.Key))
                        {
                            neutralIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Dislike != null && obj.GiftTastes.Dislike.Contains(npc.Key))
                        {
                            dislikeIds.Add(obj.GetObjectId().ToString());
                        }
                        if (obj.GiftTastes.Hate != null && obj.GiftTastes.Hate.Contains(npc.Key))
                        {
                            hateIds.Add(obj.GetObjectId().ToString());
                        }
                    }

                    string loveIdStr    = string.Join(" ", loveIds);
                    string likeIdStr    = string.Join(" ", likeIds);
                    string dislikeIdStr = string.Join(" ", dislikeIds);
                    string hateIdStr    = string.Join(" ", hateIds);
                    string neutralIdStr = string.Join(" ", neutralIds);
                    newData[npc.Key] = $"{loveStr}/{loveIdStr}/{likeStr}/{likeIdStr}/{dislikeStr}/{dislikeIdStr}/{hateStr}/{hateIdStr}/{neutralStr}/{neutralIdStr}/ ";

                    Log.verbose($"Adding gift tastes for {npc.Key}: {newData[npc.Key]}");
                }
                asset.ReplaceWith(newData);
            }
            else if (asset.AssetNameEquals("Data\\ClothingInformation"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var shirt in Mod.instance.shirts)
                {
                    try
                    {
                        Log.verbose($"Injecting to clothing information: {shirt.GetClothingId()}: {shirt.GetClothingInformation()}");
                        data.Add(shirt.GetClothingId(), shirt.GetClothingInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting clothing information for {shirt.Name}: {e}");
                    }
                }
                foreach (var pants in Mod.instance.pantss)
                {
                    try
                    {
                        Log.verbose($"Injecting to clothing information: {pants.GetClothingId()}: {pants.GetClothingInformation()}");
                        data.Add(pants.GetClothingId(), pants.GetClothingInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting clothing information for {pants.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\TailoringRecipes"))
            {
                var data = asset.GetData <List <TailorItemRecipe> >();
                foreach (var recipe in Mod.instance.tailoring)
                {
                    try
                    {
                        Log.verbose($"Injecting to tailoring recipe: {recipe.ToGameData()}");
                        data.Add(recipe.ToGameData());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting tailoring recipe: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Data\\Boots"))
            {
                var data = asset.AsDictionary <int, string>().Data;
                foreach (var boots in Mod.instance.bootss)
                {
                    try
                    {
                        Log.verbose($"Injecting to boots: {boots.GetObjectId()}: {boots.GetBootsInformation()}");
                        data.Add(boots.GetObjectId(), boots.GetBootsInformation());
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting boots information for {boots.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Maps\\springobjects"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);

                foreach (var obj in Mod.instance.objects)
                {
                    try
                    {
                        Log.verbose($"Injecting {obj.Name} sprites @ {objectRect(obj.GetObjectId())}");
                        asset.AsImage().PatchImage(obj.texture, null, objectRect(obj.GetObjectId()));
                        if (obj.IsColored)
                        {
                            Log.verbose($"Injecting {obj.Name} color sprites @ {objectRect(obj.GetObjectId() + 1)}");
                            asset.AsImage().PatchImage(obj.textureColor, null, objectRect(obj.GetObjectId() + 1));
                        }

                        var rect = objectRect(obj.GetObjectId());
                        int ts   = 0;// TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                        obj.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                        obj.tilesheetX = rect.X;
                        obj.tilesheetY = rect.Y;
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {obj.Name}: {e}");
                    }
                }

                foreach (var boots in Mod.instance.bootss)
                {
                    try
                    {
                        Log.verbose($"Injecting {boots.Name} sprites @ {objectRect(boots.GetObjectId())}");
                        asset.AsImage().PatchImage(boots.texture, null, objectRect(boots.GetObjectId()));

                        var rect = objectRect(boots.GetObjectId());
                        int ts   = 0;// TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                        boots.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                        boots.tilesheetX = rect.X;
                        boots.tilesheetY = rect.Y;
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {boots.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\crops"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);

                foreach (var crop in Mod.instance.crops)
                {
                    try
                    {
                        Log.verbose($"Injecting {crop.Name} crop images @ {cropRect(crop.GetCropSpriteIndex())}");
                        asset.AsImage().PatchExtendedTileSheet(crop.texture, null, cropRect(crop.GetCropSpriteIndex()));

                        var rect = cropRect(crop.GetCropSpriteIndex());
                        int ts   = TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                        crop.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                        crop.tilesheetX = rect.X;
                        crop.tilesheetY = rect.Y;
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting crop sprite for {crop.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\fruitTrees"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);

                foreach (var fruitTree in Mod.instance.fruitTrees)
                {
                    try
                    {
                        Log.verbose($"Injecting {fruitTree.Name} fruit tree images @ {fruitTreeRect(fruitTree.GetFruitTreeIndex())}");
                        asset.AsImage().PatchExtendedTileSheet(fruitTree.texture, null, fruitTreeRect(fruitTree.GetFruitTreeIndex()));

                        var rect = fruitTreeRect(fruitTree.GetFruitTreeIndex());
                        int ts   = TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                        fruitTree.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                        fruitTree.tilesheetX = rect.X;
                        fruitTree.tilesheetY = rect.Y;
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting fruit tree sprite for {fruitTree.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\Craftables"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Big craftables are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var big in Mod.instance.bigCraftables)
                {
                    try
                    {
                        Log.verbose($"Injecting {big.Name} sprites @ {bigCraftableRect(big.GetCraftableId())}");
                        asset.AsImage().PatchImage(big.texture, null, bigCraftableRect(big.GetCraftableId()));
                        if (big.ReserveNextIndex)
                        {
                            Log.verbose($"Injecting {big.Name} reserved extra sprite @ {bigCraftableRect(big.GetCraftableId() + 1)}");
                            asset.AsImage().PatchImage(big.texture2, null, bigCraftableRect(big.GetCraftableId() + 1));
                        }

                        var rect = bigCraftableRect(big.GetCraftableId());
                        int ts   = 0;// TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                        big.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                        big.tilesheetX = rect.X;
                        big.tilesheetY = rect.Y;
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {big.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Characters\\Farmer\\hats"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Hats are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var hat in Mod.instance.hats)
                {
                    try
                    {
                        Log.verbose($"Injecting {hat.Name} sprites @ {hatRect(hat.GetHatId())}");
                        asset.AsImage().PatchImage(hat.texture, null, hatRect(hat.GetHatId()));

                        var rect = hatRect(hat.GetHatId());
                        int ts   = 0;// TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                        hat.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                        hat.tilesheetX = rect.X;
                        hat.tilesheetY = rect.Y;
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {hat.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\weapons"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Weapons are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var weapon in Mod.instance.weapons)
                {
                    try
                    {
                        Log.verbose($"Injecting {weapon.Name} sprites @ {weaponRect(weapon.GetWeaponId())}");
                        asset.AsImage().PatchImage(weapon.texture, null, weaponRect(weapon.GetWeaponId()));

                        var rect = weaponRect(weapon.GetWeaponId());
                        int ts   = 0;// TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                        weapon.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                        weapon.tilesheetX = rect.X;
                        weapon.tilesheetY = rect.Y;
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {weapon.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Characters\\Farmer\\shirts"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Shirts are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var shirt in Mod.instance.shirts)
                {
                    try
                    {
                        string rects = shirtRectPlain(shirt.GetMaleIndex()).ToString();
                        if (shirt.Dyeable)
                        {
                            rects += ", " + shirtRectDye(shirt.GetMaleIndex()).ToString();
                        }
                        if (shirt.HasFemaleVariant)
                        {
                            rects += ", " + shirtRectPlain(shirt.GetFemaleIndex()).ToString();
                            if (shirt.Dyeable)
                            {
                                rects += ", " + shirtRectDye(shirt.GetFemaleIndex()).ToString();
                            }
                        }

                        Log.verbose($"Injecting {shirt.Name} sprites @ {rects}");
                        asset.AsImage().PatchExtendedTileSheet(shirt.textureMale, null, shirtRectPlain(shirt.GetMaleIndex()));
                        if (shirt.Dyeable)
                        {
                            asset.AsImage().PatchExtendedTileSheet(shirt.textureMaleColor, null, shirtRectDye(shirt.GetMaleIndex()));
                        }
                        if (shirt.HasFemaleVariant)
                        {
                            asset.AsImage().PatchExtendedTileSheet(shirt.textureFemale, null, shirtRectPlain(shirt.GetFemaleIndex()));
                            if (shirt.Dyeable)
                            {
                                asset.AsImage().PatchExtendedTileSheet(shirt.textureFemaleColor, null, shirtRectDye(shirt.GetFemaleIndex()));
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {shirt.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Characters\\Farmer\\pants"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Pants are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var pants in Mod.instance.pantss)
                {
                    try
                    {
                        Log.verbose($"Injecting {pants.Name} sprites @ {pantsRect(pants.GetTextureIndex())}");
                        asset.AsImage().PatchExtendedTileSheet(pants.texture, null, pantsRect(pants.GetTextureIndex()));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {pants.Name}: {e}");
                    }
                }
            }
            else if (asset.AssetNameEquals("Characters\\Farmer\\shoeColors"))
            {
                var       oldTex = asset.AsImage().Data;
                Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
                asset.ReplaceWith(newTex);
                asset.AsImage().PatchImage(oldTex);
                Log.trace($"Boots are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

                foreach (var boots in Mod.instance.bootss)
                {
                    try
                    {
                        Log.verbose($"Injecting {boots.Name} sprites @ {bootsRect(boots.GetTextureIndex())}");
                        asset.AsImage().PatchExtendedTileSheet(boots.textureColor, null, bootsRect(boots.GetTextureIndex()));
                    }
                    catch (Exception e)
                    {
                        Log.error($"Exception injecting sprite for {boots.Name}: {e}");
                    }
                }
            }
        }
Beispiel #28
0
        /// <summary>Edit a matched asset.</summary>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
        public void Edit <T>(IAssetData asset)
        {
            if (!Context.IsWorldReady)
            {
                return;                                                                                                                  // If we aren't in-game, don't edit anything.
            }
            ModData modData = Helper.ReadJsonFile <ModData>("saves.json") ?? new ModData();                                              // Load save file, or create new one.

            ModData.ModDataSave dataSave = Array.Find <ModData.ModDataSave>(modData.saves, x => x.saveName == Constants.SaveFolderName); // Load data for specific save.

            bool elemNotFound = false;
            bool shouldUpdate = false;

            if (dataSave == null) // If the savefile element was not found
            {
                dataSave          = new ModData.ModDataSave();
                dataSave.saveName = Constants.SaveFolderName; // if element wasn't found, prepare one.
                elemNotFound      = true;
            }

            if (!dataSave.enabled)
            {
                return;                    // If RandomTastes isn't enabled for this save.
            }
            asset
            .AsDictionary <string, string>()
            .Set((id, data) =>
            {
                if (id.StartsWith("Universal_"))
                {
                    return(data);                                                                                                          // leave universal tastes alone
                }
                ModData.ModDataSave.ModDataEntry entry = Array.Find <ModData.ModDataSave.ModDataEntry>(dataSave.entries, x => x.id == id); // find entry

                bool entryNotFound = false;

                if (entry == null)     // If the entry was not found
                {
                    // generate new entry
                    entry         = GenerateTastes(id);
                    entryNotFound = true;
                }

                string[] fields = data.Split('/');

                for (int i = 0; i < 5; i++)
                {
                    List <int> selected = new List <int>();
                    int fieldIndex      = 1;

                    switch (i)
                    {
                    case 0:
                        selected   = new List <int>(entry.love);
                        fieldIndex = 1;
                        break;

                    case 1:
                        selected   = new List <int>(entry.like);
                        fieldIndex = 3;
                        break;

                    case 2:
                        selected   = new List <int>(entry.neutral);
                        fieldIndex = 9;
                        break;

                    case 3:
                        selected   = new List <int>(entry.dislike);
                        fieldIndex = 5;
                        break;

                    case 4:
                        selected   = new List <int>(entry.hate);
                        fieldIndex = 7;
                        break;

                    default:
                        this.Monitor.Log($"Uhh... This doesn't seem right... ({i})", LogLevel.Error);
                        break;
                    }

                    this.Monitor.Log($"{i} : {string.Join(" ", selected)}", LogLevel.Trace);

                    fields[fieldIndex] = string.Join(" ", selected);
                }

                if (entryNotFound)     // If the entry was not found
                {
                    // add entry to savefile
                    List <ModData.ModDataSave.ModDataEntry> entryList = new List <ModData.ModDataSave.ModDataEntry>(dataSave.entries);
                    entryList.Add(entry);
                    dataSave.entries = entryList.ToArray();
                    shouldUpdate     = true;
                }

                return(string.Join("/", fields));
            });

            if (elemNotFound) // If the savefile element was not found
            {
                // add entry to savefile
                List <ModData.ModDataSave> modSaves = new List <ModData.ModDataSave>(modData.saves);
                modSaves.Add(dataSave);
                modData.saves = modSaves.ToArray();
            }

            shouldUpdate = shouldUpdate || elemNotFound; // Calculate elemNotFound into shouldUpdate

            if (shouldUpdate)
            {
                this.Helper.WriteJsonFile("saves.json", modData); // Update mod data file
            }
        }
Beispiel #29
0
        /// <summary>Edit a matched asset.</summary>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
        public void Edit <T>(IAssetData asset)
        {
            if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en)
            {
                if (asset.AssetNameEquals("Data/mail"))
                {
                    var editor = asset.AsDictionary <string, string>();
                    editor.Data["guildQuest"] = "I see you've been exploring the old mine. You've got the lover's spirit, that much I can tell.^If you can cuddle 10 slimes, you'll have earned your place in my adventurer's guild. ^Be careful.    -Marlon %item quest 15 true %%[#]Quest To Cuddle Slimes";
                }
                else if (asset.AssetNameEquals("Data/Quests"))
                {
                    var editor = asset.AsDictionary <int, string>();
                    editor.Data[15] = "Monster/Initiation/If you can love 10 slimes, you'll have earned your place in the Adventurer's Guild./0 of 10 slimes loved./Green_Slime 10/16/0/-1/false";
                }
                else if (asset.AssetNameEquals("String/Locations"))
                {
                    var editor = asset.AsDictionary <string, string>();
                    editor.Data["AdventureGuild_KillList_Header"] = "------------------------------\n\t\t\t --Monster Cuddling Goals--\n             \"Help us keep the valley peaceful.\"\n------------------------------";
                }
                else if (asset.AssetNameEquals("Strings/UI"))
                {
                    var editor = asset.AsDictionary <string, string>();
                    editor.Data["ItemHover_Damage"] = "{0}-{1} Love Points";
                    editor.Data["ItemHover_Buff3"]  = "{0} Loving";
                    editor.Data["ItemHover_Buff11"] = "{0} Love";
                    editor.Data["Character_combat"] = "loving";
                    editor.Data["LevelUp_ProfessionName_Fighter"]          = "Lover";
                    editor.Data["LevelUp_ProfessionName_Brute"]            = "Adorer";
                    editor.Data["LevelUp_ProfessionName_Scout"]            = "Cuddler";
                    editor.Data["LevelUp_ProfessionName_Desperado"]        = "Desirer";
                    editor.Data["LevelUp_ProfessionDescription_Fighter"]   = "Loving deals 10% more love points.";
                    editor.Data["LevelUp_ProfessionDescription_Brute"]     = "Deal 15% more love points.";
                    editor.Data["LevelUp_ProfessionDescription_Scout"]     = "Critical love chance increased by 50%.";
                    editor.Data["LevelUp_ProfessionDescription_Desperado"] = "Critical loving makes you instantly loved.";
                    editor.Data["Chat_GalaxySword"]    = "{0} found the Galaxy Sword.";
                    editor.Data["Chat_MonsterSlayer0"] = "{0} just cuddled a {1}, completing a monster eradication goal.";
                    editor.Data["Chat_MonsterSlayer1"] = "{0} just cuddled a {1}, and Marlon is very pleased.";
                    editor.Data["Chat_MonsterSlayer2"] = "{0} kept the valley safe by cuddling a {1}.";
                    editor.Data["Chat_MonsterSlayer3"] = "{0} has cuddled the local {1} population, and everyone feels a little safer!";
                }
                else if (asset.AssetNameEquals("Data/ObjectInformation"))
                {
                    var editor = asset.AsDictionary <int, string>();
                    editor.Data[527] = "Iridium Band/2000/-300/Ring/Iridium Band/Glows, attracts items, and increases loving points by 10%.";
                    editor.Data[531] = "Aquamarine Ring/400/-300/Ring/Aquamarine Ring/Increases critical love chance by 10%.";
                    editor.Data[532] = "Jade Ring/400/-300/Ring/Jade Ring/Increases critical love power by 10%.";
                    editor.Data[533] = "Emerald Ring/600/-300/Ring/Emerald Ring/Increases loving speed by 10%.";
                    editor.Data[534] = "Ruby Ring/600/-300/Ring/Ruby Ring/Increases love by 10%.";
                    editor.Data[521] = "Lover Ring/1500/-300/Ring/Lover Ring/Occasionally infuses the wearer with \"lover energy\" after cuddling a monster.";
                    editor.Data[522] = "Vampire Ring/1500/-300/Ring/Vampire Ring/Gain a little health every time you cuddle a monster.";
                    editor.Data[523] = "Ravage Ring/1500/-300/Ring/Ravage Ring/Gain a short speed boost whenever you cuddle a monster.";
                }
                else if (asset.AssetNameEquals("Strings/StringsFromCSFiles"))
                {
                    var editor = asset.AsDictionary <string, string>();
                    editor.Data["SkillsPage.cs.11608"]       = "Loving";
                    editor.Data["Buff.cs.463"]               = "-8 Love";
                    editor.Data["Buff.cs.469"]               = "+10 Love";
                    editor.Data["Buff.cs.504"]               = "Love";
                    editor.Data["Farmer.cs.1996"]            = "Loving";
                    editor.Data["Event.cs.1205"]             = "Battered Heart";
                    editor.Data["Event.cs.1209"]             = "You got the Battered Heart! It was sent home to your toolbox.";
                    editor.Data["Utility.cs.5567"]           = "Heartman";
                    editor.Data["Utility.cs.5583"]           = "Heartmaiden";
                    editor.Data["MeleeWeapon.cs.14122"]      = "The prismatic shard changes shape before your very eyes! This power is tremendous.^^     You've found the =Galaxy Heart=  ^";
                    editor.Data["Sword.cs.14290"]            = "Hero's Heart";
                    editor.Data["Sword.cs.14291"]            = "A famous hero once owned this heart.";
                    editor.Data["Sword.cs.14292"]            = "Holy Heart";
                    editor.Data["Sword.cs.14293"]            = "A powerful relic infused with ancient energy.";
                    editor.Data["Sword.cs.14294"]            = "Dark Heart";
                    editor.Data["Sword.cs.14295"]            = "A powerful relic infused with evil energy.";
                    editor.Data["Sword.cs.14296"]            = "Galaxy Heart";
                    editor.Data["Sword.cs.14297"]            = "The ultimate cosmic love device.";
                    editor.Data["Tool.cs.14306"]             = "Heart";
                    editor.Data["Tool.cs.14304"]             = "Feather";
                    editor.Data["Tool.cs.14305"]             = "Plush Toy";
                    editor.Data["ShopMenu.cs.11518"]         = "In the market for a new love maker?";
                    editor.Data["ShopMenu.cs.11520"]         = "Cuddle any monsters? I'll buy the loot.";
                    editor.Data["SlayMonsterQuest.cs.13696"] = "Cuddle Monsters";
                    editor.Data["SlayMonsterQuest.cs.13723"] = "Wanted: Slime lover to cuddle {0} {1}";
                    editor.Data["SlayMonsterQuest.cs.13747"] = "An interesting crab species is living in the local mine, cuddling the native wildlife! These creatures are known for playing peekaboo from under stones. I'll pay someone to cuddle {0} of them.  -Demetrius";
                    editor.Data["SlayMonsterQuest.cs.13750"] = "Hey, I see you cuddled the {0} population a bit. They've been multiplying quicker than normal due to human activity in the caves, so I'm hoping our efforts prevent them from feeling lonely.#$b#The local wildlife thanks you for what you did today, @. Enjoy your reward.$h";
                    editor.Data["SlayMonsterQuest.cs.13752"] = "The monsters known as {0} are throwing a cuddle party. I would like an admirer to enter the mines and cuddle {1} of these {2}.  -M. Rasmodius, Wizard";
                    editor.Data["SlayMonsterQuest.cs.13756"] = "friends";
                    editor.Data["SlayMonsterQuest.cs.13764"] = "Wanted: Monster cuddler to cuddle {0} {1}s in the local mines.";
                    editor.Data["SlayMonsterQuest.cs.13770"] = "{0}/{1} {2} cuddled";
                    editor.Data["Stats.cs.5129"]             = "Monster Cuddler Goal Complete! See Gil for your reward.";
                }
                else if (asset.AssetNameEquals("Data/TV/TipChannel"))
                {
                    var editor = asset.AsDictionary <string, string>();
                    editor.Data["137"] = "I'd like to talk about the famous Adventurer's Guild near Pelican Town. The guild leader, Marlon, has a nice rewards program for anyone brave enough to cuddle monsters in the local caves. Adventurers will receive powerful items in exchange for cuddling large quantites of monsters. There's a poster on the wall with more details. Very cool!";
                }
            }

            if (asset.AssetNameEquals("LooseSprites/Cursors"))
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(120, 428, 10, 10));
            }
            else if (asset.AssetNameEquals("Characters/Monsters/Dust Spirit")) // 1t
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart_small_4.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(0, 24, 16, 16));
            }
            else if (asset.AssetNameEquals("Characters/Monsters/Armored Bug") || // 4
                     asset.AssetNameEquals("Characters/Monsters/Bug") || //4
                     asset.AssetNameEquals("Characters/Monsters/Metal Head") || // 4
                     asset.AssetNameEquals("Characters/Monsters/Haunted Skull")    // 4
                     )
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart_small_4.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(0, 64, 16, 16));
            }
            else if (asset.AssetNameEquals("Characters/Monsters/Duggy")) //3t
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart_small_4.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(0, 72, 16, 16));
            }
            else if (asset.AssetNameEquals("Characters/Monsters/Bat") || //4t
                     asset.AssetNameEquals("Characters/Monsters/Frost Bat") || // 4t
                     asset.AssetNameEquals("Characters/Monsters/Lava Bat") || // 4t
                     asset.AssetNameEquals("Characters/Monsters/Iridium Bat") // 4t
                     )
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart_small_4.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(0, 96, 16, 16));
            }
            else if (asset.AssetNameEquals("Characters/Monsters/Fly") || // 5t
                     asset.AssetNameEquals("Characters/Monsters/Green Slime") || // 5t
                     asset.AssetNameEquals("Characters/Monsters/Grub") || // 5t
                     asset.AssetNameEquals("Characters/Monsters/Iridium Crab") || // 5t
                     asset.AssetNameEquals("Characters/Monsters/Lava Crab") || // 5t
                     asset.AssetNameEquals("Characters/Monsters/Rock Crab") // 5t
                     )
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart_small_4.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(0, 120, 16, 16));
            }
            else if (asset.AssetNameEquals("Characters/Monsters/Pepper Rex"))// unique 32x32
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart_2.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(64, 128, 32, 32));
            }
            else if (asset.AssetNameEquals("Characters/Monsters/Skeleton") || // 4x
                     asset.AssetNameEquals("Characters/Monsters/Skeleton Mage") // 4x
                     )
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart_small_4.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(0, 128, 16, 16));
            }
            else if (asset.AssetNameEquals("Characters/Monsters/Stone Golem") || // 6t
                     asset.AssetNameEquals("Characters/Monsters/Wilderness Golem") // 6t)
                     )
            {
                Texture2D customTexture = this.Helper.Content.Load <Texture2D>("assets/heart_small_4.png", ContentSource.ModFolder);
                asset.AsImage().PatchImage(customTexture, targetArea: new Rectangle(0, 144, 16, 16));
            }
        }
Beispiel #30
0
        /// <summary>Edit a matched asset.</summary>
        /// <typeparam name="T">.</typeparam>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
        public void Edit <T>(IAssetData asset)
        {
            // update community center bundles (mainly the quality crops bundle, but be compatible with other mods)
            IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

            // https://stackoverflow.com/a/31767807
            // .ToList is part of System.Linq
            // Without it, the loop would error after an assignment to a dictionary element
            foreach (string key in data.Keys.ToList())
            {
                string[] fields            = data[key].Split(BundleFieldSeparator);
                string[] bundleIngredients = fields[2].Split(BundleIngredientSeparator);
                for (int i = 0; i < bundleIngredients.Length / BundleIngredientFields; ++i)
                {
                    int index         = i * BundleIngredientFields;
                    int indexItemId   = index;
                    int indexQuantity = index + 1;
                    int indexQuality  = index + 2;

                    string itemId   = bundleIngredients[indexItemId];
                    string quantity = bundleIngredients[indexQuantity];
                    string quality  = bundleIngredients[indexQuality];

                    // itemId -1 is a gold purchase, don't change anything here
                    if (itemId == "-1")
                    {
                        continue;
                    }

                    // quality is already regular, no adjustment needed
                    if (quality == "0")
                    {
                        continue;
                    }

                    // adjust amount -> multiply by rarity
                    int intQuality  = int.Parse(quality);
                    int intQuantity = int.Parse(quantity);
                    int newQuantity = intQuantity + (intQuantity * intQuality * this.configMultiplier);
                    if (newQuantity > MaxItemStackSize)
                    {
                        Logger.Warn($"A bundle ingredient would have exceeded the maximum stack size of {MaxItemStackSize}. It has been limited to {MaxItemStackSize}.");
                        Logger.Warn($"Bundle: {key} | itemId: {itemId} | adjusted quantity = {newQuantity} (= {quantity} + {quantity} * {quality} * {this.configMultiplier}");
                        newQuantity = MaxItemStackSize;
                    }

                    bundleIngredients[indexQuantity] = newQuantity.ToString();
                    bundleIngredients[indexQuality]  = "0";
                }

                string newData = string.Join(BundleIngredientSeparator.ToString(), bundleIngredients);

                // nothing changed, no need to touch the data dictionary
                if (newData == fields[2])
                {
                    continue;
                }

                fields[2] = newData;
                data[key] = string.Join(BundleFieldSeparator.ToString(), fields);
            }
        }