/// <summary>Generates a method that adds this inventory to a shop that matches the defined conditions and adds it to <see cref="IDisplayEvents.MenuChanged"/>.</summary> /// <returns>Returns the method.</returns> public static EventHandler <MenuChangedEventArgs> addToShop(this InventoryItem inventory, Func <ShopMenu, bool> predicate) { EventHandler <MenuChangedEventArgs> d = delegate(object sender, MenuChangedEventArgs e) { ShopMenu shop = (ShopMenu)e.NewMenu; List <Item> forSale = shop.getForSale(); Dictionary <Item, int[]> priceAndStock = shop.getItemPriceAndStock(); forSale.AddOrReplace(inventory.item); priceAndStock.AddOrReplace(inventory.item, new int[] { inventory.price, inventory.stock }); }; d = d.addPredicate(e => predicate.Invoke(((ShopMenu)e.NewMenu))); return(Game1.activeClickableMenu.onActivation <ShopMenu>(d)); }
/// <summary>Generates a method that adds this inventory to a shop that matches the defined conditions and adds it to <see cref="IDisplayEvents.MenuChanged"/>.</summary> /// <returns>Returns the method.</returns> public static EventHandler <MenuChangedEventArgs> addToShop(this List <InventoryItem> inventory, Func <ShopMenu, bool> predicate) { EventHandler <MenuChangedEventArgs> d = delegate(object sender, MenuChangedEventArgs e) { ShopMenu shop = (ShopMenu)e.NewMenu; List <Item> forSale = shop.getForSale(); Dictionary <Item, int[]> priceAndStock = shop.getItemPriceAndStock(); forSale = forSale.Union(inventory.forSale()).ToList(); priceAndStock = priceAndStock.Union(inventory.priceAndStock()).ToDictionary(dict => dict.Key, dict => dict.Value); }; d = d.addPredicate(e => predicate.Invoke(((ShopMenu)e.NewMenu))); return(Game1.activeClickableMenu.onActivation <ShopMenu>(d)); }
public static bool isHatShop(this ShopMenu shop) { List <ISalable> items = shop.getForSale(); return(!(shop.portraitPerson is NPC) && shop.sellsOnly <Hat>()); }
public static bool isWallpaperCatalogue(this ShopMenu shop) { List <ISalable> items = shop.getForSale(); return(!(shop.portraitPerson is NPC) && shop.sellsOnly <Wallpaper>()); }
public static bool isFurnitureCataogue(this ShopMenu shop) { List <ISalable> items = shop.getForSale(); return(!(shop.portraitPerson is NPC) && shop.sellsOnly <Furniture>()); }
public static bool sellsOnly <T>(this ShopMenu shop) { return(shop.getForSale().Find(i => !(i is T)) == null); }