private bool MoveItem(bool pickup)
        {
            DirectEve.DirectEve directEve = Cache.Instance.DirectEve;

            // Open the item hangar (should still be open)
            if (Cache.Instance.ItemHangar == null)
            {
                return(false);
            }

            if (Cache.Instance.CurrentShipsCargo == null)
            {
                return(false);
            }

            DirectContainer from = pickup ? Cache.Instance.ItemHangar : Cache.Instance.CurrentShipsCargo;
            DirectContainer to   = pickup ? Cache.Instance.CurrentShipsCargo : Cache.Instance.ItemHangar;

            // We moved the item

            if (to.Items.Any(i => i.GroupId == (int)Group.MiscSpecialMissionItems || i.GroupId == (int)Group.Livestock))
            {
                return(true);
            }

            if (directEve.GetLockedItems().Count != 0)
            {
                return(false);
            }

            // Move items
            foreach (DirectItem item in from.Items.Where(i => i.GroupId == (int)Group.MiscSpecialMissionItems || i.GroupId == (int)Group.Livestock))
            {
                Logging.Log("GenericCourier", "Moving [" + item.TypeName + "][" + item.ItemId + "] to " + (pickup ? "cargo" : "hangar"), Logging.White);
                to.Add(item, item.Stacksize);
            }
            _nextGenericCourierStorylineAction = DateTime.UtcNow.AddSeconds(10);
            return(false);
        }
        private bool MoveItem(bool pickup)
        {
            // Open the item hangar (should still be open)
            if (Cache.Instance.ItemHangar == null)
            {
                return(false);
            }

            if (Cache.Instance.CurrentShipsCargo == null)
            {
                return(false);
            }

            // 314 == Transaction And Salary Logs (all different versions)
            const int       groupId = 314;
            DirectContainer from    = pickup ? Cache.Instance.ItemHangar : Cache.Instance.CurrentShipsCargo;
            DirectContainer to      = pickup ? Cache.Instance.CurrentShipsCargo : Cache.Instance.ItemHangar;

            // We moved the item
            if (to.Items.Any(i => i.GroupId == groupId))
            {
                return(true);
            }

            if (Cache.Instance.DirectEve.GetLockedItems().Count != 0)
            {
                return(false);
            }

            // Move items
            foreach (DirectItem item in from.Items.Where(i => i.GroupId == groupId))
            {
                Logging.Log("TransactionDataDelivery", "Moving [" + item.TypeName + "][" + item.ItemId + "] to " + (pickup ? "cargo" : "hangar"), Logging.White);
                to.Add(item);
            }
            _nextAction = DateTime.UtcNow.AddSeconds(10);
            return(false);
        }
Exemple #3
0
        public void ProcessState()
        {
            if (!Cache.Instance.InStation)
            {
                return;
            }

            if (Cache.Instance.InSpace)
            {
                return;
            }

            if (DateTime.UtcNow < Cache.Instance.LastInSpace.AddSeconds(10)) // we wait 20 seconds after we last thought we were in space before trying to do anything in station
            {
                return;
            }

            switch (_States.CurrentDropState)
            {
            case DropState.Idle:
            case DropState.Done:
                break;

            case DropState.Begin:
                if (Settings.Instance.DebugQuestorManager)
                {
                    Logging.Log("Drop", "Entered: Begin", Logging.Debug);
                }

                _States.CurrentDropState = DropState.ReadyItemhangar;
                break;

            case DropState.ReadyItemhangar:
                if (Settings.Instance.DebugQuestorManager)
                {
                    Logging.Log("Drop", "Entered: ReadyItemhangar", Logging.Debug);
                }
                if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds < 2)
                {
                    return;
                }
                dropHangar = Cache.Instance.ItemHangar;

                if (DestinationHangarName == "Local Hangar")
                {
                    if (Cache.Instance.ItemHangar == null)
                    {
                        return;
                    }
                    dropHangar = Cache.Instance.ItemHangar;
                }
                else if (DestinationHangarName == "Ship Hangar")
                {
                    if (!Cache.Instance.OpenShipsHangar("Drop"))
                    {
                        return;
                    }
                    dropHangar = Cache.Instance.ShipHangar;
                }
                else
                {
                    if (dropHangar != null && dropHangar.Window == null)
                    {
                        // No, command it to open
                        //Cache.Instance.DirectEve.OpenCorporationHangar();
                        break;
                    }

                    if (dropHangar != null && !dropHangar.Window.IsReady)
                    {
                        return;
                    }
                }

                Logging.Log("Drop", "Opening Hangar", Logging.White);
                _States.CurrentDropState = DropState.OpenCargo;
                break;

            case DropState.OpenCargo:
                if (Settings.Instance.DebugQuestorManager)
                {
                    Logging.Log("Drop", "Entered: OpenCargo", Logging.Debug);
                }

                if (Cache.Instance.CurrentShipsCargo == null)
                {
                    Logging.Log("OpenCargo", "if (Cache.Instance.CurrentShipsCargo == null)", Logging.Teal);
                    return;
                }

                Logging.Log("Drop", "Opening Cargo Hold", Logging.White);
                _States.CurrentDropState = Item == 00 ? DropState.AllItems : DropState.MoveItems;
                break;

            case DropState.MoveItems:

                if (Settings.Instance.DebugQuestorManager)
                {
                    Logging.Log("Drop", "Entered: MoveItems", Logging.Debug);
                }
                if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds < 2)
                {
                    return;
                }
                if (Cache.Instance.CurrentShipsCargo == null)
                {
                    Logging.Log("MoveItems", "if (Cache.Instance.CurrentShipsCargo == null)", Logging.Teal);
                    return;
                }

                DirectItem dropItem;

                if (Unit == 00)
                {
                    try
                    {
                        if (Settings.Instance.DebugQuestorManager)
                        {
                            Logging.Log("Drop", "Item TypeID is [" + Item + "]", Logging.Debug);
                        }

                        int iCount = 1;
                        foreach (DirectItem ItemTest in Cache.Instance.CurrentShipsCargo.Items)
                        {
                            iCount++;
                            if (Settings.Instance.DebugQuestorManager)
                            {
                                Logging.Log("Drop", "[" + iCount + "] ItemName: [" + ItemTest.TypeName + "]", Logging.Debug);
                            }
                        }

                        if (Cache.Instance.CurrentShipsCargo.Items.Any(i => i.TypeId == Item))
                        {
                            dropItem = Cache.Instance.CurrentShipsCargo.Items.FirstOrDefault(i => i.TypeId == Item);
                            if (dropItem != null)
                            {
                                if (Settings.Instance.DebugQuestorManager)
                                {
                                    Logging.Log("DropItem", "dropItem = [" + dropItem.TypeName + "]", Logging.Debug);
                                }
                                if (dropHangar != null)
                                {
                                    dropHangar.Add(dropItem, dropItem.Quantity);
                                }
                                Logging.Log("Drop", "Moving all the items", Logging.White);
                                _lastAction = DateTime.UtcNow;
                                _States.CurrentDropState = DropState.WaitForMove;
                                return;
                            }
                        }
                        else
                        {
                            if (Settings.Instance.DebugQuestorManager)
                            {
                                Logging.Log("DropItem", "missing item with typeID of [" + Item + "]", Logging.Debug);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        Logging.Log("Drop", "MoveItems (all): Exception [" + exception + "]", Logging.Debug);
                    }
                    return;
                }

                try
                {
                    if (Settings.Instance.DebugQuestorManager)
                    {
                        Logging.Log("Drop", "Item = [" + Item + "]", Logging.Debug);
                    }
                    dropItem = Cache.Instance.CurrentShipsCargo.Items.FirstOrDefault(i => (i.TypeId == Item));
                    if (dropItem != null)
                    {
                        if (Settings.Instance.DebugQuestorManager)
                        {
                            Logging.Log("Drop", "Unit = [" + Unit + "]", Logging.Debug);
                        }

                        if (dropHangar != null)
                        {
                            dropHangar.Add(dropItem, Unit);
                        }
                        Logging.Log("Drop", "Moving item", Logging.White);
                        _lastAction = DateTime.UtcNow;
                        _States.CurrentDropState = DropState.WaitForMove;
                        return;
                    }
                }
                catch (Exception exception)
                {
                    Logging.Log("Drop", "MoveItems: Exception [" + exception + "]", Logging.Debug);
                }

                break;

            case DropState.AllItems:
                if (Settings.Instance.DebugQuestorManager)
                {
                    Logging.Log("Drop", "Entered: AllItems", Logging.Debug);
                }
                if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds < 2)
                {
                    return;
                }

                List <DirectItem> allItem = Cache.Instance.CurrentShipsCargo.Items;
                if (allItem != null)
                {
                    if (dropHangar != null)
                    {
                        dropHangar.Add(allItem);
                    }
                    Logging.Log("Drop", "Moving item", Logging.White);
                    _lastAction = DateTime.UtcNow;
                    _States.CurrentDropState = DropState.WaitForMove;
                    return;
                }

                break;

            case DropState.WaitForMove:
                if (Settings.Instance.DebugQuestorManager)
                {
                    Logging.Log("Drop", "Entered: WaitForMove", Logging.Debug);
                }

                // Wait 2 seconds after moving
                if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds < 2)
                {
                    return;
                }

                if (Cache.Instance.DirectEve.GetLockedItems().Count == 0)
                {
                    _States.CurrentDropState = DropState.StackItemsHangar;
                    return;
                }

                if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds > 60)
                {
                    Logging.Log("Drop", "Moving items timed out, clearing item locks", Logging.White);
                    Cache.Instance.DirectEve.UnlockItems();

                    _States.CurrentDropState = DropState.StackItemsHangar;
                    return;
                }
                break;

            case DropState.StackItemsHangar:
                if (Settings.Instance.DebugQuestorManager)
                {
                    Logging.Log("Drop", "Entered: StackItemsHangar", Logging.Debug);
                }
                // Do not stack until 5 seconds after the cargo has cleared
                if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds < 5)
                {
                    return;
                }

                // Stack everything
                if (dropHangar != null)
                {
                    Logging.Log("Drop", "Stacking items", Logging.White);
                    dropHangar.StackAll();
                    _lastAction = DateTime.UtcNow;
                    _States.CurrentDropState = DropState.WaitForStacking;
                    return;
                }
                break;

            case DropState.WaitForStacking:
                if (Settings.Instance.DebugQuestorManager)
                {
                    Logging.Log("Drop", "Entered: WaitForStacking", Logging.Debug);
                }
                // Wait 5 seconds after stacking
                if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds < 5)
                {
                    return;
                }

                if (Cache.Instance.DirectEve.GetLockedItems().Count == 0)
                {
                    Logging.Log("Drop", "Done", Logging.White);
                    _States.CurrentDropState = DropState.Done;
                    return;
                }

                if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds > 120)
                {
                    Logging.Log("Drop", "Stacking items timed out, clearing item locks", Logging.White);
                    Cache.Instance.DirectEve.UnlockItems();

                    Logging.Log("Drop", "Done", Logging.White);
                    _States.CurrentDropState = DropState.Done;
                    return;
                }
                break;
            }
        }
