예제 #1
0
파일: Arm.cs 프로젝트: isxGames/QuestorISX
        private static bool LookForItem(string itemToFind, EveCom.InventoryContainer hangarToCheckForItemsdWeAlreadyMoved)
        {
            try
            {
                _weHaveThisManyOfThoseItemsInCargo = 0;
                _weHaveThisManyOfThoseItemsInItemHangar = 0;
                _weHaveThisManyOfThoseItemsInAmmoHangar = 0;
                _weHaveThisManyOfThoseItemsInLootHangar = 0;
                _cargoItems = new List<EveCom.Item>();

                _itemHangarItems = new List<EveCom.Item>();
                _itemHangarItem = null;

                _ammoHangarItems = new List<EveCom.Item>();
                _ammoHangarItem = null;

                _lootHangarItems = new List<EveCom.Item>();
                _lootHangarItem = null;
                //
                // check the local cargo for items and subtract the items in the cargo from the quantity we still need to move to our cargohold
                //
                if (hangarToCheckForItemsdWeAlreadyMoved != null && hangarToCheckForItemsdWeAlreadyMoved.Items.Any())
                {
                    _cargoItems = hangarToCheckForItemsdWeAlreadyMoved.Items.Where(i => (i.Type ?? string.Empty).ToLower() == itemToFind).ToList();
                    _weHaveThisManyOfThoseItemsInCargo = _cargoItems.Sum(i => i.Stacksize);
                    //do not return here
                }

                //
                // check itemhangar for the item
                //
                try
                {
                    if (QuestorCache.Instance.ItemHangar == null) return false;
                    if (QuestorCache.Instance.ItemHangar.Items.Any())
                    {
                        if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "We have [" + QuestorCache.Instance.ItemHangar.Items.Count() + "] total items in ItemHangar", Logging.Debug);
                        if (QuestorCache.Instance.ItemHangar.Items.Any(i => (i.Type ?? string.Empty).ToLower() == itemToFind.ToLower()))
                        {
                            _itemHangarItems = QuestorCache.Instance.ItemHangar.Items.Where(i => (i.Type ?? string.Empty).ToLower() == itemToFind.ToLower()).ToList();
                            _itemHangarItem = _itemHangarItems.FirstOrDefault();
                            _weHaveThisManyOfThoseItemsInItemHangar = _itemHangarItems.Sum(i => i.Stacksize);
                            if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "We have [" + _weHaveThisManyOfThoseItemsInItemHangar + "] [" + itemToFind + "] in ItemHangar", Logging.Debug);
                        }
                        else if (QuestorCache.Instance.ItemHangar.Items.Any(i => i.TypeID == Drones.DroneTypeId))
                        {
                            IEnumerable<EveCom.Item> dronesInItemHangar = QuestorCache.Instance.ItemHangar.Items.Where(i => i.TypeID == Drones.DroneTypeId).ToList();
                            Logging.Log(WeAreInThisStateForLogs(), "[" + itemToFind + "] not found by typeName in ItemHangar, but we DID find DroneTypeID [" + Drones.DroneTypeId + "]. We found [" + dronesInItemHangar.Count() + "] of them in the Itemhangar", Logging.Debug);
                            _itemHangarItem = dronesInItemHangar.FirstOrDefault();
                            _weHaveThisManyOfThoseItemsInItemHangar = dronesInItemHangar.Sum(i => i.Stacksize);
                            return true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "Exception [" + ex + "]", Logging.Debug);
                }

                /**
                //
                // check ammohangar for the item
                //
                try
                {
                    if (!string.IsNullOrEmpty(Settings.Instance.AmmoHangarTabName))
                    {
                        if (Cache.Instance.AmmoHangar == null) return false;

                        if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "AmmoHangar is defined", Logging.Debug);

                        if (Cache.Instance.AmmoHangar.Items.Any())
                        {
                            if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "We have [" + Cache.Instance.AmmoHangar.Items.Count() + "] total items in AmmoHangar", Logging.Debug);
                            if (Cache.Instance.AmmoHangar.Items.Any(i => (i.Type ?? string.Empty).ToLower() == itemToFind.ToLower()))
                            {
                                _ammoHangarItems = Cache.Instance.AmmoHangar.Items.Where(i => (i.Type ?? string.Empty).ToLower() == itemToFind.ToLower()).ToList();
                                _ammoHangarItem = _ammoHangarItems.FirstOrDefault();
                                WeHaveThisManyOfThoseItemsInAmmoHangar = _ammoHangarItems.Sum(i => i.Stacksize);
                                if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "We have [" + WeHaveThisManyOfThoseItemsInAmmoHangar + "] [" + itemToFind + "] in AmmoHangar", Logging.Debug);
                            }
                            else if (Cache.Instance.AmmoHangar.Items.Any(i => i.TypeID == Drones.DroneTypeId))
                            {
                                IEnumerable<EveCom.Item> _dronesInItemHangar = Cache.Instance.AmmoHangar.Items.Where(i => i.TypeID == Drones.DroneTypeId).ToList();
                                Logging.Log(WeAreInThisStateForLogs(), "[" + itemToFind + "] not found by typeName in ItemHangar, but we DID find DroneTypeID [" + Drones.DroneTypeId + "]. We found [" + _dronesInItemHangar.Count() + "] of them in the AmmoHangar", Logging.Debug);
                                _ammoHangarItem = _dronesInItemHangar.FirstOrDefault();
                                WeHaveThisManyOfThoseItemsInAmmoHangar = _dronesInItemHangar.Sum(i => i.Stacksize);
                                return true;
                            }
                        }

                    }
                }
                catch (Exception ex)
                {
                    if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "Exception [" + ex + "]", Logging.Debug);
                }

                //
                // check loothangar for the item
                //
                try
                {
                    if (!string.IsNullOrEmpty(Settings.Instance.LootHangarTabName) && Settings.Instance.LootHangarTabName != Settings.Instance.AmmoHangarTabName)
                    {
                        if (Cache.Instance.LootHangar == null) return false;

                        if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "LootHangar is defined and is different from AmmoHangar", Logging.Debug);

                        if (Cache.Instance.LootHangar.Items.Any())
                        {
                            if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "We have [" + Cache.Instance.LootHangar.Items.Count() + "] total items in LootHangar", Logging.Debug);
                            if (Cache.Instance.LootHangar.Items.Any(i => (i.Type ?? string.Empty).ToLower() == itemToFind.ToLower()))
                            {
                                _lootHangarItems = Cache.Instance.LootHangar.Items.Where(i => (i.Type ?? string.Empty).ToLower() == itemToFind.ToLower()).ToList();
                                _lootHangarItem = _lootHangarItems.FirstOrDefault();
                                WeHaveThisManyOfThoseItemsInLootHangar = _lootHangarItems.Sum(i => i.Stacksize);
                                if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "We have [" + WeHaveThisManyOfThoseItemsInLootHangar + "] [" + itemToFind + "] in LootHangar", Logging.Debug);
                            }
                            else if (Cache.Instance.LootHangar.Items.Any(i => i.TypeId == Drones.DroneTypeId))
                            {
                                IEnumerable<EveCom.Item> dronesInItemHangar = Cache.Instance.LootHangar.Items.Where(i => i.TypeID == Drones.DroneTypeId).ToList();
                                Logging.Log(WeAreInThisStateForLogs(), "[" + itemToFind + "] not found by typeName in LootHangar, but we DID find DroneTypeID [" + Drones.DroneTypeId + "]. We found [" + dronesInItemHangar.Count() + "] of them in the Loothangar", Logging.Debug);
                                _lootHangarItem = dronesInItemHangar.FirstOrDefault();
                                WeHaveThisManyOfThoseItemsInLootHangar = dronesInItemHangar.Sum(i => i.Stacksize);
                                return true;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (Logging.DebugArm) Logging.Log(WeAreInThisStateForLogs(), "Exception [" + ex + "]", Logging.Debug);
                }

                **/
                //
                // we searched all hangars, hopefully found some items...
                //
                return true;
            }
            catch (Exception exception)
            {
                Logging.Log(WeAreInThisStateForLogs(), "Exception [" + exception + "]", Logging.Debug);
                return false;
            }
        }
예제 #2
0
 public ItemCache(EveCom.Item item)
 {
     _item = item;
 }
예제 #3
0
파일: Arm.cs 프로젝트: isxGames/QuestorISX
 ///
 ///   Invalidate the cached items every pulse (called from cache.invalidatecache, which itself is called every frame in questor.cs)
 /// 
 public static void InvalidateCache()
 {
     try
     {
         //
         // this list of variables is cleared every pulse.
         //
         _cargoItems = null;
         _itemHangarItem = null;
         _itemHangarItems = null;
     }
     catch (Exception exception)
     {
         Logging.Log("Arm.InvalidateCache", "Exception [" + exception + "]", Logging.Debug);
     }
 }