Exemple #1
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);
        }