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

clientDogmaIM.py (3272B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\dogma\clientDogmaIM.py
      2 from __future__ import absolute_import
      3 import uthread
      4 from carbon.common.script.sys.service import Service
      5 from .clientDogmaLocation import DogmaLocation
      6 from carbon.common.lib.const import ixLocationID
      7 
      8 class ClientDogmaInstanceManager(Service):
      9     __guid__ = 'svc.clientDogmaIM'
     10     __startupdependencies__ = ['clientEffectCompiler',
     11      'invCache',
     12      'godma',
     13      'michelle']
     14     __notifyevents__ = ['ProcessSessionChange', 'OnSessionReset']
     15 
     16     def Run(self, *args):
     17         Service.Run(self, *args)
     18         self.dogmaLocation = None
     19         self.fittingDogmaLocation = None
     20 
     21     def GetDogmaLocation(self, charBrain = None, *args):
     22         uthread.Lock('GetDogmaLocation')
     23         try:
     24             if self.dogmaLocation is None:
     25                 self.dogmaLocation = DogmaLocation(self, charBrain)
     26                 self.LogInfo('Created client dogmaLocation', id(self.dogmaLocation))
     27         finally:
     28             uthread.UnLock('GetDogmaLocation')
     29 
     30         return self.dogmaLocation
     31 
     32     def GetFittingDogmaLocation(self, force = False, *args):
     33         uthread.Lock('GetFittingDogmaLocation')
     34         try:
     35             if self.fittingDogmaLocation is None or force:
     36                 from eve.client.script.ui.shared.fittingScreen.fittingDogmaLocation import FittingDogmaLocation
     37                 charBrain = self._GetBrainForGhostFitting()
     38                 self.fittingDogmaLocation = FittingDogmaLocation(self, charBrain=charBrain)
     39                 self.LogInfo('Created client fittingDogmaLocation', id(self.fittingDogmaLocation))
     40         finally:
     41             uthread.UnLock('GetFittingDogmaLocation')
     42 
     43         return self.fittingDogmaLocation
     44 
     45     def _GetBrainForGhostFitting(self):
     46         if self.dogmaLocation:
     47             return self.dogmaLocation.GetBrainData(session.charid)
     48         dogmaLM = sm.GetService('godma').GetDogmaLM()
     49         allInfo = dogmaLM.GetAllInfo(session.charid, None, None)
     50         charBrain = allInfo.charInfo or ()
     51         return charBrain
     52 
     53     def GodmaItemChanged(self, item, change, location):
     54         if item.itemID == session.charid:
     55             return
     56         if self.dogmaLocation is not None:
     57             shipID = self.dogmaLocation.GetCurrentShipID()
     58             if item.locationID == shipID:
     59                 self.dogmaLocation.OnItemChange(item, change, location)
     60             elif change.get(ixLocationID, None) == shipID:
     61                 self.dogmaLocation.OnItemChange(item, change, location)
     62 
     63     def ProcessSessionChange(self, isRemote, session, change):
     64         if self.dogmaLocation is None:
     65             return
     66         if 'stationid' in change or 'solarsystemid' in change:
     67             self.dogmaLocation.UpdateRemoteDogmaLocation()
     68 
     69     def OnSessionReset(self):
     70         self.dogmaLocation = None
     71         if self.fittingDogmaLocation:
     72             sm.UnregisterNotify(self.fittingDogmaLocation)
     73             self.fittingDogmaLocation = None
     74 
     75     def GetCapacityForItem(self, itemID, attributeID):
     76         if self.dogmaLocation is None:
     77             return
     78         if not self.dogmaLocation.IsItemLoaded(itemID):
     79             return
     80         return self.dogmaLocation.GetAttributeValue(itemID, attributeID)