Exemple #4
0
        private bool MoveItem(bool pickup)
        {
            var directEve = Cache.Instance.DirectEve;

            // Open the item hangar (should still be open)
            var hangar = directEve.GetItemHangar();

            if (hangar.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("TransactionDataDelivery: Opening hangar floor");

                directEve.ExecuteCommand(DirectCmd.OpenHangarFloor);
                return(false);
            }

            // Wait for it to become ready
            if (!hangar.IsReady)
            {
                return(false);
            }

            var cargo = directEve.GetShipsCargo();

            if (cargo.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("TransactionDataDelivery: Opening cargo");

                directEve.ExecuteCommand(DirectCmd.OpenCargoHoldOfActiveShip);
                return(false);
            }

            if (!cargo.IsReady)
            {
                return(false);
            }

            // 314 == Transaction And Salary Logs (all different versions)
            const int       groupId = 314;
            DirectContainer from    = pickup ? hangar : cargo;
            DirectContainer to      = pickup ? cargo : hangar;

            // We moved the item
            if (to.Items.Any(i => i.GroupId == groupId))
            {
                return(true);
            }

            if (directEve.GetLockedItems().Count != 0)
            {
                return(false);
            }

            // Move items
            foreach (var item in from.Items.Where(i => i.GroupId == groupId))
            {
                Logging.Log("TransactionDataDelivery: Moving [" + item.TypeName + "][" + item.ItemId + "] to " + (pickup ? "cargo" : "hangar"));
                to.Add(item, item.Stacksize);
            }

            _nextAction = DateTime.Now.AddSeconds(10);
            return(false);
        }
