private void Flee() { var methodName = "Flee"; LogTrace(methodName); //If I'm in a station, no further action required if (_meCache.InStation) { return; } //If we're moving, it's not obstacle avoidance movement, and we haven't done flee move or are moving to the wrong destination... clear movement var destination = _movement.DestinationQueue.FirstOrDefault(); if (destination != null && !destination.IsObstacleAvoidanceMovement & (FleeDestination == null || destination != FleeDestination)) { LogMessage(methodName, LogSeverityTypes.Standard, "We have queued destinations and either no set flee destination or are moving to the wrong destination. Clearing movemenet queue."); _movement.ClearDestinations(true); if (_meCache.ToEntity.Mode != (int)Modes.Warp) { LogMessage(methodName, LogSeverityTypes.Debug, "Stopping ship in an attempt to abort/prevent warp."); _isxeveProvider.Eve.Execute(ExecuteCommand.CmdStopShip); } } //If we've already got the flee destination queued, we don't need to do a damn thing. if (FleeDestination != null && _movement.DestinationQueue.Contains(FleeDestination)) { LogMessage(methodName, LogSeverityTypes.Debug, "Already have a flee destination..."); return; } if (_safespots.IsSafe()) { LogMessage(methodName, LogSeverityTypes.Debug, "Already at a safe location..."); //If we're fleeing because local is unsafe and I'm at a safespot and have a cloak, activate it. if (FleeReason == FleeReasons.DowntimeNear || FleeReason == FleeReasons.LocalUnsafe) { var cloakingDevice = _ship.CloakingDeviceModules.FirstOrDefault(); if (cloakingDevice != null && !cloakingDevice.IsActive) { LogMessage(methodName, LogSeverityTypes.Debug, "At safe location, we have a cloak, and downtime is near or local is unsafe. We should cloak."); cloakingDevice.Click(); } } } else { LogMessage(methodName, LogSeverityTypes.Debug, "Not at a safe location - moving to one."); var safeDestination = _safespots.GetSafeSpot(); FleeDestination = safeDestination; _movement.QueueDestination(FleeDestination); } }
protected override void ProcessPulseState() { var methodName = "ProcessPulseState"; LogTrace(methodName); //Switch the state and handle it switch (_rattingState) { case RattingStates.Idle: //Do nothing during idle. break; case RattingStates.Defend: //Again do nothing; we're fleeing or hiding. ClearEntities(); break; case RattingStates.Rearm: //Add later break; case RattingStates.KillRats: KillRats(); break; case RattingStates.ChangeBelts: ChangeBelt(); break; case RattingStates.Error: if (_safespots.IsSafe()) { return; } var safespot = _safespots.GetSafeSpot(); _movement.QueueDestination(safespot); break; } }
protected override void ProcessPulseState() { var methodName = "ProcessPulseState"; LogTrace(methodName); LogMessage(methodName, LogSeverityTypes.Debug, "State: {0}", _boostOrcaState); switch (_boostOrcaState) { case BoostOrcaStates.Idle: _boostOrcaState = BoostOrcaStates.GetInPosition; goto case BoostOrcaStates.GetInPosition; case BoostOrcaStates.GetInPosition: var boostLocationBookmark = _bookMarkCache.FirstBookMarkMatching(_miningConfiguration.BoostOrcaBoostLocationLabel, true); if (boostLocationBookmark == null) { LogMessage(methodName, LogSeverityTypes.Standard, "Error: Could not find a bookmark matching the boost orca location label of \"{0}\" in this system.", _miningConfiguration.BoostOrcaBoostLocationLabel); _boostOrcaState = BoostOrcaStates.Error; return; } if (_meCache.InStation) { LogMessage(methodName, LogSeverityTypes.Debug, "Undocking."); _movement.QueueDestination( new Destination(DestinationTypes.Undock)); return; } //Now I need to get to a safespot in space. Preferrably a tower but I can't know what type it is. //If I'm out of warp range, warp to it if (!_bookmarks.IsAtBookmark(boostLocationBookmark)) { _movement.QueueDestination( new Destination(DestinationTypes.BookMark, boostLocationBookmark.Id)); LogMessage(methodName, LogSeverityTypes.Standard, "Moving to boost location bookmark \"{0}\".", boostLocationBookmark.Label); } else { _boostOrcaState = BoostOrcaStates.WaitInPosition; goto case BoostOrcaStates.WaitInPosition; } break; case BoostOrcaStates.WaitInPosition: //Just chill here and boost for the fleet. Turn on ganglinks as needed. if (_ship.GangLinkModules.Count > 0 && !_ship.GangLinkModules[0].IsActive) { LogMessage(methodName, LogSeverityTypes.Standard, "Activating ganglink modules."); _ship.ActivateModuleList(_ship.GangLinkModules, true); } if (_ship.DamageControlModules.Count > 0 && !_ship.DamageControlModules[0].IsActive) { LogMessage(methodName, LogSeverityTypes.Standard, "Activating damage control module."); _ship.ActivateModuleList(_ship.DamageControlModules, false); } break; case BoostOrcaStates.Error: //Make sure I'm at a safespot; preferrably in space, station if required. if (!_safespots.IsSafe()) { var destination = _safespots.GetSafeSpot(); _movement.QueueDestination(destination); } IsEnabled = false; break; } }