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

officeManager.py (5182B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\services\corporation\officeManager.py
      2 import log
      3 from carbon.common.script.net.moniker import Moniker
      4 from carbon.common.script.sys.service import Service
      5 from eve.common.script.sys.idCheckers import IsNPCCorporation
      6 REMOTESVC = 'officeManager'
      7 
      8 class OfficeManager(Service):
      9     __guid__ = 'svc.officeManager'
     10     __servicename__ = 'Office Manager'
     11     __displayname__ = 'Office Manager'
     12     __dependencies__ = []
     13     __notifyevents__ = ['DoSessionChanging', 'OnOfficeRentalChange', 'OnSessionChanged']
     14 
     15     def __init__(self):
     16         super(self.__class__, self).__init__()
     17         self._offices = None
     18         self._corp_offices = None
     19         self._station = None
     20 
     21     @property
     22     def offices(self):
     23         stationID = session.stationid or session.structureid
     24         if not stationID:
     25             return []
     26         if self._offices is None:
     27             self._offices = self.station.GetCorporationsWithOffices()
     28             cfg.eveowners.Prime(self._offices)
     29         return self._offices
     30 
     31     @property
     32     def corp_offices(self):
     33         if self._corp_offices is None:
     34             self._corp_offices = sm.RemoteSvc(REMOTESVC).GetMyCorporationsOffices()
     35             cfg.evelocations.Prime({o.stationID for o in self._corp_offices})
     36         return self._corp_offices
     37 
     38     @property
     39     def station(self):
     40         if self._station is None:
     41             stationID = session.stationid or session.structureid
     42             if stationID:
     43                 self._station = Moniker(REMOTESVC, stationID)
     44                 self._station.SetSessionCheck({'stationid': session.stationid,
     45                  'structureid': session.structureid})
     46                 self._station.isPrimed = False
     47         return self._station
     48 
     49     def DoSessionChanging(self, isRemote, session, change):
     50         if {'stationid', 'structureid'} & set(change):
     51             self._offices = self._station = None
     52 
     53     def OnSessionChanged(self, isRemote, session, change):
     54         if 'corpid' in change:
     55             self._corp_offices = None
     56         if {'stationid', 'structureid'} & set(change):
     57             self._offices = self._station = None
     58 
     59     def OnOfficeRentalChange(self, corporationID, officeID):
     60         log.LogInfo('officeManager::OnOfficeRentalChange', corporationID, officeID, '- clearing station office cache.')
     61         self._offices = None
     62         if corporationID == session.corpid:
     63             log.LogInfo('officeManager::OnOfficeRentalChange', corporationID, officeID, '- clearing corporation office cache.')
     64             self._corp_offices = None
     65         log.LogInfo('officeManager::OnOfficeRentalChange', corporationID, officeID, '- notifying lobby window.')
     66         sm.ScatterEvent('OnOfficeRentalChanged', corporationID, officeID)
     67 
     68     def GetCorporationsWithOffices(self):
     69         return self.offices
     70 
     71     def GetMyCorporationsOffices(self):
     72         return self.corp_offices
     73 
     74     def GetOfficeSolarSystem(self, locationID):
     75         for office in self.corp_offices:
     76             if office.stationID == locationID:
     77                 return office.solarsystemID
     78 
     79     def GetMyCorporationsOffice(self, officeID):
     80         for office in self.GetMyCorporationsOffices():
     81             if office.officeID == officeID:
     82                 return office
     83 
     84     def GetCorpOfficeAtLocation(self, locationID = None):
     85         stationID = locationID or session.stationid or session.structureid
     86         if stationID is None:
     87             return
     88         for office in self.corp_offices:
     89             if office.stationID == stationID:
     90                 if locationID is None and not self.station.isPrimed:
     91                     self.station.isPrimed = True
     92                     self.station.PrimeOfficeItem()
     93                 return office
     94 
     95     def GetPriceQuote(self):
     96         return self.station.GetPriceQuote(session.corpid)
     97 
     98     def RentOffice(self, cost):
     99         self.station.RentOffice(cost)
    100 
    101     def UnrentOffice(self):
    102         sm.GetService('objectCaching').InvalidateCachedMethodCall('corpmgr', 'GetAssetInventoryForLocation', session.corpid, session.stationid or session.structureid, 'offices')
    103         self.station.UnrentOffice()
    104 
    105     def UnrentRemoteOffice(self, stationID):
    106         if stationID in (session.stationid, session.structureid):
    107             self.UnrentOffice()
    108         else:
    109             Moniker(REMOTESVC, stationID).UnrentOffice()
    110 
    111     def GetNumberOfUnrentedOffices(self):
    112         if session.structureid:
    113             return None
    114         return self.station.GetEmptyOfficeCount()
    115 
    116     def HasCorpImpoundedItemsAtStation(self):
    117         if IsNPCCorporation(session.corpid):
    118             return False
    119         if self.GetCorpOfficeAtLocation():
    120             return False
    121         return self.station.HasCorpImpoundedItems()
    122 
    123     def GetImpoundReleasePrice(self):
    124         if not self.HasCorpImpoundedItemsAtStation():
    125             return None
    126         return self.station.GetImpoundReleasePrice()
    127 
    128     def GetItemsFromImpound(self, quotedPrice):
    129         self.station.GetItemsFromImpound(quotedPrice)
    130 
    131     @staticmethod
    132     def TrashImpoundAtStation(stationID):
    133         Moniker(REMOTESVC, stationID).TrashImpoundedOffice()