Exemple #5
0
        public void ProcessState()
        {
            var cargo       = Cache.Instance.DirectEve.GetShipsCargo();
            var itemshangar = Cache.Instance.DirectEve.GetItemHangar();

            DirectContainer corpAmmoHangar = null;

            if (!string.IsNullOrEmpty(Settings.Instance.AmmoHangar))
            {
                corpAmmoHangar = Cache.Instance.DirectEve.GetCorporationHangar(Settings.Instance.AmmoHangar);
            }

            DirectContainer corpLootHangar = null;

            if (!string.IsNullOrEmpty(Settings.Instance.LootHangar))
            {
                corpLootHangar = Cache.Instance.DirectEve.GetCorporationHangar(Settings.Instance.LootHangar);
            }

            DirectContainer lootContainer = null;

            if (!string.IsNullOrEmpty(Settings.Instance.LootContainer))
            {
                long lootContainerID = itemshangar.Items.FirstOrDefault(i => i.GivenName != null && i.GivenName.ToLower() == Settings.Instance.LootContainer.ToLower()).ItemId;
                lootContainer = Cache.Instance.DirectEve.GetContainer(lootContainerID);
            }

            DirectContainer corpBookmarkHangar = null;

            if (!string.IsNullOrEmpty(Settings.Instance.BookmarkHangar))
            {
                corpBookmarkHangar = Cache.Instance.DirectEve.GetCorporationHangar(Settings.Instance.BookmarkHangar);
            }

            switch (State)
            {
            case UnloadLootState.Idle:
            case UnloadLootState.Done:
                break;

            case UnloadLootState.Begin:
                if (cargo.Items.Count == 0)
                {
                    State = UnloadLootState.Done;
                }
                Logging.Log("UnloadLoot: Opening station hangar");
                State = UnloadLootState.OpenItemHangar;
                break;

            case UnloadLootState.OpenItemHangar:
                // Is the hangar open?
                if (itemshangar.Window == null)
                {
                    // No, command it to open
                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenHangarFloor);
                    break;
                }

                // Not ready yet
                if (!itemshangar.IsReady)
                {
                    break;
                }

                Logging.Log("UnloadLoot: Opening ship's cargo");
                State = UnloadLootState.OpenShipsCargo;
                break;

            case UnloadLootState.OpenShipsCargo:
                // Is cargo open?
                if (cargo.Window == null)
                {
                    // No, command it to open
                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenCargoHoldOfActiveShip);
                    break;
                }

                if (!cargo.IsReady)
                {
                    break;
                }

                if (corpAmmoHangar != null || corpLootHangar != null)
                {
                    //Logging.Log("UnloadLoot: Opening corporation hangar");
                    State = UnloadLootState.OpenCorpHangar;
                }
                else
                {
                    //Logging.Log("UnloadLoot: CommonMissionCompletionitems");
                    State = UnloadLootState.MoveCommonMissionCompletionitems;
                }
                break;

            case UnloadLootState.OpenCorpHangar:
                // Is cargo open?
                var corpHangar = corpAmmoHangar ?? corpLootHangar;
                if (corpHangar != null)
                {
                    if (corpHangar.Window == null)
                    {
                        // No, command it to open
                        Logging.Log("UnloadLoot: Opening corporation hangar");
                        Cache.Instance.DirectEve.OpenCorporationHangar();
                        break;
                    }

                    if (!corpHangar.IsReady)
                    {
                        break;
                    }
                }

                Logging.Log("UnloadLoot: Moving Common Mission Completion items");
                State = UnloadLootState.MoveCommonMissionCompletionitems;
                break;

            case UnloadLootState.MoveCommonMissionCompletionitems:
                var CommonMissionCompletionItemHangar = itemshangar;
                //
                // how do we get IsMissionItem to work for us here? (see ItemCache)
                // Zbikoki's Hacker Card 28260, Reports 3814, Gate Key 2076, Militants 25373, Marines 3810, i.groupid == 314 (Misc Mission Items, mainly for storylines) and i.GroupId == 283 (Misc Mission Items, mainly for storylines)
                //
                var ItemsToMove = cargo.Items.Where(i => i.TypeId == 17192 || i.TypeId == 2076 || i.TypeId == 3814 || i.TypeId == 17206 || i.TypeId == 28260 || i.GroupId == 283 || i.GroupId == 314);

                CommonMissionCompletionItemHangar.Add(ItemsToMove);
                _lastAction = DateTime.Now;

                Logging.Log("UnloadLoot: Moving Common Mission Completion Items to Local hangar");
                State = UnloadLootState.MoveLoot;
                break;

            case UnloadLootState.MoveLoot:
                var lootHangar = corpLootHangar ?? lootContainer ?? itemshangar;

                var lootToMove = cargo.Items.Where(i => (i.TypeName ?? string.Empty).ToLower() != Cache.Instance.BringMissionItem && !Settings.Instance.Ammo.Any(a => a.TypeId == i.TypeId));
                LootValue = 0;
                foreach (var item in lootToMove)
                {
                    if (!Cache.Instance.InvTypesById.ContainsKey(item.TypeId))
                    {
                        continue;
                    }

                    var invType = Cache.Instance.InvTypesById[item.TypeId];
                    LootValue += (invType.MedianBuy ?? 0) * Math.Max(item.Quantity, 1);
                }

                // Move loot to the loot hangar
                lootHangar.Add(lootToMove);
                _lastAction = DateTime.Now;

                Logging.Log("UnloadLoot: Loot was worth an estimated [" + LootValue.ToString("#,##0") + "] isk in buy-orders");

                //Move bookmarks to the bookmarks hangar
                if (!string.IsNullOrEmpty(Settings.Instance.BookmarkHangar) && Settings.Instance.CreateSalvageBookmarks == true)
                {
                    Logging.Log("UnloadLoot: Creating salvage bookmarks in hangar");
                    var         bookmarks  = Cache.Instance.BookmarksByLabel(Settings.Instance.BookmarkPrefix + " ");
                    List <long> salvageBMs = new List <long>();
                    foreach (DirectBookmark bookmark in bookmarks)
                    {
                        salvageBMs.Add((long)bookmark.BookmarkId);
                        if (salvageBMs.Count == 5)
                        {
                            itemshangar.AddBookmarks(salvageBMs);
                            salvageBMs.Clear();
                        }
                    }
                    if (salvageBMs.Count > 0)
                    {
                        itemshangar.AddBookmarks(salvageBMs);
                        salvageBMs.Clear();
                    }
                }

                Logging.Log("UnloadLoot: Moving ammo");
                State = UnloadLootState.MoveAmmo;
                break;

            case UnloadLootState.MoveAmmo:
                // Wait 5 seconds after moving
                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                {
                    break;
                }

                var ammoHangar = corpAmmoHangar ?? itemshangar;

                // Move the mission item & ammo to the ammo hangar
                ammoHangar.Add(cargo.Items.Where(i => ((i.TypeName ?? string.Empty).ToLower() == Cache.Instance.BringMissionItem || Settings.Instance.Ammo.Any(a => a.TypeId == i.TypeId))));
                _lastAction = DateTime.Now;

                Logging.Log("UnloadLoot: Waiting for items to move");
                State = UnloadLootState.WaitForMove;
                break;

            case UnloadLootState.WaitForMove:
                if (cargo.Items.Count != 0)
                {
                    _lastAction = DateTime.Now;
                    break;
                }

                // Wait x seconds after moving
                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 2)
                {
                    break;
                }

                if (Cache.Instance.DirectEve.GetLockedItems().Count == 0)
                {
                    if (corpBookmarkHangar != null && Settings.Instance.CreateSalvageBookmarks)
                    {
                        Logging.Log("UnloadLoot: Moving salvage bookmarks to corp hangar");
                        corpBookmarkHangar.Add(itemshangar.Items.Where(i => i.TypeId == 51));
                    }

                    Logging.Log("UnloadLoot: Stacking items");
                    State = UnloadLootState.StackItemsHangar;
                    break;
                }

                if (DateTime.Now.Subtract(_lastAction).TotalSeconds > 120)
                {
                    Logging.Log("UnloadLoot: Moving items timed out, clearing item locks");
                    Cache.Instance.DirectEve.UnlockItems();

                    Logging.Log("UnloadLoot: Stacking items");
                    State = UnloadLootState.StackItemsHangar;
                    break;
                }
                break;

            case UnloadLootState.StackItemsHangar:
                // Don't stack until 5 seconds after the cargo has cleared
                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                {
                    break;
                }


                // Stack everything
                if (corpAmmoHangar == null || corpLootHangar == null || lootContainer == null)    // Only stack if we moved something
                {
                    itemshangar.StackAll();
                    _lastAction = DateTime.Now;
                }

                State = UnloadLootState.StackItemsCorpAmmo;
                break;

            case UnloadLootState.StackItemsCorpAmmo:
                if (Settings.Instance.AmmoHangar != string.Empty)
                {
                    // Don't stack until 5 seconds after the cargo has cleared
                    if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                    {
                        break;
                    }

                    // Stack everything
                    if (corpAmmoHangar != null)
                    {
                        corpAmmoHangar.StackAll();
                        _lastAction = DateTime.Now;
                    }
                }
                State = UnloadLootState.StackItemsCorpLoot;
                break;

            case UnloadLootState.StackItemsCorpLoot:
                if (Settings.Instance.LootHangar != string.Empty)
                {
                    // Don't stack until 5 seconds after the cargo has cleared
                    if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                    {
                        break;
                    }

                    // Stack everything
                    if (corpLootHangar != null)
                    {
                        corpLootHangar.StackAll();
                        _lastAction = DateTime.Now;
                    }
                }
                State = UnloadLootState.StackItemsLootContainer;
                break;

            case UnloadLootState.StackItemsLootContainer:
                if (Settings.Instance.LootContainer != string.Empty)
                {
                    // Don't stack until 5 seconds after the cargo has cleared
                    if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                    {
                        break;
                    }

                    // Stack everything
                    if (lootContainer != null)
                    {
                        lootContainer.StackAll();
                        _lastAction = DateTime.Now;
                    }
                }
                State = UnloadLootState.WaitForStacking;
                break;

            case UnloadLootState.WaitForStacking:
                // Wait 5 seconds after stacking
                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                {
                    break;
                }

                if (Cache.Instance.DirectEve.GetLockedItems().Count == 0)
                {
                    Logging.Log("UnloadLoot: Done");
                    State = UnloadLootState.Done;
                    break;
                }

                if (DateTime.Now.Subtract(_lastAction).TotalSeconds > 120)
                {
                    Logging.Log("UnloadLoot: Stacking items timed out, clearing item locks");
                    Cache.Instance.DirectEve.UnlockItems();

                    Logging.Log("UnloadLoot: Done");
                    State = UnloadLootState.Done;
                    break;
                }
                break;
            }
        }
