/// <summary> /// Item container /// </summary> /// <param name="itemId"></param> /// <returns></returns> public DirectContainer GetContainer(long itemId) { if (!_containers.ContainsKey(itemId)) { _containers[itemId] = DirectContainer.GetContainer(this, itemId); } return(_containers[itemId]); }
/// <summary> /// Internal "OnFrame" handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrameworkOnFrame(object sender, EventArgs e) { var st = new Stopwatch(); st.Start(); using (var pySharp = new PySharp.PySharp(true)) { // Make the link to the instance PySharp = pySharp; //#if !NO_DIRECTEVE_SECURITY // // Pulse security // if (_security == null || !_security.Pulse()) // { // if (!_securityCheckFailed) // { // _securityCheckFailed = true; // Log("DirectEve supported instance check failed!"); // } // return; // } // if (_securityCheckFailed) // { // _securityCheckFailed = false; // Log("DirectEve supported instance check succeeded, continuing..."); // } //#endif // Get current target list dynamic ps = pySharp; // targetsByID and targeting are now dictionaries List<long> targets = ps.__builtin__.sm.services["target"].targetsByID.keys().ToList<long>(); targets.AddRange(ps.__builtin__.sm.services["target"].targeting.keys().ToList<long>()); // Update currently locked targets targets.ForEach(t => _lastKnownTargets[t] = DateTime.Now); // Remove all targets that have not been locked for 3 seconds foreach (var t in _lastKnownTargets.Keys.ToArray()) { if (DateTime.Now.AddSeconds(-3) < _lastKnownTargets[t]) continue; _lastKnownTargets.Remove(t); } ////Populate the statistic variables if (_enableStatisticsModifying) { CheckStatistics(); } // Check if we're still valid if (OnFrame != null) OnFrame(this, new EventArgs()); // Clear any cache that we had during this frame _localSvcCache.Clear(); _entitiesById = null; _windows = null; _modules = null; _const = null; _bookmarks = null; _agentMissions = null; _containers.Clear(); _itemHangar = null; _shipHangar = null; _shipsCargo = null; _shipsOreHold = null; _shipsModules = null; _shipsDroneBay = null; _listGlobalAssets = null; _me = null; _activeShip = null; _standings = null; _navigation = null; _session = null; _login = null; _skills = null; // Remove the link PySharp = null; st.Stop(); _lastOnframeTook = st.ElapsedMilliseconds; } }
/// <summary> /// Invalidate the cached items /// </summary> public void InvalidateCache() { try { // // this list of variables is cleared every pulse. // _activeDrones = null; _agent = null; _aggressed = null; _allBookmarks = null; _ammoHangar = null; _approaching = null; _activeDrones = null; _bestDroneTargets = null; _bestPrimaryWeaponTargets = null; _bigObjects = null; _bigObjectsAndGates = null; _combatTargets = null; _currentShipsCargo = null; _containerInSpace = null; _containers = null; _entities = null; _entitiesNotSelf = null; _entitiesOnGrid = null; _entitiesById.Clear(); _fittingManagerWindow = null; _gates = null; _IDsinInventoryTree = null; _itemHangar = null; _jumpBridges = null; _lootContainer = null; _lootHangar = null; _lpStore = null; _maxLockedTargets = null; _maxDroneRange = null; _maxrange = null; _maxTargetRange = null; _modules = null; _modulesAsItemCache = null; _myShipEntity = null; _objects = null; _potentialCombatTargets = null; _primaryWeaponPriorityTargetsPerFrameCaching = null; _safeSpotBookmarks = null; _star = null; _stations = null; _stargate = null; _stargates = null; _targets = null; _targeting = null; _targetedBy = null; _TotalTargetsandTargeting = null; _unlootedContainers = null; _unlootedWrecksAndSecureCans = null; _weapons = null; _windows = null; _primaryWeaponPriorityEntities = null; _dronePriorityEntities = null; _preferredPrimaryWeaponTarget = null; //if (QuestorJustStarted && InvalidateCacheQuestorJustStartedFlag) //{ // InvalidateCacheQuestorJustStartedFlag = false; // if (Settings.Instance.DebugPreferredPrimaryWeaponTarget) Logging.Log("Cache.InvalidateCache", "QuestorJustStarted: initializing", Logging.Debug); if (_primaryWeaponPriorityTargets != null && _primaryWeaponPriorityTargets.Any()) { _primaryWeaponPriorityTargets.ForEach(pt => pt.ClearCache()); } if (_dronePriorityTargets != null && _dronePriorityTargets.Any()) { _dronePriorityTargets.ForEach(pt => pt.ClearCache()); } //} } catch (Exception exception) { Logging.Log("Cache.InvalidateCache", "Exception [" + exception + "]", Logging.Debug); } }
public void ProcessState() { // Only pulse state changes every 1.5s if (DateTime.UtcNow.Subtract(_lastPulse).TotalMilliseconds < Time.Instance.QuestorPulse_milliseconds) //default: 1500ms return; _lastPulse = DateTime.UtcNow; if (!Cache.Instance.InStation) return; if (Cache.Instance.InSpace) return; if (DateTime.UtcNow < Cache.Instance.LastInSpace.AddSeconds(20)) // we wait 20 seconds after we last thought we were in space before trying to do anything in station return; if (!string.IsNullOrEmpty(Settings.Instance.LootContainerName) && Cache.Instance.LootContainer != null && Cache.Instance.LootContainer.IsValid) { PutLootHere = Cache.Instance.LootContainer; PutLootHere_Description = "LootContainer Named: [" + Settings.Instance.LootContainerName + "]"; } else if (!String.IsNullOrEmpty(Settings.Instance.LootHangarTabName) && Cache.Instance.LootHangar != null) //&& Cache.Instance.LootHangar.IsValid) { PutLootHere = Cache.Instance.LootHangar; PutLootHere_Description = "LootHangar Named: [" + Settings.Instance.LootHangarTabName + "]"; } else { PutLootHere = Cache.Instance.ItemHangar; PutLootHere_Description = "ItemHangar"; } switch (_States.CurrentUnloadLootState) { case UnloadLootState.Idle: case UnloadLootState.Done: break; case UnloadLootState.Begin: if (DateTime.UtcNow < _nextUnloadAction) { if (Settings.Instance.DebugUnloadLoot) Logging.Log("UnloadLoot", "will Continue in [ " + Math.Round(_nextUnloadAction.Subtract(DateTime.UtcNow).TotalSeconds, 0) + " ] sec", Logging.Debug); break; } AmmoIsBeingMoved = false; LootIsBeingMoved = false; _lastUnloadAction = DateTime.UtcNow.AddSeconds(-10); _States.CurrentUnloadLootState = UnloadLootState.MoveAmmo; break; case UnloadLootState.MoveAmmo: if (!MoveAmmo()) return; //_States.CurrentUnloadLootState = UnloadLootState.MoveLoot; break; case UnloadLootState.MoveLoot: if (!MoveLoot()) return; //_States.CurrentUnloadLootState = UnloadLootState.Done; break; } }
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.OpenItemsHangar("Drop")) 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.OpenCargoHold("Drop")) 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.OpenCargoHold("Drop")) return; DirectItem dropItem; if (Unit == 00) { try { if (Settings.Instance.DebugQuestorManager) Logging.Log("Drop", "Item TypeID is [" + Item + "]",Logging.Debug); int x = 1; foreach (DirectItem ItemTest in Cache.Instance.CargoHold.Items) { if (Settings.Instance.DebugQuestorManager) Logging.Log("Drop", "[" + x + "] ItemName: [" + ItemTest.TypeName + "]", Logging.Debug); } if (Cache.Instance.CargoHold.Items.Any(i => i.TypeId == Item)) { dropItem = Cache.Instance.CargoHold.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.CargoHold.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.CargoHold.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; } }
/// <summary> /// Item hangar container /// </summary> /// <returns></returns> public DirectContainer GetItemHangar() { return(_itemHangar ?? (_itemHangar = DirectContainer.GetItemHangar(this))); }
/// <summary> /// Ship's modules container /// </summary> /// <returns></returns> public DirectContainer GetShipsModules() { return _shipsModules ?? (_shipsModules = DirectContainer.GetShipsModules(this)); }
/// <summary> /// Ship's cargo container /// </summary> /// <returns></returns> public DirectContainer GetShipsCargo() { return _shipsCargo ?? (_shipsCargo = DirectContainer.GetShipsCargo(this)); }
/// <summary> /// Get the corporation hangar container based on division name /// </summary> /// <param name="divisionName"></param> /// <returns></returns> public DirectContainer GetCorporationHangar(string divisionName) { return(DirectContainer.GetCorporationHangar(this, divisionName)); }
/// <summary> /// Ship's modules container /// </summary> /// <returns></returns> public DirectContainer GetShipsModules() { return(_shipsModules ?? (_shipsModules = DirectContainer.GetShipsModules(this))); }
/// <summary> /// Ship's drone bay /// </summary> /// <returns></returns> public DirectContainer GetShipsDroneBay() { return(_shipsDroneBay ?? (_shipsDroneBay = DirectContainer.GetShipsDroneBay(this))); }
/// <summary> /// Ship's ore hold container /// </summary> /// <returns></returns> public DirectContainer GetShipsOreHold() { return(_shipsOreHold ?? (_shipsOreHold = DirectContainer.GetShipsOreHold(this))); }
/// <summary> /// Ship's cargo container /// </summary> /// <returns></returns> public DirectContainer GetShipsCargo() { return(_shipsCargo ?? (_shipsCargo = DirectContainer.GetShipsCargo(this))); }
/// <summary> /// Ship hangar container /// </summary> /// <returns></returns> public DirectContainer GetShipHangar() { return(_shipHangar ?? (_shipHangar = DirectContainer.GetShipHangar(this))); }
/// <summary> /// Item hangar container /// </summary> /// <returns></returns> public DirectContainer GetItemHangar() { return _itemHangar ?? (_itemHangar = DirectContainer.GetItemHangar(this)); }
/// <summary> /// Get the corporation hangar container based on division id (1-7) /// </summary> /// <param name="divisionId"></param> /// <returns></returns> public DirectContainer GetCorporationHangar(int divisionId) { return(DirectContainer.GetCorporationHangar(this, divisionId)); }
/// <summary> /// Ship hangar container /// </summary> /// <returns></returns> public DirectContainer GetShipHangar() { return _shipHangar ?? (_shipHangar = DirectContainer.GetShipHangar(this)); }
public DirectContainer GetCorporationHangarArray(long itemId, string divisionName) { return(DirectContainer.GetCorporationHangarArray(this, itemId, divisionName)); }
/// <summary> /// Ship's drone bay /// </summary> /// <returns></returns> public DirectContainer GetShipsDroneBay() { return _shipsDroneBay ?? (_shipsDroneBay = DirectContainer.GetShipsDroneBay(this)); }
public DirectContainer GetCorporationHangarArray(long itemId, int divisionId) { return(DirectContainer.GetCorporationHangarArray(this, itemId, divisionId)); }
/// <summary> /// Ship's ore hold container /// </summary> /// <returns></returns> public DirectContainer GetShipsOreHold() { return _shipsOreHold ?? (_shipsOreHold = DirectContainer.GetShipsOreHold(this)); }
/// <summary> /// Internal "OnFrame" handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrameworkOnFrame(object sender, EventArgs e) { var st = new Stopwatch(); st.Start(); using (var pySharp = new PySharp.PySharp(true)) { // Make the link to the instance PySharp = pySharp; //#if !NO_DIRECTEVE_SECURITY // // Pulse security // if (_security == null || !_security.Pulse()) // { // if (!_securityCheckFailed) // { // _securityCheckFailed = true; // Log("DirectEve supported instance check failed!"); // } // return; // } // if (_securityCheckFailed) // { // _securityCheckFailed = false; // Log("DirectEve supported instance check succeeded, continuing..."); // } //#endif // Get current target list dynamic ps = pySharp; // targetsByID and targeting are now dictionaries List <long> targets = ps.__builtin__.sm.services["target"].targetsByID.keys().ToList <long>(); targets.AddRange(ps.__builtin__.sm.services["target"].targeting.keys().ToList <long>()); // Update currently locked targets targets.ForEach(t => _lastKnownTargets[t] = DateTime.Now); // Remove all targets that have not been locked for 3 seconds foreach (var t in _lastKnownTargets.Keys.ToArray()) { if (DateTime.Now.AddSeconds(-3) < _lastKnownTargets[t]) { continue; } _lastKnownTargets.Remove(t); } ////Populate the statistic variables if (_enableStatisticsModifying) { CheckStatistics(); } // Check if we're still valid if (OnFrame != null) { OnFrame(this, new EventArgs()); } // Clear any cache that we had during this frame _localSvcCache.Clear(); _entitiesById = null; _windows = null; _modules = null; _const = null; _bookmarks = null; _agentMissions = null; _containers.Clear(); _itemHangar = null; _shipHangar = null; _shipsCargo = null; _shipsOreHold = null; _shipsModules = null; _shipsDroneBay = null; _listGlobalAssets = null; _me = null; _activeShip = null; _standings = null; _navigation = null; _session = null; _login = null; _skills = null; // Remove the link PySharp = null; st.Stop(); _lastOnframeTook = st.ElapsedMilliseconds; } }