Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
        public static bool isHatShop(this ShopMenu shop)
        {
            List <ISalable> items = shop.getForSale();

            return(!(shop.portraitPerson is NPC) && shop.sellsOnly <Hat>());
        }
Ejemplo n.º 4
0
        public static bool isWallpaperCatalogue(this ShopMenu shop)
        {
            List <ISalable> items = shop.getForSale();

            return(!(shop.portraitPerson is NPC) && shop.sellsOnly <Wallpaper>());
        }
Ejemplo n.º 5
0
        public static bool isFurnitureCataogue(this ShopMenu shop)
        {
            List <ISalable> items = shop.getForSale();

            return(!(shop.portraitPerson is NPC) && shop.sellsOnly <Furniture>());
        }
Ejemplo n.º 6
0
 public static bool sellsOnly <T>(this ShopMenu shop)
 {
     return(shop.getForSale().Find(i => !(i is T)) == null);
 }