Exemple #6
0
        public void ProcessState()
        {
            DirectContainer _hangar = null;

            var cargo = DirectEve.Instance.GetShipsCargo();

            if ("Local Hangar" == Hangar)
            {
                _hangar = DirectEve.Instance.GetItemHangar();
            }
            else if ("Ship Hangar" == Hangar)
            {
                _hangar = DirectEve.Instance.GetShipHangar();
            }
            else
            {
                _hangar = DirectEve.Instance.GetCorporationHangar(Hangar);
            }


            switch (State)
            {
            case StateDrop.Idle:
            case StateDrop.Done:
                break;

            case StateDrop.Begin:
                State = StateDrop.OpenItemHangar;
                break;

            case StateDrop.OpenItemHangar:

                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 2)
                {
                    break;
                }

                if ("Local Hangar" == Hangar)
                {
                    // Is the hangar open?
                    if (_hangar.Window == null)
                    {
                        // No, command it to open
                        DirectEve.Instance.ExecuteCommand(DirectCmd.OpenHangarFloor);
                        break;
                    }
                    if (!_hangar.IsReady)
                    {
                        break;
                    }
                }
                else if ("Ship Hangar" == Hangar)
                {
                    if (_hangar.Window == null)
                    {
                        // No, command it to open
                        DirectEve.Instance.ExecuteCommand(DirectCmd.OpenShipHangar);
                        break;
                    }
                    if (!_hangar.IsReady)
                    {
                        break;
                    }
                }
                else
                {
                    if (_hangar.Window == null)
                    {
                        // No, command it to open
                        DirectEve.Instance.OpenCorporationHangar();
                        break;
                    }

                    if (!_hangar.IsReady)
                    {
                        break;
                    }
                }

                Logging.Log("Drop: Opening Hangar");
                State = StateDrop.OpenCargo;
                break;

            case StateDrop.OpenCargo:

                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 2)
                {
                    break;
                }
                // Is cargo open?
                if (cargo.Window == null)
                {
                    // No, command it to open
                    DirectEve.Instance.ExecuteCommand(DirectCmd.OpenCargoHoldOfActiveShip);
                    break;
                }

                if (!cargo.IsReady)
                {
                    break;
                }

                Logging.Log("Drop: Opening Cargo Hold");
                if (Item == 00)
                {
                    State = StateDrop.AllItems;
                }
                else
                {
                    State = StateDrop.MoveItems;
                }

                break;

            case StateDrop.MoveItems:

                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 2)
                {
                    break;
                }

                if (Unit == 00)
                {
                    var DropItem = cargo.Items.FirstOrDefault(i => (i.TypeId == Item));
                    if (DropItem != null)
                    {
                        _hangar.Add(DropItem, DropItem.Quantity);
                        Logging.Log("Drop: Moving all the items");
                        _lastAction = DateTime.Now;
                        State       = StateDrop.WaitForMove;
                    }
                }
                else
                {
                    var DropItem = cargo.Items.FirstOrDefault(i => (i.TypeId == Item));
                    if (DropItem != null)
                    {
                        _hangar.Add(DropItem, Unit);
                        Logging.Log("Drop: Moving item");
                        _lastAction = DateTime.Now;
                        State       = StateDrop.WaitForMove;
                    }
                }

                break;

            case StateDrop.AllItems:

                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 2)
                {
                    break;
                }

                var AllItem = cargo.Items;
                if (AllItem != null)
                {
                    _hangar.Add(AllItem);
                    Logging.Log("Drop: Moving item");
                    _lastAction = DateTime.Now;
                    State       = StateDrop.WaitForMove;
                }


                break;

            case StateDrop.WaitForMove:
                if (cargo.Items.Count != 0)
                {
                    _lastAction = DateTime.Now;
                    break;
                }

                // Wait 5 seconds after moving
                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                {
                    break;
                }

                if (DirectEve.Instance.GetLockedItems().Count == 0)
                {
                    State = StateDrop.StackItemsHangar;
                    break;
                }

                if (DateTime.Now.Subtract(_lastAction).TotalSeconds > 120)
                {
                    Logging.Log("Drop: Moving items timed out, clearing item locks");
                    DirectEve.Instance.UnlockItems();


                    State = StateDrop.StackItemsHangar;
                    break;
                }
                break;

            case StateDrop.StackItemsHangar:
                // Dont stack until 5 seconds after the cargo has cleared
                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                {
                    break;
                }

                // Stack everything
                if (_hangar != null)
                {
                    Logging.Log("Drop: Stacking items");
                    _hangar.StackAll();
                    _lastAction = DateTime.Now;
                }



                State = StateDrop.WaitForStacking;
                break;


            case StateDrop.WaitForStacking:
                // Wait 5 seconds after stacking
                if (DateTime.Now.Subtract(_lastAction).TotalSeconds < 5)
                {
                    break;
                }

                if (DirectEve.Instance.GetLockedItems().Count == 0)
                {
                    Logging.Log("Drop: Done");
                    State = StateDrop.Done;
                    break;
                }

                if (DateTime.Now.Subtract(_lastAction).TotalSeconds > 120)
                {
                    Logging.Log("Drop: Stacking items timed out, clearing item locks");
                    DirectEve.Instance.UnlockItems();

                    Logging.Log("Drop: Done");
                    State = StateDrop.Done;
                    break;
                }
                break;
            }
        }
