NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

movementFunctions.py (26307B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\services\menuSvcExtras\movementFunctions.py
      2 from ballparkCommon.parkhelpers.warpSubjects import WarpSubjects
      3 from player_messaging.client.ui_message import message_player, prompt_player_fsd_dialog
      4 from randomJump import get_error_label
      5 from spacecomponents.common.componentConst import SHIPCASTER_LAUNCHER, FILAMENT_SPOOLUP
      6 from spacecomponents.common.helper import HasShipcasterComponent, HasStarterShipcasterComponent
      7 from carbon.common.script.sys.serviceConst import ROLE_GML
      8 from carbon.common.script.util.format import FmtAmt, FmtDist
      9 from carbonui.uicore import uicore
     10 import destiny
     11 from eve.client.script.parklife import states
     12 import eve.client.script.ui.util.defaultRangeUtils as defaultRangeUtils
     13 from eve.common.lib import appConst as const
     14 from eve.common.script.sys.eveCfg import CheckShipHasFighterBay, IsControllingStructure
     15 from evefleet import FORMATION_SKILL, FORMATION_DISTANCE_SKILL
     16 from evefleet.client.util import GetFormationSelected, GetFormationSpacingSelected, GetFormationSizeSelected
     17 from eveexceptions import UserError, ExceptionEater
     18 from eveservices.menu import GetMenuService
     19 from evetypes import IsUpwellStargate
     20 from evedungeons.client.ship_restrictions_window import ShipRestrictionsWindow
     21 import carbonui.const as uiconst
     22 import localization
     23 import log
     24 from eve.client.script.ui.util import uix
     25 from menu import MenuLabel
     26 ORBIT_RANGES = (500, 1000, 2500, 5000, 7500, 10000, 15000, 20000, 25000, 30000)
     27 KEEP_AT_RANGE_RANGES = (500, 1000, 2500, 5000, 7500, 10000, 15000, 20000, 25000, 30000)
     28 
     29 def SetDefaultDist(key):
     30     if not key:
     31         return
     32     minDist, maxDist = {'Orbit': (500, 1000000),
     33      'KeepAtRange': (50, 1000000),
     34      'WarpTo': (const.minWarpEndDistance, const.maxWarpEndDistance)}.get(key, (500, 1000000))
     35     current = GetMenuService().GetDefaultActionDistance(key)
     36     current = current or ''
     37     fromDist = FmtAmt(minDist)
     38     toDist = FmtAmt(maxDist)
     39     if key == 'KeepAtRange':
     40         hint = localization.GetByLabel('UI/Inflight/SetDefaultKeepAtRangeDistanceHint', fromDist=fromDist, toDist=toDist)
     41         caption = localization.GetByLabel('UI/Inflight/Submenus/KeepAtRange')
     42     elif key == 'Orbit':
     43         hint = localization.GetByLabel('UI/Inflight/SetDefaultOrbitDistanceHint', fromDist=fromDist, toDist=toDist)
     44         caption = localization.GetByLabel('UI/Inflight/OrbitObject')
     45     elif key == 'WarpTo':
     46         hint = localization.GetByLabel('UI/Inflight/SetDefaultWarpWithinDistanceHint', fromDist=fromDist, toDist=toDist)
     47         caption = localization.GetByLabel('UI/Inflight/Submenus/WarpToWithin')
     48     else:
     49         hint = ''
     50         caption = ''
     51     r = uix.QtyPopup(maxvalue=maxDist, minvalue=minDist, setvalue=current, hint=hint, caption=caption, label=None, digits=0)
     52     if r:
     53         newRange = max(minDist, min(maxDist, r['qty']))
     54         defaultRangeUtils.UpdateRangeSetting(key, newRange)
     55 
     56 
     57 def GetKeepAtRangeMenu(itemID, typeID, dist, currentDistance):
     58     keepRangeMenu = _GetRangeMenu(itemID=itemID, typeID=typeID, dist=dist, currentDistance=currentDistance, rangesList=KEEP_AT_RANGE_RANGES, mainFunc=KeepAtRange, setDefaultFunc=defaultRangeUtils.SetDefaultKeepAtRangeDist, atCurrentRangeLabel='UI/Inflight/KeepAtCurrentRange', setDefaultLabel='UI/Inflight/Submenus/SetDefaultWarpRange', referenceString='KeepAtRange')
     59     return keepRangeMenu
     60 
     61 
     62 def GetOrbitMenu(itemID, typeID, dist, currentDistance):
     63     orbitMenu = _GetRangeMenu(itemID=itemID, typeID=typeID, dist=dist, currentDistance=currentDistance, rangesList=ORBIT_RANGES, mainFunc=Orbit, setDefaultFunc=defaultRangeUtils.SetDefaultOrbitDist, atCurrentRangeLabel='UI/Inflight/OrbitAtCurrentRange', setDefaultLabel='UI/Inflight/Submenus/SetDefaultWarpRange', referenceString='Orbit')
     64     return orbitMenu
     65 
     66 
     67 def _GetRangeMenu(itemID, typeID, dist, currentDistance, rangesList, mainFunc, setDefaultFunc, atCurrentRangeLabel, setDefaultLabel, referenceString):
     68     rangeMenu = []
     69     rangeSubMenu = []
     70     for eachRange in rangesList:
     71         fmtRange = FmtDist(eachRange)
     72         fmtRangeNoWhiteSpace = ''.join(fmtRange.split())
     73         optionReferenceString = referenceString + fmtRangeNoWhiteSpace
     74         rangeMenu.append((fmtRange,
     75          mainFunc,
     76          (itemID, eachRange),
     77          None,
     78          None,
     79          optionReferenceString,
     80          typeID))
     81         rangeSubMenu.append((fmtRange, setDefaultFunc, (eachRange,)))
     82 
     83     rangeMenu += [(MenuLabel(atCurrentRangeLabel, {'currentDistance': currentDistance}), mainFunc, (itemID, dist)), None, (MenuLabel(setDefaultLabel), rangeSubMenu)]
     84     return rangeMenu
     85 
     86 
     87 def GetDefaultDist(key, itemID = None, minDist = 500, maxDist = 1000000):
     88     drange = GetMenuService().GetDefaultActionDistance(key)
     89     if drange is None:
     90         dist = ''
     91         if itemID:
     92             bp = sm.StartService('michelle').GetBallpark()
     93             if not bp:
     94                 return
     95             ball = bp.GetBall(itemID)
     96             if not ball:
     97                 return
     98             dist = long(max(minDist, min(maxDist, ball.surfaceDist)))
     99         fromDist = FmtAmt(minDist)
    100         toDist = FmtAmt(maxDist)
    101         if key == 'KeepAtRange':
    102             hint = localization.GetByLabel('UI/Inflight/SetDefaultKeepAtRangeDistanceHint', fromDist=fromDist, toDist=toDist)
    103             caption = localization.GetByLabel('UI/Inflight/SetDefaultKeepAtRangeDistance')
    104         elif key == 'Orbit':
    105             hint = localization.GetByLabel('UI/Inflight/SetDefaultOrbitDistanceHint', fromDist=fromDist, toDist=toDist)
    106             caption = localization.GetByLabel('UI/Inflight/SetDefaultOrbitDistance')
    107         elif key == 'WarpTo':
    108             hint = localization.GetByLabel('UI/Inflight/SetDefaultWarpWithinDistanceHint', fromDist=fromDist, toDist=toDist)
    109             caption = localization.GetByLabel('UI/Inflight/SetDefaultWarpWithinDistance')
    110         else:
    111             hint = ''
    112             caption = ''
    113         r = uix.QtyPopup(maxvalue=maxDist, minvalue=minDist, setvalue=dist, hint=hint, caption=caption, label=None, digits=0)
    114         if r:
    115             newRange = max(minDist, min(maxDist, r['qty']))
    116             defaultRangeUtils.UpdateRangeSetting(key, newRange)
    117         else:
    118             return
    119     return drange
    120 
    121 
    122 def GetSelectedShipAndFighters():
    123     selectedFighterIDs = GetFightersSelectedForNavigation()
    124     shipIsSelected = len(selectedFighterIDs) == 0 or IsSelectedForNavigation(session.shipid)
    125     return (shipIsSelected, selectedFighterIDs)
    126 
    127 
    128 def GetFightersSelectedForNavigation():
    129     if not CheckShipHasFighterBay(session.shipid):
    130         return []
    131     selectedItemIDs = sm.GetService('stateSvc').GetStatesForFlag(states.selectedForNavigation)
    132     fighterIDsInSpace = sm.GetService('fighters').shipFighterState.GetAllFighterIDsInSpace()
    133     return [ fighterItemID for fighterItemID in fighterIDsInSpace if fighterItemID in selectedItemIDs ]
    134 
    135 
    136 def IsSelectedForNavigation(itemID):
    137     return sm.GetService('stateSvc').GetState(itemID, states.selectedForNavigation)
    138 
    139 
    140 def SelectForNavigation(itemID):
    141     if not CheckShipHasFighterBay(session.shipid):
    142         return
    143     sm.GetService('stateSvc').SetState(itemID, states.selectedForNavigation, True)
    144 
    145 
    146 def DeselectForNavigation(itemID):
    147     sm.GetService('stateSvc').SetState(itemID, states.selectedForNavigation, False)
    148 
    149 
    150 def ToggleSelectForNavigation(itemID):
    151     if IsSelectedForNavigation(itemID):
    152         DeselectForNavigation(itemID)
    153     else:
    154         SelectForNavigation(itemID)
    155 
    156 
    157 def DeselectAllForNavigation():
    158     sm.GetService('stateSvc').ResetByFlag(states.selectedForNavigation)
    159 
    160 
    161 def GetSelectedFightersByTubeIDs():
    162     selectedItemIDs = sm.GetService('stateSvc').GetStatesForFlag(states.selectedForNavigation)
    163     if not selectedItemIDs:
    164         return {}
    165     shipFighterState = sm.GetService('fighters').shipFighterState
    166     fighterIDsByTubeID = {}
    167     allFighters = shipFighterState.GetAllFighters()
    168     for eachFighter in allFighters:
    169         if eachFighter and eachFighter.itemID in selectedItemIDs:
    170             fighterIDsByTubeID[eachFighter.tubeFlagID] = eachFighter.itemID
    171 
    172     return fighterIDsByTubeID
    173 
    174 
    175 def IsApproachingBall(targetBallID):
    176     ball = sm.GetService('michelle').GetBall(session.shipid)
    177     if ball is None:
    178         return False
    179     return ball.mode == destiny.DSTBALL_FOLLOW and ball.followId == targetBallID
    180 
    181 
    182 def _IsAlreadyFollowingBallAtRange(ballID, targetID, targetRange, moveMode = destiny.DSTBALL_FOLLOW):
    183     ball = sm.GetService('michelle').GetBall(ballID)
    184     if ball is None:
    185         return
    186     return ball.mode == moveMode and ball.followId == targetID and ball.followRange == targetRange
    187 
    188 
    189 def _GetMovementDistanceOrDefault(targetID, targetRange, action, **kwargs):
    190     if targetRange is None:
    191         return GetDefaultDist(action, targetID, **kwargs)
    192     return targetRange
    193 
    194 
    195 def KeepAtRange(targetID, followRange = None):
    196     if _IsInvalidMovementTarget(targetID):
    197         return
    198     followRange = _GetMovementDistanceOrDefault(targetID, followRange, 'KeepAtRange', minDist=const.approachRange)
    199     if followRange is None:
    200         return
    201     shipIsSelected, selectedFighterIDs = GetSelectedShipAndFighters()
    202     if shipIsSelected:
    203         _Ship_KeepAtRange(targetID, followRange)
    204     if selectedFighterIDs:
    205         sm.GetService('fighters').CmdMovementFollow(selectedFighterIDs, targetID, followRange)
    206 
    207 
    208 def _Ship_KeepAtRange(targetID, followRange):
    209     if IsControllingStructure():
    210         return
    211     if _IsAlreadyFollowingBallAtRange(session.shipid, targetID, followRange):
    212         return
    213     sm.GetService('space').SetIndicationTextInstantly(ballMode=destiny.DSTBALL_FOLLOW, followId=targetID, followRange=int(followRange))
    214     bp = sm.GetService('michelle').GetRemotePark()
    215     bp.CmdFollowBall(targetID, followRange)
    216     sm.GetService('autoPilot').CancelSystemNavigation()
    217     sm.GetService('flightPredictionSvc').OptionActivated('KeepAtRange', targetID, followRange)
    218     sm.GetService('tacticalNavigation').NotifyOfKeepAtRangeCommand(targetID, followRange)
    219 
    220 
    221 def Orbit(targetID, followRange = None):
    222     if _IsInvalidMovementTarget(targetID):
    223         return
    224     followRange = _GetMovementDistanceOrDefault(targetID, followRange, 'Orbit')
    225     if followRange is None:
    226         return
    227     followRange = float(followRange) if followRange < 10.0 else int(followRange)
    228     shipIsSelected, selectedFighterIDs = GetSelectedShipAndFighters()
    229     if shipIsSelected:
    230         _Ship_Orbit(targetID, followRange)
    231     if selectedFighterIDs:
    232         sm.GetService('fighters').CmdMovementOrbit(selectedFighterIDs, targetID, followRange)
    233 
    234 
    235 def _Ship_Orbit(targetID, followRange):
    236     if IsControllingStructure():
    237         return
    238     _ScatterOrbitAchievementEvent(targetID, followRange)
    239     if _IsAlreadyFollowingBallAtRange(session.shipid, targetID, followRange, moveMode=destiny.DSTBALL_ORBIT):
    240         return
    241     sm.GetService('space').SetIndicationTextInstantly(ballMode=destiny.DSTBALL_ORBIT, followId=targetID, followRange=followRange)
    242     bp = sm.GetService('michelle').GetRemotePark()
    243     bp.CmdOrbit(targetID, followRange)
    244     sm.GetService('autoPilot').CancelSystemNavigation()
    245     sm.GetService('flightPredictionSvc').OptionActivated('Orbit', targetID, followRange)
    246 
    247 
    248 def _ScatterOrbitAchievementEvent(targetID, distance):
    249     try:
    250         slimItem = sm.GetService('michelle').GetItem(targetID)
    251         if slimItem:
    252             sm.GetService('tacticalNavigation').NotifyOfOrbitCommand(targetID, distance, slimItem)
    253         else:
    254             log.LogTraceback('Failed at scattering orbit event')
    255     except Exception as e:
    256         log.LogTraceback('Failed at scattering orbit event')
    257 
    258 
    259 def Approach(targetID, cancelAutoNavigation = True):
    260     if _IsInvalidMovementTarget(targetID):
    261         return
    262     shipIsSelected, selectedFighterIDs = GetSelectedShipAndFighters()
    263     if shipIsSelected:
    264         ShipApproach(targetID, cancelAutoNavigation)
    265     if selectedFighterIDs:
    266         sm.GetService('fighters').CmdMovementFollow(selectedFighterIDs, targetID, const.approachRange)
    267 
    268 
    269 def ShipApproach(targetID, cancelAutoNavigation = True):
    270     if IsControllingStructure():
    271         return
    272     autoPilot = sm.GetService('autoPilot')
    273     if cancelAutoNavigation:
    274         autoPilot.CancelSystemNavigation()
    275     approachRange = const.approachRange
    276     if _IsAlreadyFollowingBallAtRange(session.shipid, targetID, approachRange):
    277         return
    278     sm.GetService('space').SetIndicationTextInstantly(ballMode=destiny.DSTBALL_FOLLOW, followId=targetID, followRange=approachRange)
    279     bp = sm.GetService('michelle').GetRemotePark()
    280     sm.GetService('menu').StoreAlignTarget(alignTargetID=targetID, aligningToBookmark=False)
    281     bp.CmdFollowBall(targetID, approachRange)
    282     sm.GetService('flightPredictionSvc').OptionActivated('Approach', targetID, approachRange)
    283     slimItem = sm.GetService('michelle').GetItem(targetID)
    284     sm.GetService('tacticalNavigation').NotifyOfApproachCommand(slimItem)
    285 
    286 
    287 def GoToPoint(position):
    288     bp = sm.GetService('michelle').GetRemotePark()
    289     if bp is not None:
    290         shipIsSelected, selectedFighterIDs = GetSelectedShipAndFighters()
    291         if selectedFighterIDs:
    292             _Fighters_GoToPoint(selectedFighterIDs, position)
    293         if shipIsSelected:
    294             _Ship_GoToPoint(bp, position)
    295 
    296 
    297 def _Ship_GoToPoint(bp, position):
    298     if IsControllingStructure():
    299         return
    300     sm.GetService('autoPilot').CancelSystemNavigation()
    301     bp.CmdGotoPoint(*position)
    302 
    303 
    304 def _Fighters_GoToPoint(fighterIDs, position):
    305     fighterSvc = sm.GetService('fighters')
    306     fighterSvc.CmdGotoPoint(fighterIDs, position)
    307 
    308 
    309 def GetWarpToRanges():
    310     ranges = [const.minWarpEndDistance,
    311      (const.minWarpEndDistance / 10000 + 1) * 10000,
    312      (const.minWarpEndDistance / 10000 + 2) * 10000,
    313      (const.minWarpEndDistance / 10000 + 3) * 10000,
    314      (const.minWarpEndDistance / 10000 + 5) * 10000,
    315      (const.minWarpEndDistance / 10000 + 7) * 10000,
    316      const.maxWarpEndDistance]
    317     return ranges
    318 
    319 
    320 def DockOrJumpOrActivateGate(itemID):
    321     if _IsInvalidMovementTarget(itemID):
    322         return
    323     bp = sm.StartService('michelle').GetBallpark()
    324     menuSvc = GetMenuService()
    325     if bp:
    326         item = bp.GetInvItem(itemID)
    327         if item.groupID == const.groupStation:
    328             menuSvc.DockStation(itemID)
    329         elif item.categoryID == const.categoryStructure:
    330             if IsUpwellStargate(item.typeID):
    331                 menuSvc.JumpThroughStructureJumpBridge(itemID)
    332             else:
    333                 sm.GetService('structureDocking').Dock(itemID)
    334         elif item.groupID == const.groupStargate:
    335             slimItem = bp.slimItems.get(itemID)
    336             if slimItem:
    337                 jump = slimItem.jumps[0]
    338                 if not jump:
    339                     return
    340                 menuSvc.StargateJump(itemID, item.typeID, jump.toCelestialID, jump.locationID)
    341         elif item.typeID in [const.typeNeedlejackTrace, const.typeYoiulTrace, const.typeTriglavianSpaceTrace]:
    342             menuSvc.ActivateRandomJumpTraceGate(itemID)
    343         elif item.typeID == const.typeAbyssEncounterGate:
    344             menuSvc.ActivateAbyssalAccelerationGate(itemID)
    345         elif item.typeID == const.typeAbyssEntranceGate:
    346             menuSvc.ActivateAbyssalEntranceAccelerationGate(itemID)
    347         elif item.typeID == const.typeAbyssExitGate:
    348             menuSvc.ActivateAbyssalEndGate(itemID)
    349         elif item.typeID == const.typeAbyssPvPGate:
    350             menuSvc.ActivatePVPAbyssalEndGate(itemID)
    351         elif item.typeID == const.typeVoidSpaceExitGate:
    352             menuSvc.ActivateVoidSpaceExitGate(itemID)
    353         elif item.groupID == const.groupWarpGate:
    354             menuSvc.ActivateAccelerationGate(itemID)
    355         elif item.groupID == const.groupWormhole:
    356             menuSvc.EnterWormhole(itemID)
    357         elif HasShipcasterComponent(item.typeID):
    358             menuSvc.JumpThroughShipcaster(itemID)
    359         elif HasStarterShipcasterComponent(item.typeID):
    360             menuSvc.JumpThroughStarterShipcaster(itemID)
    361 
    362 
    363 def _IsInvalidMovementTarget(itemID):
    364     if sm.GetService('michelle').GetRemotePark() is None:
    365         return False
    366     return itemID == session.shipid or sm.GetService('sensorSuite').IsSiteBall(itemID)
    367 
    368 
    369 def ApproachLocation(bookmark):
    370     bp = sm.StartService('michelle').GetRemotePark()
    371     if bp:
    372         if getattr(bookmark, 'agentID', 0) and hasattr(bookmark, 'locationNumber'):
    373             referringAgentID = getattr(bookmark, 'referringAgentID', None)
    374             sm.StartService('agents').GetAgentMoniker(bookmark.agentID).GotoLocation(bookmark.locationType, bookmark.locationNumber, referringAgentID)
    375         else:
    376             sm.GetService('menu').StoreAlignTarget(alignTargetID=None, aligningToBookmark=False)
    377             bp.CmdGotoBookmark(bookmark.bookmarkID)
    378             sm.GetService('tacticalNavigation').NotifyOfApproachCommand()
    379 
    380 
    381 def WarpToBookmark(bookmark, warpRange = 20000.0, fleet = False):
    382     michelle = sm.GetService('michelle')
    383     bp = michelle.GetRemotePark()
    384     if bp:
    385         if getattr(bookmark, 'agentID', 0) and hasattr(bookmark, 'locationNumber'):
    386             referringAgentID = getattr(bookmark, 'referringAgentID', None)
    387             sm.StartService('agents').GetAgentMoniker(bookmark.agentID).WarpToLocation(bookmark.locationType, bookmark.locationNumber, warpRange, fleet, referringAgentID, GetFormationSettings())
    388         else:
    389             sm.GetService('autoPilot').CancelSystemNavigation()
    390             michelle.CmdWarpToStuff('bookmark', bookmark.bookmarkID, minRange=warpRange, fleet=fleet)
    391             sm.StartService('space').WarpDestination(bookmarkID=bookmark.bookmarkID)
    392 
    393 
    394 def WarpFleetToBookmark(bookmark, warpRange = 20000.0, fleet = True):
    395     michelle = sm.GetService('michelle')
    396     bp = michelle.GetRemotePark()
    397     if bp:
    398         if getattr(bookmark, 'agentID', 0) and hasattr(bookmark, 'locationNumber'):
    399             referringAgentID = getattr(bookmark, 'referringAgentID', None)
    400             sm.StartService('agents').GetAgentMoniker(bookmark.agentID).WarpToLocation(bookmark.locationType, bookmark.locationNumber, warpRange, fleet, referringAgentID, GetFormationSettings())
    401         else:
    402             sm.GetService('autoPilot').CancelSystemNavigation()
    403             michelle.CmdWarpToStuff('bookmark', bookmark.bookmarkID, minRange=warpRange, fleet=fleet)
    404 
    405 
    406 def WarpToItem(itemID, warpRange = None, cancelAutoNavigation = True, warpSubject = WarpSubjects.ITEM):
    407     if itemID == session.shipid:
    408         return
    409     if warpRange is None:
    410         warpRange = GetMenuService().GetDefaultActionDistance('WarpTo')
    411     siteBracket = sm.GetService('sensorSuite').GetBracketByBallID(itemID)
    412     if siteBracket:
    413         siteBracket.data.WarpToAction(None, warpRange)
    414         return
    415     michelle = sm.GetService('michelle')
    416     bp = michelle.GetRemotePark()
    417     if bp is not None:
    418         if cancelAutoNavigation:
    419             sm.GetService('autoPilot').CancelSystemNavigation()
    420         michelle.CmdWarpToStuff(warpSubject, itemID, minRange=warpRange)
    421         sm.StartService('space').WarpDestination(celestialID=itemID)
    422         sm.GetService('flightPredictionSvc').OptionActivated('AlignTo', itemID)
    423         item = michelle.GetItem(itemID)
    424         if item and item.typeID == const.typeAsteroidBelt:
    425             sm.ScatterEvent('OnWarpToAsteroidBelt')
    426 
    427 
    428 def WarpToOperationSite(siteID):
    429     sm.ScatterEvent('OnOperationSiteWarpToExecuted', siteID)
    430     sm.GetService('michelle').CmdWarpToStuff(WarpSubjects.OPERATION_DUNGEON, siteID)
    431 
    432 
    433 def CanWarpToOperationSite(siteID):
    434     sm.GetService('michelle').CanWarpToOperationSite(siteID)
    435 
    436 
    437 def WarpToMiningPointPoint(moonID, warpRange = None):
    438     _WarpToMoonMiningPoint(moonID, warpRange)
    439 
    440 
    441 def WarpFleetToMiningPointPoint(moonID, warpRange = None):
    442     _WarpToMoonMiningPoint(moonID, warpRange, fleet=True)
    443 
    444 
    445 def _WarpToMoonMiningPoint(moonID, warpRange = None, fleet = False):
    446     if warpRange is None:
    447         warpRange = GetMenuService().GetDefaultActionDistance('WarpTo')
    448     michelle = sm.GetService('michelle')
    449     bp = michelle.GetRemotePark()
    450     if bp is not None:
    451         sm.GetService('autoPilot').CancelSystemNavigation()
    452         michelle.CmdWarpToStuff(WarpSubjects.MOON_MINING_POINT, moonID, minRange=warpRange, fleet=fleet)
    453         sm.StartService('space').WarpDestination(celestialID=moonID)
    454         sm.GetService('flightPredictionSvc').OptionActivated('AlignTo', moonID)
    455 
    456 
    457 def GetFormationSettings():
    458     skillSvc = sm.GetService('skills')
    459     formationSettings = {'formationType': GetFormationSelected(skillSvc.MySkillLevel(FORMATION_SKILL)),
    460      'formationSpacing': GetFormationSpacingSelected(skillSvc.MySkillLevel(FORMATION_DISTANCE_SKILL)),
    461      'formationSize': GetFormationSizeSelected(skillSvc.MySkillLevel(FORMATION_DISTANCE_SKILL))}
    462     return formationSettings
    463 
    464 
    465 def RealDock(itemID):
    466     bp = sm.StartService('michelle').GetBallpark()
    467     if not bp:
    468         return
    469     if sm.GetService('viewState').HasActiveTransition():
    470         return
    471     prompt_player_fsd_dialog('OnDockingRequest')
    472     bp = sm.GetService('michelle').GetRemotePark()
    473     if bp is not None:
    474         log.LogNotice('Docking', itemID)
    475         if uicore.uilib.Key(uiconst.VK_CONTROL) and uicore.uilib.Key(uiconst.VK_SHIFT) and uicore.uilib.Key(uiconst.VK_MENU) and session.role & ROLE_GML:
    476             sm.GetService('sessionMgr').PerformSessionChange('dock', bp.CmdTurboDock, itemID)
    477         else:
    478             sm.GetService('sessionMgr').PerformSessionChange('dock', bp.CmdDock, itemID, session.shipid)
    479 
    480 
    481 def RealActivateRandomFilamentGate(itemID):
    482     remoteBallpark = sm.GetService('michelle').GetRemotePark()
    483     try:
    484         remoteBallpark.CallComponentFromClient(itemID, FILAMENT_SPOOLUP, 'JumpThroughRandomFilamentGate')
    485     except UserError as e:
    486         if e.msg == 'RandomJumpError':
    487             textList = []
    488             for errorLine in e.dict['errors']:
    489                 errorCode, errorArgs = errorLine
    490                 text = get_error_label(localization.GetByLabel, errorCode, *errorArgs)
    491                 textList.append(text)
    492 
    493             if textList:
    494                 text = '<br>'.join(textList)
    495                 message_player(text)
    496                 return
    497         raise
    498 
    499 
    500 def RealActivateAccelerationGate(itemID):
    501     crimewatchSvc = sm.GetService('crimewatchSvc')
    502     requiredSafetyLevel, errorMessage, confirmationMessage = crimewatchSvc.GetRequiredSafetyLevelForActivatingAccelerationGate(itemID)
    503     considerSvc = sm.GetService('consider')
    504     if not considerSvc.SafetyCheckPasses(requiredSafetyLevel):
    505         raise UserError(errorMessage)
    506     if confirmationMessage:
    507         userPromptResult = prompt_player_fsd_dialog(confirmationMessage, buttons=uiconst.YESNO)
    508         if userPromptResult != uiconst.ID_YES:
    509             return
    510     try:
    511         sm.StartService('sessionMgr').PerformSessionChange(localization.GetByLabel('UI/Inflight/ActivateGate'), sm.RemoteSvc('keeper').ActivateAccelerationGate, itemID, violateSafetyTimer=1)
    512     except UserError as e:
    513         if e.msg in ('DunShipCannotWarp', 'DunBlacklistCannotWarp'):
    514             dungeonID = sm.GetService('dungeonTracking').GetCurrentDungeonID()
    515             if dungeonID:
    516                 slimItem = sm.StartService('michelle').GetBallpark().GetInvItem(itemID)
    517                 gateID = slimItem.dunObjectID if slimItem else None
    518                 ShipRestrictionsWindow.Open(dungeon_id=dungeonID, gate_id=gateID)
    519                 return
    520         raise
    521 
    522     log.LogNotice('Acceleration Gate activated to ', itemID)
    523 
    524 
    525 def RealActivateAbyssalGate(itemID):
    526     sm.GetService('sessionMgr').PerformSessionChange('abyssToAbyssJump', sm.RemoteSvc('abyssalMgr').AbyssalGateActivation, itemID, violateSafetyTimer=True)
    527 
    528 
    529 def RealActivateEntranceToAbyssalGate(itemID):
    530     sm.GetService('abyss').open_abyss_jump_window(itemID)
    531 
    532 
    533 def RealActivateAbyssalEndGate(itemID):
    534     sm.GetService('sessionMgr').PerformSessionChange('abyssToKnownJump', sm.RemoteSvc('abyssalMgr').AbyssalEndGateActivation, itemID)
    535 
    536 
    537 def RealActivatePVPAbyssalEndGate(itemID):
    538     sm.GetService('sessionMgr').PerformSessionChange('abyssToKnownJump', sm.RemoteSvc('pvpFilamentMgr').AbyssalPVPEndGateActivation, itemID)
    539 
    540 
    541 def RealActivateVoidSpaceExitGate(itemID):
    542     sm.GetService('sessionMgr').PerformSessionChange('voidToKnownJump', sm.RemoteSvc('voidSpaceMgr').VoidSpaceEndGateActivation, itemID)
    543 
    544 
    545 def RealEnterWormhole(itemID):
    546     isHighSec = sm.GetService('securitySvc').is_effective_high_sec_system(session.solarsystemid)
    547     if isHighSec and prompt_player_fsd_dialog('WormholeJumpingFromHiSec', {}, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES:
    548         return
    549     log.LogNotice('Wormhole Jump from', session.solarsystemid2, 'to', itemID)
    550     sm.StartService('sessionMgr').PerformSessionChange(localization.GetByLabel('UI/Inflight/EnterWormhole'), sm.RemoteSvc('wormholeMgr').WormholeJump, itemID)
    551 
    552 
    553 def RealJumpThroughShipcaster(itemID, targetSolarsystemID, targetLandingPadID):
    554     (sm.GetService('shipcaster').JumpThroughShipcaster(itemID, targetSolarsystemID, targetLandingPadID),)
    555 
    556 
    557 def RealJumpThroughStarterShipcaster(itemID):
    558     from safespace.client.exit_dialog_svc import get_safe_space_exit_dialog_service
    559     dialog_service = get_safe_space_exit_dialog_service()
    560     if not dialog_service.should_show_exit_dialog():
    561         if prompt_player_fsd_dialog('ConfirmLeaveStarterSpace', {}, uiconst.OKCANCEL) != uiconst.ID_OK:
    562             return
    563     else:
    564         if dialog_service.prompt_player_to_exit(is_shipcaster_exit=True) != uiconst.ID_YES:
    565             return
    566         dialog_service.set_has_seen_exit_dialog()
    567     sm.GetService('shipcaster').JumpThroughStarterShipcaster(itemID)
    568 
    569 
    570 def GetGlobalActiveItemKeyName(labelPath):
    571     return {'UI/Inflight/OrbitObject': 'Orbit',
    572      'UI/Inflight/Submenus/KeepAtRange': 'KeepAtRange',
    573      'UI/Inflight/WarpToWithinDistance': 'WarpTo',
    574      'UI/Inflight/Submenus/WarpToWithin': 'WarpTo'}.get(labelPath, None)
    575 
    576 
    577 def GetDefaultWarpToLabel():
    578     defaultWarpDist = GetMenuService().GetDefaultActionDistance('WarpTo')
    579     return MenuLabel('UI/Inflight/WarpToWithinDistance', {'distance': FmtDist(float(defaultWarpDist))})
    580 
    581 
    582 def StopMyShip():
    583     uicore.cmd.GetCommandAndExecute('CmdStopShip')
    584 
    585 
    586 def TryStopMyShip():
    587     with ExceptionEater('Failed attempt to stop ship.'):
    588         StopMyShip()