stargate.py (5411B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\environment\spaceObject\stargate.py 2 import eve.common.lib.appConst as const 3 from eve.client.script.environment.spaceObject.spaceObject import SpaceObject 4 import evegraphics.gateLogoConst as lconst 5 import eve.client.script.ui.control.eveIcon as eveIcon 6 import logging 7 logger = logging.getLogger(__name__) 8 9 class StargateBannerModel(object): 10 11 def __init__(self, destAllianceID, originAllianceID, targetSystemWarningIcon, logoList): 12 self.destAllianceID = destAllianceID 13 self.originAllianceID = originAllianceID 14 self.targetSystemWarningIcon = targetSystemWarningIcon 15 self.logoList = logoList 16 17 18 class Stargate(SpaceObject): 19 20 def __init__(self): 21 SpaceObject.__init__(self) 22 self.lastActivationTime = 0 23 self.activeStateDuration = 15 * const.SEC 24 self.isDeactivationThreadRunning = False 25 self.isActive = False 26 self.deactivationCurve = None 27 self.activationCurve = None 28 self.lightningTransform = None 29 self.arrivalCurve = None 30 self.departureCurve = None 31 self.bannerModel = None 32 33 def _SetupStargateBanners(self): 34 slimItem = self.typeData.get('slimItem') 35 if slimItem is None: 36 return 37 self.bannerModel = StargateBannerModel(destAllianceID=slimItem.destinationSystemOwnerID, originAllianceID=slimItem.originSystemOwnerID, targetSystemWarningIcon=slimItem.destinationSystemWarningIcon, logoList=slimItem.destinationSystemStatusIcons or []) 38 self.SetupStargateBanners(self.bannerModel) 39 40 def SetupStargateBanners(self, bannerModel): 41 model = self.GetModel() 42 if model is None: 43 return 44 45 def _IsPlayerAlliance(allianceID): 46 return allianceID >= lconst.MIN_PLAYER_ALLIANCE_ID 47 48 photoSvc = sm.GetService('photo') 49 iconSize = 128 50 for param in model.externalParameters: 51 if param.name == 'TargetSystemAllianceLogoResPath': 52 targetAllianceLogoPath = lconst.LOGO_BLACK_ICON_PATH 53 if bannerModel.destAllianceID: 54 if _IsPlayerAlliance(bannerModel.destAllianceID): 55 targetAllianceLogoPath = photoSvc.GetAllianceLogo(bannerModel.destAllianceID, iconSize, callback=True) 56 else: 57 targetAllianceLogoPath = eveIcon.LogoIcon.GetFactionIconTexturePath(bannerModel.destAllianceID, isSmall=False) 58 param.SetValue(targetAllianceLogoPath) 59 elif param.name == 'CurrentSystemAllianceLogoResPath': 60 currentAllianceLogoPath = lconst.LOGO_BLACK_ICON_PATH 61 if bannerModel.originAllianceID: 62 if _IsPlayerAlliance(bannerModel.originAllianceID): 63 currentAllianceLogoPath = photoSvc.GetAllianceLogo(bannerModel.originAllianceID, iconSize, callback=True) 64 else: 65 currentAllianceLogoPath = eveIcon.LogoIcon.GetFactionIconTexturePath(bannerModel.originAllianceID, isSmall=False) 66 param.SetValue(currentAllianceLogoPath) 67 elif param.name == 'TargetSystemVerticalBannerResPath': 68 value = lconst.LOGO_BLACK_ICON_PATH 69 if bannerModel.destAllianceID in lconst.FACTION_BANNERS: 70 value = lconst.FACTION_BANNER_DIR + lconst.FACTION_BANNERS[bannerModel.destAllianceID] 71 param.SetValue(value) 72 elif param.name == 'CurrentSystemVerticalBannerResPath': 73 value = lconst.LOGO_BLACK_ICON_PATH 74 if bannerModel.originAllianceID in lconst.FACTION_BANNERS: 75 value = lconst.FACTION_BANNER_DIR + lconst.FACTION_BANNERS[bannerModel.originAllianceID] 76 elif param.name == 'TargetSystemStatusResPath': 77 value = lconst.LOGO_BLACK_ICON_PATH 78 if bannerModel.targetSystemWarningIcon: 79 value = lconst.SYSTEM_STATUS_DIR + bannerModel.targetSystemWarningIcon 80 param.SetValue(value) 81 elif param.name[:-8] == 'TargetSystemInfo': 82 index = int(param.name[-8:-7]) 83 logo_path = lconst.LOGO_BLACK_ICON_PATH 84 logoList = bannerModel.logoList 85 if index < len(logoList) and logoList[index] and logoList[index] > -1: 86 logo_path = lconst.SYSTEM_STATUS_DIR + lconst.SYSTEM_STATUS_ICONS[logoList[index]] 87 param.SetValue(logo_path) 88 89 def OnAllianceLogoReady(self, allianceID, _size): 90 if allianceID and (self.bannerModel.originAllianceID == allianceID or self.bannerModel.destAllianceID == allianceID): 91 self._SetupStargateBanners() 92 93 def OnSlimItemUpdated(self, slimItem): 94 self.typeData['slimItem'] = slimItem 95 self._SetupStargateBanners() 96 self.SetControllerVariablesFromSlimItem(slimItem) 97 98 def LoadModel(self, fileName = None, loadedModel = None, notify = True, addToScene = True): 99 SpaceObject.LoadModel(self, fileName, loadedModel, notify, addToScene) 100 self._SetupStargateBanners() 101 self.SetStaticRotation() 102 sm.ScatterEvent('OnStargateModelLoaded', self) 103 104 def Assemble(self): 105 if hasattr(self.model, 'ChainAnimationEx'): 106 self.model.ChainAnimationEx('NormalLoop', 0, 0, 1.0)