Exemple #7
0
        private bool MoveItem(bool pickup)
        {
            var directEve = Cache.Instance.DirectEve;

            // Open the item hangar (should still be open)
            var hangar = directEve.GetItemHangar();

            if (hangar.Window == null)
            {
                _nextCourierAction = DateTime.Now.AddSeconds(8);
                Logging.Log("CourierMissionState: Opening hangar floor");
                directEve.ExecuteCommand(DirectCmd.OpenHangarFloor);
                return(false);
            }

            // Wait for it to become ready
            if (!hangar.IsReady)
            {
                return(false);
            }

            var cargo = directEve.GetShipsCargo();

            if (cargo.Window == null)
            {
                _nextCourierAction = DateTime.Now.AddSeconds(8);
                Logging.Log("CourierMissionState: Opening cargo");
                directEve.ExecuteCommand(DirectCmd.OpenCargoHoldOfActiveShip);
                return(false);
            }

            if (!cargo.IsReady)
            {
                return(false);
            }

            string missionItem = "Encoded Data Chip";

            Logging.Log("CourierMission: mission item is: " + missionItem);
            DirectContainer from = pickup ? hangar : cargo;
            DirectContainer to   = pickup ? cargo : hangar;

            // We moved the item
            if (to.Items.Any(i => i.TypeName == missionItem))
            {
                return(true);
            }

            if (directEve.GetLockedItems().Count != 0)
            {
                return(false);
            }

            // Move items
            foreach (var item in from.Items.Where(i => i.TypeName == missionItem))
            {
                Logging.Log("CourierMissionState: Moving [" + item.TypeName + "][" + item.ItemId + "] to " + (pickup ? "cargo" : "hangar"));
                to.Add(item);
            }
            _nextCourierAction = DateTime.Now.AddSeconds(8);
            return(false);
        }
