assetSafetySvc.py (3960B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\assets\assetSafetySvc.py 2 from carbon.common.script.sys.service import Service 3 from carbonui import uiconst 4 from eve.common.script.sys.eveCfg import IsControllingStructure 5 from eve.common.script.sys.idCheckers import IsWormholeSystem, IsTriglavianSystem 6 from eveexceptions import UserError 7 from inventorycommon.const import containerGlobal 8 from player_messaging.client.ui_message import prompt_player_fsd_dialog 9 10 class AssetSafetySvc(Service): 11 __guid__ = 'svc.assetSafety' 12 __servicename__ = 'assetSafety' 13 __notifyevents__ = ['OnAssetSafetyCreated', 'OnAssetSafetyDelivered'] 14 __dependencies__ = ['objectCaching'] 15 16 def Run(self, *args): 17 self.wrapNames = {} 18 19 @staticmethod 20 def GetItemsInSafetyForCharacter(): 21 return sm.RemoteSvc('structureAssetSafety').GetItemsInSafetyForCharacter() 22 23 @staticmethod 24 def GetItemsInSafetyForCorp(): 25 return sm.RemoteSvc('structureAssetSafety').GetItemsInSafetyForCorp() 26 27 @staticmethod 28 def MoveItemsInStructureToAssetSafetyForCharacter(solarSystemID, structureID): 29 if IsControllingStructure() and session.shipid == structureID: 30 raise UserError('CannotPutItemsInSafetyWhileControllingStructure') 31 itemsAtStructureExceptCurrentShip = [ item for item in sm.GetService('invCache').GetInventory(containerGlobal).ListStationItems(structureID) if item.itemID != session.shipid ] 32 if 0 < len(itemsAtStructureExceptCurrentShip): 33 if _IsAssetSafetyDisabledInSystem(solarSystemID): 34 label = 'ConfirmAssetEjectionCharacter' 35 else: 36 label = 'ConfirmAssetSafetyCharacter' 37 if prompt_player_fsd_dialog(label, {'structureID': structureID, 38 'solarsystemID': solarSystemID}, uiconst.YESNO) == uiconst.ID_YES: 39 sm.RemoteSvc('structureAssetSafety').MovePersonalAssetsToSafety(solarSystemID, structureID) 40 else: 41 raise UserError('NoItemsToPutInAssetSafety') 42 43 @staticmethod 44 def MoveItemsInStructureToAssetSafetyForCorp(solarSystemID, structureID): 45 if _IsAssetSafetyDisabledInSystem(solarSystemID): 46 label = 'ConfirmAssetEjectionCorp' 47 else: 48 label = 'ConfirmAssetSafetyCorp' 49 if prompt_player_fsd_dialog(label, {'corpName': cfg.eveowners.Get(session.corpid).name, 50 'structureID': structureID, 51 'solarsystemID': solarSystemID}, uiconst.YESNO) == uiconst.ID_YES: 52 sm.RemoteSvc('structureAssetSafety').MoveCorpAssetsToSafety(solarSystemID, structureID) 53 54 def OnAssetSafetyCreated(self, ownerID, solarSystemID, locationID): 55 if ownerID == session.corpid: 56 self.objectCaching.InvalidateCachedMethodCall('corpmgr', 'GetAssetInventoryForLocation', session.corpid, locationID, 'offices') 57 self.objectCaching.InvalidateCachedMethodCall('structureAssetSafety', 'GetItemsInSafetyForCorp') 58 sm.ScatterEvent('OnReloadCorpAssets') 59 60 def OnAssetSafetyDelivered(self, ownerID): 61 if ownerID == session.corpid: 62 self.objectCaching.InvalidateCachedMethodCall('structureAssetSafety', 'GetItemsInSafetyForCorp') 63 sm.ScatterEvent('OnReloadCorpAssets') 64 elif ownerID == session.charid: 65 self.objectCaching.InvalidateCachedMethodCall('structureAssetSafety', 'GetItemsInSafetyForCharacter') 66 67 def GetWrapName(self, wrapID): 68 return self.GetWrapNames([wrapID])[wrapID] 69 70 def GetWrapNames(self, wrapIDs): 71 missing = set(wrapIDs) - set(self.wrapNames.keys()) 72 if missing: 73 self.wrapNames.update(sm.RemoteSvc('structureAssetSafety').GetWrapNames(wrapIDs)) 74 return {wrapID:self.wrapNames.get(wrapID) for wrapID in wrapIDs} 75 76 77 def _IsAssetSafetyDisabledInSystem(solarSystemID): 78 return IsWormholeSystem(solarSystemID) or IsTriglavianSystem(solarSystemID)