public override void Pulse() { var methodName = "Pulse"; LogTrace(methodName); if (!ShouldPulse()) { return; } if (!_meCache.InSpace || _meCache.InStation) { return; } if (_movement.IsMoving && _movement.MovementType == MovementTypes.Warp) { //Make sure all modules are off _ship.DeactivateModuleList(_ship.MiningLaserModules, true); _ship.DeactivateModuleList(_ship.SalvagerModules, true); if (Core.StealthBot.Config.MiningConfig.UseMiningDrones && _drones.DronesInSpace > 0) { _drones.RecallAllDrones(true); } return; } if (_randomWait.ShouldWait()) { return; } var activeTargetId = _meCache.ActiveTargetId; if (activeTargetId <= 0) { return; } StartPulseProfiling(); _capacitor = _meCache.Ship.Capacitor; var activeTarget = _entityProvider.EntityWrappersById[activeTargetId]; var activeQueueTarget = _targeting.GetActiveQueueTarget(); if (activeQueueTarget != null && !_targeting.WasTargetChangedThisFrame) { switch (activeQueueTarget.Type) { case TargetTypes.Mine: //If it's not in range, approach //Otherwise mine if (_entityProvider.EntityWrappersById[activeQueueTarget.Id].Distance > _ship.MaximumMiningRange && (_meCache.ToEntity.Approaching == null || _meCache.ToEntity.Approaching.ID != activeQueueTarget.Id)) { //Dequeue it, shouldn't be queued any more _targetQueue.DequeueTarget(activeQueueTarget.Id); //Unlock it _targeting.UnlockTarget(activeTarget); } break; case TargetTypes.LootSalvage: TractorTarget(activeQueueTarget); break; } } MineTargets(); EndPulseProfiling(); }
public override void Pulse() { var methodName = "Pulse"; LogTrace(methodName); if (!ShouldPulse()) { return; } if (!_meCache.InSpace || _meCache.InStation || (_movement.IsMoving && _movement.MovementType != MovementTypes.Approach)) { return; } StartPulseProfiling(); var wasTargetUnlocked = UnlockUnqueuedTargets(); if (wasTargetUnlocked) { EndPulseProfiling(); return; } WasTargetChangedThisFrame = false; //reset the modules dictionary _modulesBuilt = false; ModulesOnEntity.Clear(); _queueTargetsByEntityId.Clear(); if (_targetQueue.Targets.Count == 0) { _ship.DeactivateModuleList(_ship.SensorBoosterModules, true); EndPulseProfiling(); return; } //Activate sensor boosters _ship.ActivateModuleList(_ship.SensorBoosterModules, true); //TargetQueue.SortQueue(); //StartMethodProfiling("BuildE_QT_Dictionary"); foreach (QueueTarget queueTarget in _targetQueue.Targets) { _queueTargetsByEntityId.Add(queueTarget.Id, queueTarget); } //EndMethodProfiling(); //StartMethodProfiling("TargetNext"); if (_randomWait.ShouldWait()) { EndPulseProfiling(); return; } if (IsTargetJammed) { LogMessage(methodName, LogSeverityTypes.Standard, "Targeting jammed, not targeting"); _alerts.TargetJammed(); return; } ProcessTargetQueue(); //EndMethodProfiling(); EndPulseProfiling(); }