Exemple #8
0
        private bool MoveLoot()
        {
            if (DateTime.UtcNow < _nextUnloadAction)
            {
                if (Settings.Instance.DebugUnloadLoot)
                {
                    Logging.Log("UnloadLoot.MoveLoot", "will Continue in [ " + Math.Round(_nextUnloadAction.Subtract(DateTime.UtcNow).TotalSeconds, 0) + " ] sec", Logging.Debug);
                }
                return(false);
            }

            if (LootIsBeingMoved && AllLootWillFit)
            {
                if (Cache.Instance.DirectEve.GetLockedItems().Count != 0)
                {
                    if (DateTime.UtcNow.Subtract(_lastUnloadAction).TotalSeconds > 120)
                    {
                        Logging.Log("UnloadLootState.MoveLoot", "Moving Loot timed out, clearing item locks", Logging.Orange);
                        Cache.Instance.DirectEve.UnlockItems();
                        _lastUnloadAction = DateTime.UtcNow.AddSeconds(-10);
                        _States.CurrentUnloadLootState = UnloadLootState.Begin;
                        return(false);
                    }

                    if (Settings.Instance.DebugUnloadLoot)
                    {
                        Logging.Log("UnloadLootState.MoveLoot", "Waiting for Locks to clear. GetLockedItems().Count [" + Cache.Instance.DirectEve.GetLockedItems().Count + "]", Logging.Teal);
                    }
                    return(false);
                }
            }

            if (DateTime.UtcNow.Subtract(Cache.Instance.LastStackLootHangar).TotalSeconds < 10)
            {
                if (Settings.Instance.DebugUnloadLoot)
                {
                    Logging.Log("UnloadLootState.MoveLoot", "if (DateTime.UtcNow.Subtract(Cache.Instance.LastStackLootHangar).TotalSeconds < 30)", Logging.Teal);
                }
                if (!Cache.Instance.CloseLootHangar("UnloadLootState.MoveLoot"))
                {
                    return(false);
                }
                Logging.Log("UnloadLoot.MoveLoot", "Loot was worth an estimated [" + Statistics.Instance.LootValue.ToString("#,##0") + "] isk in buy-orders", Logging.Teal);
                LootIsBeingMoved = false;
                AllLootWillFit   = false;
                _States.CurrentUnloadLootState = UnloadLootState.Done;
                return(true);
            }

            if (Cache.Instance.CurrentShipsCargo == null)
            {
                Logging.Log("UnloadLootState.MoveAmmo", "if (Cache.Instance.CurrentShipsCargo == null)", Logging.Teal);
                return(false);
            }

            if (Cache.Instance.CurrentShipsCargo.IsValid)
            {
                if (Settings.Instance.DebugUnloadLoot)
                {
                    Logging.Log("UnloadLootState.MoveLoot", "if (Cache.Instance.CargoHold.IsValid)", Logging.White);
                }
                IEnumerable <DirectItem> lootToMove = Cache.Instance.CurrentShipsCargo.Items.ToList();

                //IEnumerable<DirectItem> somelootToMove = lootToMove;
                if (Settings.Instance.DebugUnloadLoot)
                {
                    Logging.Log("UnloadLootState.MoveLoot", "foreach (DirectItem item in lootToMove) (start)", Logging.White);
                }

                int y = lootToMove.Count();
                int x = 1;

                foreach (DirectItem item in lootToMove)
                {
                    if (!Cache.Instance.InvTypesById.ContainsKey(item.TypeId))
                    {
                        continue;
                    }

                    if (item.Volume != 0)
                    {
                        if (Settings.Instance.DebugLootValue)
                        {
                            Logging.Log("UnloadLoot.Lootvalue", "[" + x + "of" + y + "] ItemName [" + item.TypeName + "] ItemTypeID [" + item.TypeId + "] AveragePrice[" + (int)item.AveragePrice() + "]", Logging.Debug);
                        }
                        Statistics.Instance.LootValue += (int)item.AveragePrice() * Math.Max(item.Quantity, 1);
                    }
                    x++;
                }

                if (Settings.Instance.DebugUnloadLoot)
                {
                    Logging.Log("UnloadLootState.MoveLoot", "foreach (DirectItem item in lootToMove) (done)", Logging.White);
                }
                if (lootToMove.Any() && !LootIsBeingMoved)
                {
                    if (Settings.Instance.DebugUnloadLoot)
                    {
                        Logging.Log("UnloadLootState.MoveLoot", "if (lootToMove.Any() && !LootIsBeingMoved))", Logging.White);
                    }

                    if (string.IsNullOrEmpty(Settings.Instance.LootHangarTabName)) // if we do NOT have the loot hangar configured.
                    {
                        /*
                         * if (Settings.Instance.DebugUnloadLoot) Logging.Log("UnloadLootState.Moveloot", "LootHangar setting is not configured, assuming lothangar is local items hangar (and its 999 item limit)", Logging.White);
                         *
                         * // Move loot to the loot hangar
                         * int roominHangar = (999 - Cache.Instance.LootHangar.Items.Count);
                         * if (roominHangar > lootToMove.Count())
                         * {
                         *  if (Settings.Instance.DebugUnloadLoot) Logging.Log("UnloadLootState.Moveloot", "LootHangar has plenty of room to move loot all in one go", Logging.White);
                         *  Cache.Instance.LootHangar.Add(lootToMove);
                         *  AllLootWillFit = true;
                         *  _lootToMoveWillStillNotFitCount = 0;
                         *  return;
                         * }
                         *
                         * AllLootWillFit = false;
                         * Logging.Log("Unloadloot", "LootHangar is almost full and contains [" + Cache.Instance.LootHangar.Items.Count + "] of 999 total possible stacks", Logging.Orange);
                         * if (roominHangar > 50)
                         * {
                         *  if (Settings.Instance.DebugUnloadLoot) Logging.Log("UnloadLoot", "LootHangar has more than 50 item slots left", Logging.White);
                         *  somelootToMove = lootToMove.Where(i => Settings.Instance.Ammo.All(a => a.TypeId != i.TypeId)).ToList().GetRange(0, 49).ToList();
                         * }
                         * else if (roominHangar > 20)
                         * {
                         *  if (Settings.Instance.DebugUnloadLoot) Logging.Log("UnloadLoot", "LootHangar has more than 20 item slots left", Logging.White);
                         *  somelootToMove = lootToMove.Where(i => Settings.Instance.Ammo.All(a => a.TypeId != i.TypeId)).ToList().GetRange(0, 19).ToList();
                         * }
                         *
                         * if (somelootToMove.Any())
                         * {
                         *  Logging.Log("UnloadLoot", "Moving [" + somelootToMove.Count() + "]  of [" + lootToMove.Count() + "] items into the LootHangar", Logging.White);
                         *  Cache.Instance.LootHangar.Add(somelootToMove);
                         *  return;
                         * }
                         *
                         * if (_lootToMoveWillStillNotFitCount < 7)
                         * {
                         *  _lootToMoveWillStillNotFitCount++;
                         *  if (!Cache.Instance.StackLootHangar("Unloadloot")) return;
                         *  return;
                         * }
                         *
                         * Logging.Log("Unloadloot", "We tried to stack the loothangar 7 times and we still could not fit all the LootToMove into the LootHangar [" + Cache.Instance.LootHangar.Items.Count + " items ]", Logging.Red);
                         * _States.CurrentQuestorState = QuestorState.Error;
                         * return;
                         */
                    }

                    //
                    // if we are using the corp hangar then just grab all the loot in one go.
                    //
                    if (lootToMove.Any() && !LootIsBeingMoved)
                    {
                        //Logging.Log("UnloadLoot", "Moving [" + lootToMove.Count() + "] items from CargoHold to LootHangar which has [" + Cache.Instance.LootHangar.Items.Count() + "] items in it now.", Logging.White);
                        Logging.Log("UnloadLoot.MoveLoot", "Moving [" + lootToMove.Count() + "] items from CargoHold to [" + PutLootHere_Description + "]", Logging.White);
                        AllLootWillFit   = true;
                        LootIsBeingMoved = true;
                        PutLootHere.Add(lootToMove);
                        _nextUnloadAction = DateTime.UtcNow.AddSeconds(5);
                        return(false);
                    }
                    if (Settings.Instance.DebugUnloadLoot)
                    {
                        Logging.Log("UnloadLoot.MoveLoot", "1) if (lootToMove.Any()) is false", Logging.White);
                    }
                    return(false);
                }

                if (Settings.Instance.DebugUnloadLoot)
                {
                    Logging.Log("UnloadLoot.MoveLoot", "2) if (lootToMove.Any()) is false", Logging.White);
                }
                //
                // Stack LootHangar
                //
                if (Settings.Instance.DebugUnloadLoot)
                {
                    Logging.Log("UnloadLoot.MoveLoot", "if (!Cache.Instance.StackLootHangar(UnloadLoot.MoveLoot)) return;", Logging.White);
                }
                _nextUnloadAction = DateTime.UtcNow.AddSeconds(Cache.Instance.RandomNumber(4, 6));
                if (!Cache.Instance.StackLootHangar("UnloadLoot.MoveLoot"))
                {
                    return(false);
                }
                _States.CurrentUnloadLootState = UnloadLootState.Done;
                return(true);
            }

            if (Settings.Instance.DebugUnloadLoot)
            {
                Logging.Log("UnloadLoot.MoveLoot", "Cache.Instance.CargoHold is not yet valid", Logging.White);
            }
            return(false);
        }
