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

directionalScanSvc.py (4373B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\parklife\directionalScanSvc.py
      2 import blue
      3 import geo2
      4 import uthread
      5 from carbon.client.script.environment.AudioUtil import PlaySound
      6 from carbon.common.script.sys.service import Service
      7 from eve.client.script.ui.camera.cameraUtil import GetBallPosition, GetBall
      8 from eve.client.script.ui.inflight.scannerFiles.directionalScanUtil import GetScanAngle, GetScanRangeInMeters
      9 from eve.client.script.ui.shared.mapView.mapViewUtil import SolarSystemPosToMapPos
     10 from eveexceptions import UserError
     11 THROTTLE_TIME = 1500
     12 
     13 class DirectionalScanSvc(Service):
     14     __guid__ = 'svc.directionalScanSvc'
     15     __servicename__ = 'svc.directionalScanSvc'
     16     __displayname__ = 'Directional Scan Service'
     17     __notifyevents__ = []
     18     __dependencies__ = []
     19     __uthreads__ = []
     20 
     21     def Run(self, memStream = None):
     22         Service.Run(self, memStream)
     23         self.isScanning = False
     24         self.hasScanExecutedDuringKeyPress = False
     25 
     26     def GetScanMan(self):
     27         return sm.GetService('scanSvc').GetScanMan()
     28 
     29     def DirectionalScan(self, direction = None, *args):
     30         self.hasScanExecutedDuringKeyPress = True
     31         if self.isScanning:
     32             return
     33         results = []
     34         scanAngle = GetScanAngle()
     35         scanRange = GetScanRangeInMeters()
     36         if not direction:
     37             direction = self.GetScanDirection()
     38         if not direction:
     39             return
     40         sm.ScatterEvent('OnDirectionalScanStarted')
     41         self.isScanning = True
     42         try:
     43             results = self.GetScanMan().ConeScan(scanAngle, scanRange, *direction)
     44             self.PlayResultSound(results)
     45             sm.ScatterEvent('OnDirectionalScanComplete', scanAngle, scanRange, direction, results)
     46         except UserError as e:
     47             raise e
     48         finally:
     49             uthread.new(self.ReportCooldownAfterThrottle)
     50 
     51     def PlayResultSound(self, results):
     52         if results:
     53             PlaySound('msg_newscan_directional_scan_results_play')
     54         else:
     55             PlaySound('msg_newscan_directional_scan_noresults_play')
     56 
     57     def ReportCooldownAfterThrottle(self):
     58         blue.synchro.SleepWallclock(THROTTLE_TIME)
     59         self.isScanning = False
     60         sm.ScatterEvent('OnDirectionalScanCooldown')
     61 
     62     def GetScanDirection(self):
     63         spaceCamera = sm.GetService('sceneManager').GetActiveSpaceCamera()
     64         if not spaceCamera:
     65             return
     66         direction = spaceCamera.GetLookAtDirection()
     67         direction = geo2.Vec3Negate(direction)
     68         return direction
     69 
     70     def IsScanning(self):
     71         return self.isScanning
     72 
     73     def OnCmdDirectionalScanUnload(self, *args):
     74         if not self.hasScanExecutedDuringKeyPress:
     75             self.DirectionalScan()
     76 
     77     def OnCmdDirectionalScanLoad(self):
     78         self.hasScanExecutedDuringKeyPress = False
     79 
     80     def GetSolarSystemView(self):
     81         from eve.client.script.ui.shared.mapView.solarSystemViewPanel import SolarSystemViewPanel
     82         solarSystemView = SolarSystemViewPanel.GetIfOpen()
     83         if solarSystemView and not solarSystemView.destroyed:
     84             return solarSystemView
     85 
     86     def GetDirectionalScanHandler(self):
     87         solarSystemView = self.GetSolarSystemView()
     88         if solarSystemView:
     89             return solarSystemView.GetDirectionalScanHandler()
     90 
     91     def ScanTowardsItem(self, itemID, mapPosition = None):
     92         if self.IsScanning():
     93             return
     94         ball = GetBall(itemID)
     95         if mapPosition:
     96             bp = sm.GetService('michelle').GetBallpark()
     97             egoPos = bp.GetCurrentEgoPos()
     98             egoPos = SolarSystemPosToMapPos(egoPos)
     99             direction = geo2.Vec3Normalize(geo2.Vec3Subtract(egoPos, mapPosition))
    100         elif ball:
    101             pos = GetBallPosition(ball)
    102             direction = geo2.Vec3Normalize(pos)
    103             direction = geo2.Vec3Negate(direction)
    104         else:
    105             direction = None
    106         uthread.new(self.DirectionalScan, geo2.Vec3Negate(direction))
    107         camera = sm.GetService('sceneManager').GetActiveSpaceCamera()
    108         directionalScanHandler = self.GetDirectionalScanHandler()
    109         if direction and directionalScanHandler:
    110             camera.Track(None)
    111             camera.StopUpdateThreads()
    112             directionalScanHandler.SetScanTarget(direction)
    113         else:
    114             camera.Track(itemID)