/* * Returns the amount of itemtypes that are existent in the given room. * The itemtype that you require is given in the parameter. */ public int AmountInRoom(ItemType type, Room r) { List<Item> matches = ItemHandler.GetInstance().GetItemsBy(delegate (Item i) { return i.RoomID == r.GetID(); }); int rtn = 0; foreach (Item i in matches) if (i.Type.ID == type.ID) rtn++; return rtn; }
/* * Returns all of the different itemtypes that are in the given room * This will distinct any duplicate values. */ public List<ItemType> InRoom(Room r) { List<ItemType> itemTypes = new List<ItemType>(); List<Item> matches = ItemHandler.GetInstance().GetItemsBy(delegate (Item i) { return i.RoomID == r.GetID(); }); foreach (Item i in matches) { if (itemTypes.Contains(i.Type)) continue; itemTypes.Add(i.Type); } return itemTypes; }