Exemple #9
0
        private bool MoveItem(bool pickup)
        {
            DirectEve directEve = Cache.Instance.DirectEve;

            // Open the item hangar (should still be open)
            if (Cache.Instance.ItemHangar == null)
            {
                return(false);
            }

            if (Cache.Instance.CurrentShipsCargo == null)
            {
                return(false);
            }
            string missionItem;

            switch (Cache.Instance.Mission.Name)
            {
            case "Enemies Abound (2 of 5)":                           //lvl4 courier
                missionItem = "Encoded Data Chip";
                break;

            case "In the Midst of Deadspace (2 of 5)":                //lvl4 courier
                missionItem = "Amarr Light Marines";
                break;

            case "Pot and Kettle - Delivery (3 of 5)":                //lvl4 courier
                missionItem = "Large EMP Smartbomb I";
                break;

            case "Pot and Kettle - Making Amends (5 of 5)":           //lvl4 courier
                missionItem = "Mexallon";
                break;

            case "Technological Secrets (2 of 3)": //lvl4 courier
                missionItem = "DNA Sample";        //typeid: 13288	 groupID: 314
                break;

            case "Interstellar Railroad (2 of 4)": //lvl1 courier
                missionItem = "Reports";           //not correct here
                break;

            case "New Frontiers - Toward a Solution (3 of 7)":    //lvl3 courier - this likely needs to be corrected to be the correct mission name
            case "New Frontiers - Nanite Express (6 of 7)":       //lvl3 courier - this likely needs to be corrected to be the correct mission name
            case "Portal to War (3 of 5)":                        //lvl3 courier - this likely needs to be corrected to be the correct mission name
            case "Guristas Strike - The Interrogation (2 of 10)": //lvl3 courier - this likely needs to be corrected to be the correct mission name
            case "Guristas Strike - Possible Leads (4 of 10)":    //lvl3 courier - this likely needs to be corrected to be the correct mission name
            case "Guristas Strike - The Flu Outbreak (6 of 10)":  //lvl3 courier - this likely needs to be corrected to be the correct mission name
            case "Angel Strike - The Interrogation (2 of 10)":    //lvl3 courier - this likely needs to be corrected to be the correct mission name
            case "Angel Strike - Possible Leads (4 of 10)":       //lvl3 courier - this likely needs to be corrected to be the correct mission name
            case "Angel Strike - The Flu Outbreak (6 of 10)":     //lvl3 courier - this likely needs to be corrected to be the correct mission name
                missionItem = "Encoded Data Chip";                //not correct here
                break;

            default:
                missionItem = "Encoded Data Chip";     //likely not correct - add an entry above for the courier mission in question
                break;
            }

            Logging.Log("CourierMissionCtrl", "mission item is: " + missionItem, Logging.White);

            DirectContainer from = null; // = pickup ? Cache.Instance.ItemHangar : Cache.Instance.CargoHold;
            DirectContainer to   = null; // = pickup ? Cache.Instance.CargoHold : Cache.Instance.ItemHangar;

            if (_States.CurrentCourierMissionCtrlState == CourierMissionCtrlState.PickupItem || pickup)
            {
                try
                {
                    // We moved the item
                    if (Cache.Instance.CurrentShipsCargo.Items.Any(i => i.TypeName == missionItem))
                    {
                        moveItemRetryCounter         = 0;
                        _nextCourierMissionCtrlPulse = DateTime.UtcNow.AddSeconds(3);
                        return(true);
                    }

                    //
                    // be flexible on the "from" as we might have the item needed in the ammohangar or loothangar if it is not available in the itemhangar
                    //
                    //from = Cache.Instance.ItemHangar;
                    if (Cache.Instance.ItemHangar.Items.OrderBy(i => i.IsSingleton).ThenBy(i => i.Quantity).Any(i => i.TypeName == missionItem))
                    {
                        from = Cache.Instance.ItemHangar;
                    }
                    else if (!string.IsNullOrEmpty(Settings.Instance.AmmoHangarTabName) && Cache.Instance.DirectEve.Session.SolarSystemId == Cache.Instance.AgentSolarSystemID && Cache.Instance.AmmoHangar.Items.OrderBy(i => i.IsSingleton).ThenBy(i => i.Quantity).Any(i => i.TypeName == missionItem))
                    {
                        from = Cache.Instance.AmmoHangar;
                    }
                    else if (!string.IsNullOrEmpty(Settings.Instance.LootHangarTabName) && Cache.Instance.DirectEve.Session.SolarSystemId == Cache.Instance.AgentSolarSystemID && Cache.Instance.LootHangar.Items.OrderBy(i => i.IsSingleton).ThenBy(i => i.Quantity).Any(i => i.TypeName == missionItem))
                    {
                        from = Cache.Instance.LootHangar;
                    }
                    else
                    {
                        from = Cache.Instance.ItemHangar;
                        //
                        // we cant do the below because we run this routine multiple times after asking the items to move... maybe we need to track that
                        //
                        //Logging.Log("CourierMissionCtrl","Unable to find [" + missionItem + "] in any of the defined hangars - pausing",Logging.Teal);
                        //Cache.Instance.Paused = true;
                    }
                    to = Cache.Instance.CurrentShipsCargo;
                }
                catch (Exception exception)
                {
                    Logging.Log("CourierMissionCtrl", "MoveItem: exception [" + exception + "]", Logging.Red);
                    return(false);
                }
            }

            if (_States.CurrentCourierMissionCtrlState == CourierMissionCtrlState.DropOffItem || !pickup)
            {
                from = Cache.Instance.CurrentShipsCargo;
                to   = Cache.Instance.ItemHangar;
            }

            // We moved the item
            if (to.Items.Any(i => i.TypeName == missionItem))
            {
                moveItemRetryCounter         = 0;
                _nextCourierMissionCtrlPulse = DateTime.UtcNow.AddSeconds(3);
                return(true);
            }

            if (directEve.GetLockedItems().Count != 0)
            {
                moveItemRetryCounter++;
                _nextCourierMissionCtrlPulse = DateTime.UtcNow.AddSeconds(3);
                return(false);
            }

            // Move items
            foreach (DirectItem item in from.Items.Where(i => i.TypeName == missionItem))
            {
                Logging.Log("CourierMissionCtrl", "Moving [" + item.TypeName + "][" + item.ItemId + "] to " + (pickup ? "cargo" : "hangar"), Logging.White);
                to.Add(item);
                _nextCourierMissionCtrlPulse = DateTime.UtcNow.AddSeconds(7);
                continue;
            }

            //_nextCourierAction = DateTime.UtcNow.AddSeconds(8);
            moveItemRetryCounter++;
            return(false);
        }
