prefetchSvc.py (2339B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\environment\prefetchSvc.py 2 import inventorycommon.typeHelpers 3 import everesourceprefetch 4 from carbon.common.script.sys.service import Service 5 from fsdBuiltData.common.graphicIDs import GetGraphicFile 6 7 class PrefetchSvc(Service): 8 __guid__ = 'svc.prefetchSvc' 9 __notifyevents__ = ['OnSessionChanged'] 10 11 def _AddGraphicAttribute(self, pla, attr, filesToPrefetch): 12 graphic = GetGraphicFile(getattr(pla, attr)) 13 filesToPrefetch.add(graphic.lower()) 14 15 def GatherFilesForSolarSystem(self, ssid): 16 filesToPrefetch = set() 17 neighborSystemContents = cfg.mapSolarSystemContentCache[ssid] 18 for stargateID, stargateInfo in neighborSystemContents.stargates.iteritems(): 19 graphic = inventorycommon.typeHelpers.GetGraphicFile(stargateInfo.typeID) 20 filesToPrefetch.add(graphic.lower()) 21 22 for planetID, planetInfo in neighborSystemContents.planets.iteritems(): 23 pla = planetInfo.planetAttributes 24 self._AddGraphicAttribute(pla, 'heightMap1', filesToPrefetch) 25 self._AddGraphicAttribute(pla, 'heightMap2', filesToPrefetch) 26 self._AddGraphicAttribute(pla, 'shaderPreset', filesToPrefetch) 27 28 return filesToPrefetch 29 30 def SchedulePrefetchForSystem(self, ssid): 31 key = 'solarsystem_%d_statics' % ssid 32 if not everesourceprefetch.KeyExists(key): 33 filesToPrefetch = self.GatherFilesForSolarSystem(ssid) 34 everesourceprefetch.AddFileset(key, filesToPrefetch) 35 everesourceprefetch.ScheduleFront(key) 36 37 def OnSessionChanged(self, isremote, session, change): 38 if 'stationid' in change: 39 stationId = change['stationid'][1] 40 if stationId: 41 npcStation = cfg.mapSolarSystemContentCache.npcStations.get(stationId, None) 42 if npcStation: 43 self.SchedulePrefetchForSystem(npcStation.solarSystemID) 44 return 45 if 'solarsystemid' not in change: 46 return 47 ssid = change['solarsystemid'][1] 48 if ssid is None: 49 return 50 systemInfo = cfg.mapSystemCache[ssid] 51 for neighbor in systemInfo.neighbours: 52 self.SchedulePrefetchForSystem(neighbor.solarSystemID)