Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option for Marnie to sell tools. #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ButcherMod/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ModConfig
public bool DisableInseminationSyringeLetter;
public bool DisableMeatToolLetter;
public bool DisableMeatButton;
public bool EnableMarnieTools;
public bool DisableMeatInBlundle;
public bool ForceDrawAttachmentOnAnyOS;
public bool DisableTvChannels;
Expand Down
43 changes: 43 additions & 0 deletions ButcherMod/common/DataLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using StardewValley;
using StardewValley.GameData.FarmAnimals;
using StardewValley.GameData.Objects;
using StardewValley.GameData.Shops;
using StardewValley.Locations;

namespace AnimalHusbandryMod.common
Expand Down Expand Up @@ -105,6 +106,7 @@ private static void InvalidateCache()
Helper.GameContent.InvalidateCache("Data/Tools");
Helper.GameContent.InvalidateCache("Data/Bundles");
Helper.GameContent.InvalidateCache("Data/NPCGiftTastes");
Helper.GameContent.InvalidateCache("Data/Shops");
}

public void Edit(object sender, AssetRequestedEventArgs args)
Expand Down Expand Up @@ -232,6 +234,45 @@ public void Edit(object sender, AssetRequestedEventArgs args)
AddCustomAnimalsTemplate((IDictionary<string, FarmAnimalData>)(isLoadingFarmAnimals ? asset.Data : null));
});
}
else if (args.NameWithoutLocale.IsEquivalentTo("Data/Shops")) {
args.Edit(asset => {
if (!ModConfig.EnableMarnieTools) return;
var items = asset.AsDictionary<string, ShopData>().Data["AnimalShop"].Items;
var shears = items.FirstOrDefault(i => i.Id == "(T)Shears");
var index = items.IndexOf(shears);
var price = shears.Price;
if (!ModConfig.DisableMeat) {
items.Insert(index + 1, new ShopItemData() {
TradeItemAmount = 1,
Price = price,
AvailableStock = 1,
Condition = $"!PLAYER_HAS_ITEM Current (T){MeatCleaverOverrides.MeatCleaverItemId}",
Id = $"(T){MeatCleaverOverrides.MeatCleaverItemId}",
ItemId = $"(T){MeatCleaverOverrides.MeatCleaverItemId}"
});
}
if (!ModConfig.DisablePregnancy) {
items.Insert(index + 2, new ShopItemData() {
TradeItemAmount = 1,
Price = price,
AvailableStock = 1,
Condition = $"!PLAYER_HAS_ITEM Current (T){InseminationSyringeOverrides.InseminationSyringeItemId}",
Id = $"(T){InseminationSyringeOverrides.InseminationSyringeItemId}",
ItemId = $"(T){InseminationSyringeOverrides.InseminationSyringeItemId}"
});
}
if (!ModConfig.DisableTreats) {
items.Insert(index + 3, new ShopItemData() {
TradeItemAmount = 1,
Price = price / 2,
AvailableStock = 1,
Condition = $"!PLAYER_HAS_ITEM Current (T){FeedingBasketOverrides.FeedingBasketItemId}",
Id = $"(T){FeedingBasketOverrides.FeedingBasketItemId}",
ItemId = $"(T){FeedingBasketOverrides.FeedingBasketItemId}"
});
}
});
}
}

private static void LoadTreatsMail()
Expand Down Expand Up @@ -449,6 +490,8 @@ private void CreateConfigMenu(IManifest manifest)

api.AddBoolOption(manifest, () => DataLoader.ModConfig.DisableMeatButton, (bool val) => DataLoader.ModConfig.DisableMeatButton = val, () => "Disable Meat Button", () => "Disable the meat button showing in the animal query menu. Meat will only be able to be obtained using the tools.");

api.AddBoolOption(manifest, () => DataLoader.ModConfig.EnableMarnieTools, (bool val) => DataLoader.ModConfig.EnableMarnieTools = val, () => "Marnie Sells Tools", () => "Add the meat cleaver/wand, syringe, and basket to Marnie's shop inventory, useful as an alternative if you disable letters.");

api.AddKeybind(manifest, () => DataLoader.ModConfig.AddMeatCleaverToInventoryKey ?? SButton.None, (SButton val) => DataLoader.ModConfig.AddMeatCleaverToInventoryKey = val == SButton.None ? (SButton?)null : val, () => "Add Meat Tool Key", () => "Set a keyboard key to directly add the Meat Cleaver/Want to your inventory.");

api.AddSectionTitle(manifest, () => "Pregnancy Properties:", () => "Properties to configure the insemination feature.");
Expand Down