Exemple #10
0
        /// <summary>
        ///   Loot any wrecks close by
        /// </summary>
        private void LootHostileWrecks()
        {
            // We are not in space yet, wait...
            if (!Cache.Instance.InSpace)
            {
                return;
            }

            if (Cache.Instance.CurrentShipsCargo == null)
            {
                return;
            }

            List <ItemCache> shipsCargo        = Cache.Instance.CurrentShipsCargo.Items.Select(i => new ItemCache(i)).ToList();
            double           freeCargoCapacity = Cache.Instance.CurrentShipsCargo.Capacity - Cache.Instance.CurrentShipsCargo.UsedCapacity;
            IEnumerable <DirectContainerWindow> lootWindows = Cache.Instance.Windows.OfType <DirectContainerWindow>().Where(w => !string.IsNullOrEmpty(w.Name) && w.Name.StartsWith("loot_")).ToList();

            foreach (DirectContainerWindow window in lootWindows)
            {
                // The window is not ready, then continue
                if (!window.IsReady)
                {
                    continue;
                }

                // Get the container
                EntityCache containerEntity = Cache.Instance.EntityById(window.ItemId);

                // Does it no longer exist or is it out of transfer range or its looted
                if (containerEntity == null || containerEntity.Distance > (int)Distances.SafeScoopRange || Cache.Instance.LootedContainers.Contains(containerEntity.Id))
                {
                    Logging.Log("Salvage", "Closing loot window [" + window.ItemId + "]", Logging.White);
                    window.Close();
                    continue;
                }

                // Get the container that is associated with the cargo container
                DirectContainer container = Cache.Instance.DirectEve.GetContainer(window.ItemId);

                // List its items
                IEnumerable <ItemCache> items = container.Items.Select(i => new ItemCache(i));

                // Build a list of items to loot
                List <ItemCache> lootItems = new List <ItemCache>();

                //can we loot all items in one go here?
                //
                // bulk loot code would go here
                //

                // Walk through the list of items ordered by highest value item first
                foreach (ItemCache item in items) //.OrderByDescending(i => i.IskPerM3))
                {
                    // We never want to pick up Bookmarks
                    if (item.IsBookmark)
                    {
                        continue;
                    }

                    // We never want to pick up a cap booster
                    if (item.GroupID == (int)Group.CapacitorGroupCharge)
                    {
                        continue;
                    }

                    // We never want to pick up metal scraps
                    if (item.IsScrapMetal)
                    {
                        continue;
                    }

                    // We never want to pick up Ore...
                    if (item.IsOre)
                    {
                        continue;
                    }

                    // We never want to pick up Low End Minerals
                    if (item.IsLowEndMineral)
                    {
                        continue;
                    }

                    // Never pick up contraband
                    if (item.IsContraband)
                    {
                        continue;
                    }

                    // We pick up loot depending on isk per m3
                    bool isMissionItem = Cache.Instance.MissionItems.Contains((item.Name ?? string.Empty).ToLower());

                    // We are at our max, either make room or skip the item
                    if ((freeCargoCapacity - item.TotalVolume) <= (isMissionItem ? 0 : ReserveCargoCapacity))
                    {
                        // We can't drop items in this container anyway, well get it after its salvaged
                        if (!isMissionItem && containerEntity.GroupId != (int)Group.CargoContainer)
                        {
                            continue;
                        }

                        // Make a list of items which are worth less
                        List <ItemCache> worthLess;
                        if (item.IskPerM3.HasValue)
                        {
                            worthLess = shipsCargo.Where(sc => sc.IskPerM3.HasValue && sc.IskPerM3 < item.IskPerM3).ToList();
                        }
                        else
                        {
                            worthLess = shipsCargo.Where(sc => sc.IskPerM3.HasValue).ToList();
                        }

                        // Remove mission item from this list
                        worthLess.RemoveAll(wl => Cache.Instance.MissionItems.Contains((wl.Name ?? string.Empty).ToLower()));
                        worthLess.RemoveAll(wl => (wl.Name ?? string.Empty).ToLower() == Cache.Instance.BringMissionItem.ToLower());

                        // Nothing is worth less then the current item
                        if (!worthLess.Any())
                        {
                            continue;
                        }

                        // Not enough space even if we dumped the crap
                        if ((freeCargoCapacity + worthLess.Sum(wl => wl.TotalVolume)) < item.TotalVolume)
                        {
                            if (isMissionItem)
                            {
                                Logging.Log("Scoop", "Not enough space for [" + item.Name + "] Need [" + item.TotalVolume + "]m3 - maximum available [" + (freeCargoCapacity + worthLess.Sum(wl => wl.TotalVolume)) + "]m3", Logging.White);
                            }

                            continue;
                        }

                        // Start clearing out items that are worth less
                        List <DirectItem> moveTheseItems = new List <DirectItem>();
                        foreach (ItemCache wl in worthLess.OrderBy(wl => wl.IskPerM3.HasValue ? wl.IskPerM3.Value : double.MaxValue).ThenByDescending(wl => wl.TotalVolume))
                        {
                            // Mark this item as moved
                            moveTheseItems.Add(wl.DirectItem);

                            // Subtract (now) free volume
                            freeCargoCapacity += wl.TotalVolume;

                            // We freed up enough space?
                            if ((freeCargoCapacity - item.TotalVolume) >= ReserveCargoCapacity)
                            {
                                break;
                            }
                        }

                        if (moveTheseItems.Count > 0)
                        {
                            // If this is not a cargo container, then jettison loot
                            if (containerEntity.GroupId != (int)Group.CargoContainer)
                            {
                                if (DateTime.UtcNow.Subtract(_lastJettison).TotalSeconds < 185)
                                {
                                    return;
                                }

                                Logging.Log("Scoop", "Jettisoning [" + moveTheseItems.Count + "] items to make room for the more valuable loot", Logging.White);

                                // Note: This could (in theory) f**k up with the bot jettison an item and
                                // then picking it up again :/ (granted it should never happen unless
                                // mission item volume > reserved volume
                                Cache.Instance.CurrentShipsCargo.Jettison(moveTheseItems.Select(i => i.ItemId));
                                _lastJettison = DateTime.UtcNow;
                                return;
                            }

                            // Move items to the cargo container
                            container.Add(moveTheseItems);

                            // Remove it from the ships cargo list
                            shipsCargo.RemoveAll(i => moveTheseItems.Any(wl => wl.ItemId == i.Id));
                            Logging.Log("Scoop", "Moving [" + moveTheseItems.Count + "] items into the cargo container to make room for the more valuable loot", Logging.White);
                        }
                    }

                    // Update free space
                    freeCargoCapacity -= item.TotalVolume;
                    lootItems.Add(item);
                }

                // Mark container as looted
                Cache.Instance.LootedContainers.Add(containerEntity.Id);

                // Loot actual items
                if (lootItems.Count != 0)
                {
                    Cache.Instance.CurrentShipsCargo.Add(lootItems.Select(i => i.DirectItem));
                    //Logging.Log("Scoop: Looting container [" + containerEntity.Name + "][" + containerEntity.Id + "], [" + lootItems.Count + "] valuable items");
                }
                else
                {
                    Logging.Log("Scoop", "Container [" + containerEntity.Name + "][ID: " + Cache.Instance.MaskedID(containerEntity.Id) + "] contained no valuable items", Logging.White);
                }
            }

            // Open a container in range
            foreach (EntityCache containerEntity in Cache.Instance.UnlootedWrecksAndSecureCans.Where(e => e.Distance <= (int)Distances.SafeScoopRange))
            {
                // Empty wreck, ignore
                if (containerEntity.IsWreckEmpty) //this only returns true if it is a wreck, not for cargo containers, spawn containers, etc.
                {
                    continue;
                }

                // We looted this container
                if (Cache.Instance.LootedContainers.Contains(containerEntity.Id))
                {
                    continue;
                }

                // We already opened the loot window
                DirectContainerWindow window = lootWindows.FirstOrDefault(w => w.ItemId == containerEntity.Id);
                if (window != null)
                {
                    continue;
                }

                // Ignore open request within 10 seconds
                if (_openedContainers.ContainsKey(containerEntity.Id) && DateTime.UtcNow.Subtract(_openedContainers[containerEntity.Id]).TotalSeconds < 10)
                {
                    continue;
                }

                // Open the container
                Logging.Log("Scoop", "Opening container [" + containerEntity.Name + "][ID: " + Cache.Instance.MaskedID(containerEntity.Id) + "]", Logging.White);
                containerEntity.OpenCargo();
                _openedContainers[containerEntity.Id] = DateTime.UtcNow;
                break;
            }
        }