public override bool onDresserItemWithdrawn(ISalable salable, Farmer who, int amount) { bool result = base.onDresserItemWithdrawn(salable, who, amount); refreshFishEvent.Fire(); return(result); }
public static void Utility_getBlacksmithUpgradeStock_postfix(ref Dictionary <ISalable, int[]> __result) { try { Dictionary <ISalable, int[]> editedStock = new Dictionary <ISalable, int[]>(); foreach (KeyValuePair <ISalable, int[]> kvp in __result) { ISalable key = kvp.Key; Tool tool = key as Tool; if (tool != null && Enum.IsDefined(typeof(UpgradeMaterials), tool.UpgradeLevel)) { int upgradeLvl = tool.UpgradeLevel; List <int> stockAndPrice = kvp.Value.ToList(); if (tool is GenericTool) { upgradeLvl++; } stockAndPrice.Add(_instance._config.UpgradeCosts[(UpgradeMaterials)upgradeLvl].MaterialStack); editedStock.Add(kvp.Key, stockAndPrice.ToArray()); } else { editedStock.Add(kvp); } } __result = editedStock; } catch (Exception ex) { _instance.Monitor.Log($"Failed in {nameof(Utility_indexOfExtraMaterialForToolUpgrade_prefix)}:\n{ex}", (LogLevel)4); } }
public override void performHoverAction(int x, int y) { base.performHoverAction(x, y); this.hoverText = ""; this.hoveredItem = null; this.boldTitleText = ""; if (this.scrolling) { return; } for (int j = 0; j < this.forSaleButtons.Count; j++) { if (this.forSaleButtons[j].containsPoint(x, y)) { if (j + (currentItemIndex * 2) >= forSale.Count) { return; } ISalable item = this.forSale[j + (currentItemIndex * 2)]; this.hoverText = item.getDescription(); this.boldTitleText = item.DisplayName; this.hoveredItem = item; } } }
public static void CheckSellQuests(ISalable itemToSell) { foreach (var quest in GetQuestsForCheck <SellItemQuest>()) { quest.checkIfComplete(null, itemToSell.Stack, -2, itemToSell as Item, "sell"); } }
/********* ** Private methods *********/ /// <summary>The method to call before <see cref="Item.canStackWith"/>.</summary> public static bool Before_CanStackWith(Item __instance, ISalable other, ref bool __result) { // We're checking the `.ParentSheetIndex` instead of `is Chest` because when you break a chest // and pick it up it isn't a chest instance, it's just an object with the chest index. if (__instance.ParentSheetIndex == 130 && other is SObject { ParentSheetIndex : 130 })
public virtual bool onDresserItemDeposited(ISalable deposited_salable) { if (deposited_salable is Item) { heldItems.Add(deposited_salable as Item); if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ShopMenu) { Dictionary <ISalable, int[]> contents = new Dictionary <ISalable, int[]>(); List <Item> list = heldItems.ToList(); list.Sort(SortItems); foreach (Item item in list) { contents[item] = new int[2] { 0, 1 }; } (Game1.activeClickableMenu as ShopMenu).setItemPriceAndStock(contents); Game1.playSound("dwop"); return(true); } } return(false); }
public void addItem(ISalable salable) { if (this.numberOfItems < this.maxItem) { this.items[this.numberOfItems++] = salable; } }
public static void AddItemToShop(ShopMenu Menu, ISalable Item, int Price, int Stock) { Menu.forSale.Add(Item); Menu.itemPriceAndStock.Add(Item, new int[2] { Price, Stock }); }
/// <summary> /// Bunches groups of common items together in the seed shop. /// Json Assets appends new stock to the bottom, and we don't want that very much at all. /// </summary> public static void SortSeedShopStock(ref ShopMenu menu) { // Pair a suffix grouping some common items together with the name of the lowest-index (first-found) item in the group List <ISalable> itemList = menu.forSale; var suffixes = new Dictionary <string, string> { { "seeds", null }, { "bulb", null }, { "starter", null }, { "shoot", null }, { "sapling", null } }; for (int i = 0; i < itemList.Count; ++i) { // Ignore items without one of our group suffixes string suffix = suffixes.Keys .FirstOrDefault(s => itemList[i].Name.ToLower().EndsWith(s)); if (suffix is null) { continue; } // Set the move-to-this-item name to be the first-found item in the group suffixes[suffix] ??= itemList[i].Name; if (suffixes[suffix] == itemList[i].Name) { continue; } // Move newly-found items of a group up to the first item in the group, and change the move-to name to this item ISalable item = itemList[i]; int index = 1 + itemList .FindIndex(i => i.Name == suffixes[suffix]); itemList.RemoveAt(i); itemList.Insert(index, item); suffixes[suffix] = itemList[index].Name; } menu.forSale = itemList; }
/// <summary>Get whether to prevent stacking the given item.</summary> /// <param name="item">The item to check.</param> private static bool ShouldPreventStacking(ISalable item) { return (ChestHelper.IsSupported(item) && item is Chest chest && chest.items.Count != 0); }
/// <summary> /// Copied over method to make the desert trader work without reflection bs /// </summary> /// <returns></returns> private static bool boughtTraderItem(ISalable s, Farmer f, int i) { if (s.Name == "Magic Rock Candy") { Desert.boughtMagicRockCandy = true; } return(false); }
public virtual bool onDresserItemWithdrawn(ISalable salable, Farmer who, int amount) { if (salable is Item) { heldItems.Remove(salable as Item); } return(false); }
public static bool boughtTraderItem(ISalable s, Farmer arg2, int arg3) { if (s.Name == "Magic Rock Candy") { Desert.boughtMagicRockCandy = true; } return(false); }
public bool boughtTraderItem(ISalable s, Farmer f, int i) { if (s.Name == "Magic Rock Candy") { boughtMagicRockCandy = true; } return(false); }
public bool OnDonatedItemWithdrawn(ISalable salable, Farmer who, int amount) { if (salable is Item && (salable.Stack <= 0 || salable.maximumStackSize() <= 1)) { returnedDonations.Remove(salable as Item); } return(false); }
public static void RemoveFromJojaOnlineStock(ISalable item) { // Remove the item if (jojaOnlineStock.ContainsKey(item)) { jojaOnlineStock.Remove(item); } }
/********* ** Private methods *********/ /// <summary>The method to call after <see cref="Item.canStackWith"/>.</summary> private static void After_CanStackWith(Item __instance, ISalable other, ref bool __result) { // prevent stacking chests that contain items if (__result) { __result = !ItemPatcher.ShouldPreventStacking(__instance) && !ItemPatcher.ShouldPreventStacking(other); } }
public override bool canStackWith(ISalable other) { if (other is not CustomFence fence) { return(false); } return(fence.FullId == this.FullId && base.canStackWith(fence)); }
private bool OnSell(ISalable salable) { if (salable is Item item && TargetIndex == item.ParentSheetIndex) { IncrementCount(item.Stack); } return(false); }
private bool OnPurchase(ISalable salable, Farmer player, int amount) { if (player.IsLocalPlayer && salable is Item item && TargetIndex == item.ParentSheetIndex) { IncrementCount(amount); } return(false); }
public void OnItemPurchased(SynchedShop shop, ISalable item, int amount) { NetStringDictionary <int, NetInt> sharedStock = getSharedStock(shop); string itemString = Utility.getStandardDescriptionFromItem(item as Item, 1); if (sharedStock.ContainsKey(itemString) && sharedStock[itemString] != int.MaxValue && (!(item is Object) || !(item as Object).IsRecipe)) { sharedStock[itemString] -= amount; } }
/********* ** Public methods *********/ /// <summary>Get whether an item is a chest that can be carried while full.</summary> /// <param name="item">The item to check.</param> public static bool IsSupported(ISalable item) { // We're checking the `.ParentSheetIndex` instead of `is Chest` because when you break a chest // and pick it up it isn't a chest instance, it's just an object with the chest index. return (item is SObject obj && obj.bigCraftable.Value && (obj.ParentSheetIndex is 130 or 232) && // chest or stone chest (obj is not Chest chest || chest.playerChest.Value)); }
private static bool Prefix(StardewValley.Item __instance, ref bool __result, ISalable other) { if (__instance is SObject obj1 && other is SObject obj2) { __result = obj1.preservedParentSheetIndex.Value == obj2.preservedParentSheetIndex.Value; return(false); } return(true); }
/// <summary>Constructs an instance.</summary> /// <param name="menu">The native shop menu.</param> /// <param name="item">The item to buy.</param> public BuyAction(ShopMenu menu, ISalable item) : base(menu, item) { // Default if (CanPerformAction()) { this.Amount = Math.Min(Mod.Config.DefaultShopAmount, GetMaxPurchasable()); } Log.TraceIfD($"[{nameof(BuyAction)}] Instantiated for shop {menu} item {item}, Amount = {this.Amount}, GUID = {GUID}"); }
/// <summary> /// Checks whether any item is effectively considered a cooking tool, including legacy implementations. /// </summary> public static bool IsItemCookingTool(ISalable item) { bool isCookingTool = item is CookingTool; bool isLegacyTool = !isCookingTool && item is not null && item is StardewValley.Tools.GenericTool tool && tool.IndexOfMenuItemView - CookingTool.LegacyCookingToolSheetIndex is >= 0 and < CookingTool.MaxUpgradeLevel; return(isCookingTool || isLegacyTool); }
public static bool Prefix(Item __instance, ref bool __result, ISalable other) { if ((__instance is StorageFurniture dresser1 && dresser1.heldItems.Count != 0) || (other is StorageFurniture dresser2 && dresser2.heldItems.Count != 0)) { __result = false; return(false); } return(true); }
public static void AddToJojaOnlineStock(ISalable item, int salePrice = -1, int stock = -1) { if (cachedItemNames.Contains(item.DisplayName) && item.DisplayName != "Wallpaper" && item.DisplayName != "Flooring") { return; } cachedItemNames.Add(item.DisplayName); // Add the unique item jojaOnlineStock.Add(item, new int[] { salePrice == -1 ? item.salePrice() : salePrice, stock == -1 ? int.MaxValue : stock }); }
public override bool canStackWith(ISalable other) { if (other is WireMultiTiledObject) { return((other as WireMultiTiledObject).info.id == this.info.id && (other as WireMultiTiledObject).info.DyedColor == this.info.DyedColor); } else { return(false); } }
public static bool OnPurchaseRenovation(ISalable salable, Farmer who, int amount) { HouseRenovation renovation; if ((renovation = (salable as HouseRenovation)) != null) { Game1.activeClickableMenu = new RenovateMenu(renovation); return(true); } return(false); }
internal static bool Equal(ISalable a, ISalable b) { if (a is null || b is null) { return(false); } var dgaApi = APIs.dgaApi.Value; if (dgaApi is not null) { var aID = dgaApi.GetDGAItemId(a); var bID = dgaApi.GetDGAItemId(b); if (aID is not null && bID is not null) { return(aID == bID); } } switch (a) { case Hat aHat when b is Hat bHat: return(aHat.which.Value == bHat.which.Value); case Tool aTool when b is Tool bTool: // includes weapons return(aTool.InitialParentTileIndex == bTool.InitialParentTileIndex); case Boots aBoots when b is Boots bBoots: return(aBoots.indexInTileSheet == bBoots.indexInTileSheet); case Item aItem when b is Item bItem: { if (aItem.ParentSheetIndex > -1 && bItem.ParentSheetIndex > -1) { return(aItem.ParentSheetIndex == bItem.ParentSheetIndex && aItem.Category == bItem.Category); } break; } } if (a is not Item) { MarketDay.Log($"Equal: {a.Name} not an item", LogLevel.Warn); } if (b is not Item) { MarketDay.Log($"Equal: {b.Name} not an item", LogLevel.Warn); } return(a.Name == b.Name); }
private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is ShopMenu shop && shop.portraitPerson == null && shop.forSale.All(salable => salable is Furniture)) { var itemsForSale = new ISalable[] { new KeyboardBlock(), new WindBlock() }; foreach (var item in itemsForSale) { shop.itemPriceAndStock.Add(item, new int[2] { 0, int.MaxValue }); shop.forSale.Add(item); } } }