public InventoryLocations Get(Int64 ixInventoryLocation) { InventoryLocations inventorylocations = _context.InventoryLocations.AsNoTracking().Where(x => x.ixInventoryLocation == ixInventoryLocation).First(); if (inventorylocations.ixCompany != null) { inventorylocations.Companies = _context.Companies.Find(inventorylocations.ixCompany); } inventorylocations.Facilities = _context.Facilities.Find(inventorylocations.ixFacility); inventorylocations.FacilityAisleFaces = _context.FacilityAisleFaces.Find(inventorylocations.ixFacilityAisleFace); inventorylocations.FacilityFloors = _context.FacilityFloors.Find(inventorylocations.ixFacilityFloor); inventorylocations.FacilityWorkAreas = _context.FacilityWorkAreas.Find(inventorylocations.ixFacilityWorkArea); inventorylocations.FacilityZones = _context.FacilityZones.Find(inventorylocations.ixFacilityZone); if (inventorylocations.ixInventoryLocationSize != null) { inventorylocations.InventoryLocationSizes = _context.InventoryLocationSizes.Find(inventorylocations.ixInventoryLocationSize); } inventorylocations.LocationFunctions = _context.LocationFunctions.Find(inventorylocations.ixLocationFunction); if (inventorylocations.ixXOffsetUnit != null) { inventorylocations.UnitsOfMeasurementFKDiffXOffsetUnit = _context.UnitsOfMeasurement.Find(inventorylocations.ixXOffsetUnit); } if (inventorylocations.ixYOffsetUnit != null) { inventorylocations.UnitsOfMeasurementFKDiffYOffsetUnit = _context.UnitsOfMeasurement.Find(inventorylocations.ixYOffsetUnit); } if (inventorylocations.ixZOffsetUnit != null) { inventorylocations.UnitsOfMeasurementFKDiffZOffsetUnit = _context.UnitsOfMeasurement.Find(inventorylocations.ixZOffsetUnit); } return(inventorylocations); }
/// <summary>Gets the first occurance of an item with the specified lore group in the specified location(s).</summary> internal InventoryItem GetItemByLoreGroupByLocation(int loreGroupId, InventoryLocations invLoc) { // TODO: Add checks for augments if ((invLoc & InventoryLocations.Equipped) == InventoryLocations.Equipped) { foreach (InventoryItem invItem in this.EquippedItems()) { // Check more restrictive first if (invItem.Item.LoreGroup == loreGroupId) return invItem; } } if ((invLoc & InventoryLocations.Personal) == InventoryLocations.Personal) { foreach (InventoryItem invItem in this.AllPersonalItems()) { if (invItem.Item.LoreGroup == loreGroupId) return invItem; } } if ((invLoc & InventoryLocations.Bank) == InventoryLocations.Bank) { foreach (InventoryItem invItem in this.AllBankItems()) { if (invItem.Item.LoreGroup == loreGroupId) return invItem; } } if ((invLoc & InventoryLocations.SharedBank) == InventoryLocations.SharedBank) { foreach (InventoryItem invItem in this.AllSharedBankItems()) { if (invItem.Item.LoreGroup == loreGroupId) return invItem; } } if ((invLoc & InventoryLocations.Trading) == InventoryLocations.Trading) { // Look in trading window slots foreach (InventoryItem invItem in this.TradingItems()) { if (invItem.Item.LoreGroup == loreGroupId) return invItem; } } if ((invLoc & InventoryLocations.Cursor) == InventoryLocations.Cursor) { // Look in the cursor queue foreach (InventoryItem ii in _cursorQueue) { if (ii.Item.LoreGroup == loreGroupId) return ii; } } return null; }
/// <summary>Determines if any containers have sub-items and adds them to the relevant InventoryItem.</summary> internal void CalculateSubItems(InventoryLocations invLoc) { InventoryItem parentItem = null, subItem = null; int slotsIdx = 0, bagIdx = 0, bagRangeLow = 0, bagRangeHigh = 0; // Personal inventory bags if ((invLoc & InventoryLocations.Personal) == InventoryLocations.Personal) { for (int i = (int)InventorySlot.PersonalSlotsBegin; i <= (int)InventorySlot.PersonalSlotsEnd; i++) { if (_invItems.TryGetValue(i, out parentItem)) { if (parentItem != null && parentItem.Item.ItemClass == Item.ITEM_CLASS_CONTAINER) { // Looks like we are a container in a personal inventory slot //_log.DebugFormat("{0} is a container in personal inventory slot {1}", parentItem.Item.Name, i); parentItem.ClearSubItems(); slotsIdx = (i - (int)InventorySlot.PersonalBagsBegin) % MAX_ITEMS_PER_BAG; bagRangeLow = (int)InventorySlot.PersonalBagsBegin + slotsIdx * MAX_ITEMS_PER_BAG; bagRangeHigh = (int)InventorySlot.PersonalBagsEnd - slotsIdx * MAX_ITEMS_PER_BAG; for (int bagSlotsIdx = bagRangeLow; bagSlotsIdx <= bagRangeHigh; bagSlotsIdx++) { if (_invItems.TryGetValue(bagSlotsIdx, out subItem) && subItem != null) { // And we contain something //_log.DebugFormat("Containing {0}", subItem.Item.Name); bagIdx = (bagSlotsIdx - (int)InventorySlot.PersonalBagsBegin) % MAX_ITEMS_PER_BAG; //_log.DebugFormat("Calculated subitem {0} at bag index {1}, inventory index {2}", subItem.Item.Name, bagIdx, bagSlotsIdx); parentItem.AddSubItem(bagIdx, subItem); } } } } } } // Bank bags if ((invLoc & InventoryLocations.Bank) == InventoryLocations.Bank) { for (int i = (int)InventorySlot.BankBegin; i <= (int)InventorySlot.BankEnd; i++) { if (_invItems.TryGetValue(i, out parentItem)) { if (parentItem != null && parentItem.Item.ItemClass == Item.ITEM_CLASS_CONTAINER) { // Looks like we are a container in a bank slot _log.DebugFormat("{0} is a container in bank slot {1}", parentItem.Item.Name, i); parentItem.ClearSubItems(); slotsIdx = (i - (int)InventorySlot.BankBagsBegin) % MAX_ITEMS_PER_BAG; bagRangeLow = (int)InventorySlot.BankBagsBegin + slotsIdx * MAX_ITEMS_PER_BAG; bagRangeHigh = (int)InventorySlot.BankBagsEnd - slotsIdx * MAX_ITEMS_PER_BAG; for (int bagSlotsIdx = bagRangeLow; bagSlotsIdx <= bagRangeHigh; bagSlotsIdx++) { if (_invItems.TryGetValue(bagSlotsIdx, out subItem) && subItem != null) { // And we contain something bagIdx = (bagSlotsIdx - (int)InventorySlot.BankBagsBegin) % MAX_ITEMS_PER_BAG; parentItem.AddSubItem(bagIdx, subItem); } } } } } } // Shared bank bags if ((invLoc & InventoryLocations.SharedBank) == InventoryLocations.SharedBank) { for (int i = (int)InventorySlot.SharedBankBegin; i <= (int)InventorySlot.SharedBankEnd; i++) { if (_invItems.TryGetValue(i, out parentItem)) { if (parentItem != null && parentItem.Item.ItemClass == Item.ITEM_CLASS_CONTAINER) { // Looks like we are a container in a shared bank slot _log.DebugFormat("{0} is a container in shared bank slot {1}", parentItem.Item.Name, i); parentItem.ClearSubItems(); slotsIdx = (i - (int)InventorySlot.SharedBankBagsBegin) % MAX_ITEMS_PER_BAG; bagRangeLow = (int)InventorySlot.SharedBankBagsBegin + slotsIdx * MAX_ITEMS_PER_BAG; bagRangeHigh = (int)InventorySlot.SharedBankBagsEnd - slotsIdx * MAX_ITEMS_PER_BAG; for (int bagSlotsIdx = bagRangeLow; bagSlotsIdx <= bagRangeHigh; bagSlotsIdx++) { if (_invItems.TryGetValue(bagSlotsIdx, out subItem) && subItem != null) { // And we contain something bagIdx = (bagSlotsIdx - (int)InventorySlot.SharedBankBagsBegin) % MAX_ITEMS_PER_BAG; parentItem.AddSubItem(bagIdx, subItem); } } } } } } // TODO: augmentations (LoY era) }