def onEnterWorld(self, prereqs): super(NewYearJukeboxObject, self).onEnterWorld(prereqs) if self.stateMachine: animationLoader = AnimationSequence.Loader(self.stateMachine, self.spaceID) BigWorld.loadResourceListBG( (animationLoader, ), makeCallbackWeak(self.__onAnimatorLoaded)) effectNames = tuple( (effectName for effectName in ('', '') if effectName)) effectList = tuple((AnimationSequence.Loader(effect, self.spaceID) for effect in effectNames)) if effectList: BigWorld.loadResourceListBG( effectList, makeCallbackWeak(self.__onEffectListLoaded, effectNames))
def init(self, dataSection): if not self._initialized: self.__vehicleUpgradeEffect = _VehicleUpgradeEffect(dataSection) self.__kamikazeActivatedEffect = _KamikazeActivatedEffect( dataSection) self.__trapPoint = _BattleRoyaleTrapPointEffect(dataSection) self.__repairPoint = _BattleRoyaleRepairPointEffect(dataSection) self.__botDeliveryEffect = _BattleRoyaleBotDeliveryEffect( dataSection) self.__botDeliveryMarker = _BattleRoyaleBotDeliveryMarkerArea( dataSection) self.__minesEffects = _MinesEffects( plantEffect=_MinesPlantEffect(dataSection), idleEffect=_MinesIdleEffect(dataSection), destroyEffect=_MinesDestroyEffect(dataSection), blowUpEffectName='minesBlowUpEffect') self.__berserkerEffects = _BerserkerEffects( turretEffect=_BerserkerTurretEffect(dataSection), hullEffect=_BerserkerHullEffect(dataSection), transformPath=dataSection.readString('berserkerTransformPath')) prerequisites = set() self.__dropPlane = _createDropPlane(dataSection['dropPlane'], prerequisites) self.__airDrop = _createAirDrop(dataSection['airDrop'], prerequisites) self.__loots = _createLoots(dataSection, dataSection['lootTypes'], prerequisites) BigWorld.loadResourceListBG( list(prerequisites), makeCallbackWeak(self.__onResourcesLoaded)) super(_BattleRoyaleDynObjects, self).init(dataSection)
def __loadVehicleCompound(self, vehicleDescr): vehicleName = vehicleDescr.name layout = self.__layouts.get(vehicleName, self.__layouts['default']) if vehicleName in self.__cachedCompound: _logger.debug('Loaded vehicle compound of "%s" from cache', vehicleName) BigWorld.buildBlueprint(self.__cachedCompound[vehicleName], _BLUEPRINT_BG_TEXTURE, layout.projections) self.__inProgress = None return elif vehicleName in self.__pendingCompound: _logger.debug('Vehicle compound of "%s" is loading at the moment.', vehicleName) return else: _logger.debug('Loading vehicle compound of "%s".', vehicleName) self.__pendingCompound.add(vehicleName) resources = (ma.prepareCompoundAssembler(vehicleDescr, ModelsSetParams( '', 'undamaged', []), BigWorld.camera().spaceID, lodIdx=layout.lodIdx, skipMaterials=True), ) BigWorld.loadResourceListBG( resources, makeCallbackWeak(self.__onResourcesLoaded, vehicleName)) return
def attach(self, componentIdx, stickerModel, isDamaged): if IS_EDITOR: self.__onClanEmblemLoaded(None, None, componentIdx, stickerModel, isDamaged) return elif not self._isValidComponentIdx(componentIdx): return elif not self._data[componentIdx]: return else: if not IS_EDITOR: replayCtrl = BattleReplay.g_replayCtrl if replayCtrl.isPlaying and replayCtrl.isOffline: return serverSettings = self.lobbyContext.getServerSettings() if serverSettings is not None and serverSettings.roaming.isInRoaming(): return accountRep = _getAccountRepository() if not accountRep: LOG_WARNING('Failed to attach clan sticker to the vehicle - account repository is not initialized') return fileCache = accountRep.customFilesCache fileServerSettings = accountRep.fileServerSettings clanEmblems = fileServerSettings.get('clan_emblems') if clanEmblems is None: return try: url = clanEmblems['url_template'] % self._clanId except Exception: LOG_ERROR('Failed to attach stickers to the vehicle - server returned incorrect url format: %s' % clanEmblems['url_template']) return clanCallback = stricted_loading.makeCallbackWeak(self.__onClanEmblemLoaded, componentIdx=componentIdx, stickerModel=weakref.proxy(stickerModel), isDamaged=isDamaged) fileCache.get(url, clanCallback) return
def loadResourceMapping(resourceMapping, callback, *args, **kwargs): resourceLoadingList = [ loader.resourceLoader for loader in resourceMapping.itervalues() ] BigWorld.loadResourceListBG( resourceLoadingList, stricted_loading.makeCallbackWeak(callback, *args, **kwargs))
def onEnterWorld(self, prereqs): _logger.debug('Starting platoon lighting state machine.') if self.animationStateMachine: animationLoader = AnimationSequence.Loader( self.animationStateMachine, self.spaceID) BigWorld.loadResourceListBG( (animationLoader, ), makeCallbackWeak(self.__onAnimatorLoaded)) super(PlatoonLighting, self).onEnterWorld(prereqs)
def __requestModelsRefresh(self): currentModelState = self.__currentDamageState.modelState assembler = model_assembler.prepareCompoundAssembler( self.__typeDesc, currentModelState, self.__vehicle.spaceID, self.__vehicle.isTurretDetached) BigWorld.loadResourceListBG((assembler, ), makeCallbackWeak(self.__onModelsRefresh, currentModelState))
def loadPrerequisites(self): prereqs = [] for visualData in self.__visualisationData.iteritems(): if 'visual' in visualData: prereqs.append(visualData['visual']) BigWorld.loadResourceListBG(prereqs, makeCallbackWeak(self.__onPrereqsLoaded))
def __requestModelsRefresh(self): modelsSetParams = self.modelsSetParams assembler = model_assembler.prepareCompoundAssembler( self.__typeDesc, modelsSetParams, self.__vehicle.spaceID, self.__vehicle.isTurretDetached) BigWorld.loadResourceListBG((assembler, ), makeCallbackWeak(self.__onModelsRefresh, modelsSetParams.state), loadingPriority(self.__vehicle.id))
def showCustomization(self, vehInvID=None, callback=None, season=None, modeId=None, tabId=None): if self.__customizationCtx is None: lobbyHeaderNavigationPossible = yield self.__lobbyContext.isHeaderNavigationPossible( ) if not lobbyHeaderNavigationPossible: return self.__showCustomizationKwargs = { 'vehInvID': vehInvID, 'callback': callback, 'season': season, 'modeId': modeId, 'tabId': tabId } shouldSelectVehicle = False if self.hangarSpace.space is not None: self.hangarSpace.space.turretAndGunAngles.set( gunPitch=self.__GUN_PITCH_ANGLE, turretYaw=self.__TURRET_YAW_ANGLE) if vehInvID is not None: vehGuiItem = self.itemsCache.items.getVehicle(vehInvID) if vehGuiItem is not None: if not vehGuiItem.isCustomizationEnabled(): _logger.error( "Can't show customization view for currently non-customizable vehicle '%s'", vehGuiItem.name) return if g_currentVehicle.invID != vehInvID: shouldSelectVehicle = True if not self.hangarSpace.spaceInited or not self.hangarSpace.isModelLoaded or shouldSelectVehicle: if shouldSelectVehicle: if g_currentPreviewVehicle.isPresent(): hideVehiclePreview(back=False, close=True) g_currentPreviewVehicle.selectNoVehicle() BigWorld.callback( 0.0, makeCallbackWeak(g_currentVehicle.selectVehicle, vehInvID=vehInvID)) _logger.info( 'Space or vehicle is not presented, customization view loading delayed' ) self.hangarSpace.onVehicleChanged += self.__delayedShowCustomization self.hangarSpace.onSpaceChanged += self.__delayedShowCustomization return else: if not shouldSelectVehicle and self.hangarSpace.space is not None: vEntity = self.hangarSpace.space.getVehicleEntity() if vEntity is not None: vEntity.appearance.rotateTurretForAnchor(None, None) vEntity.appearance.rotateGunToDefault() self.__delayedShowCustomization() return
def onEnterWorld(self, prereqs): super(NewYearCelebrityObject, self).onEnterWorld(prereqs) self._nyController.onStateChanged += self.__onStateChanged self.__onStateChanged() if self.stateMachine: animationLoader = AnimationSequence.Loader(self.stateMachine, self.spaceID) BigWorld.loadResourceListBG((animationLoader,), makeCallbackWeak(self.__onAnimatorLoaded, self.stateMachine)) self._celebrityController.addCelebrityEntity(self) if self.selectionGroupIdx: self.entityGameObject.createComponent(HighlightGroupComponent, self.selectionGroupIdx)
def __loadModel(self, trackAssembler): if not IS_EDITOR: BigWorld.loadResourceListBG((trackAssembler, ), makeCallbackWeak(self.__onModelLoaded), loadingPriority(self.__entity.id)) self.__loading = True else: self.__loading = True resourceRefs = BigWorld.loadResourceListFG((trackAssembler, )) self.__onModelLoaded(resourceRefs)
def __init__(self, idx, data): super(AnimationSequenceMarkerComponent, self).__init__(data) animSeqData = data.get(self.maskType)[idx] self.__path = animSeqData.get('path', None) self.__animator = None self.__spaceID = BigWorld.player().spaceID if self.__path is not None: loader = AnimationSequence.Loader(self.__path, self.__spaceID) BigWorld.loadResourceListBG((loader,), makeCallbackWeak(self.__onSequenceLoaded)) return
def __updateSequences(self, outfit): resources = camouflages.getModelAnimatorsPrereqs(outfit, self.__spaceId) resources.extend(camouflages.getAttachmentsAnimatorsPrereqs(self.__attachments, self.__spaceId)) if not resources: self.__clearModelAnimators() if not self.__isVehicleDestroyed: from vehicle_systems import model_assembler model_assembler.assembleCustomLogicComponents(self, self.__vEntity.typeDescriptor, self.__attachments, self.__modelAnimators) return BigWorld.loadResourceListBG(tuple(resources), makeCallbackWeak(self.__onAnimatorsLoaded, self.__curBuildInd, outfit))
def __handlePlaceToyEvent(self, event): self.__clearNodes() modelName = event.ctx['modelName'] effects = _ModelEffects(event.ctx['regularEffectName'], event.ctx['hangingEffectName']) for i in range(self.hardPointCount): BigWorld.loadResourceListBG([modelName], makeCallbackWeak(self.__onModelLoaded, nodeIndex=i + 1, modelName=modelName, effects=effects))
def __startBuild(self, vDesc, vState): self.__curBuildInd += 1 self.__vState = vState self.__resources = {} self.__vehicleStickers = None cfg = hangarCFG() if vState == 'undamaged': self.__currentEmblemsAlpha = cfg['emblems_alpha_undamaged'] self.__isVehicleDestroyed = False else: self.__currentEmblemsAlpha = cfg['emblems_alpha_damaged'] self.__isVehicleDestroyed = True self.__vDesc = vDesc resources = camouflages.getCamoPrereqs(self.__outfit, vDesc) splineDesc = vDesc.chassis.splineDesc if splineDesc is not None: resources.append(splineDesc.segmentModelLeft) resources.append(splineDesc.segmentModelRight) if splineDesc.leftDesc is not None: resources.append(splineDesc.leftDesc) if splineDesc.rightDesc is not None: resources.append(splineDesc.rightDesc) if splineDesc.segment2ModelLeft is not None: resources.append(splineDesc.segment2ModelLeft) if splineDesc.segment2ModelRight is not None: resources.append(splineDesc.segment2ModelRight) from vehicle_systems import model_assembler resources.append(model_assembler.prepareCompoundAssembler(self.__vDesc, ModelsSetParams(self.__outfit.modelsSet, self.__vState), self.__spaceId)) g_eventBus.handleEvent(CameraRelatedEvents(CameraRelatedEvents.VEHICLE_LOADING, ctx={'started': True, 'vEntityId': self.__vEntity.id}), scope=EVENT_BUS_SCOPE.DEFAULT) cfg = hangarCFG() gunScale = Math.Vector3(1.0, 1.0, 1.1) capsuleScale = Math.Vector3(1.5, 1.5, 1.5) loadedGunScale = cfg.get('cam_capsule_gun_scale', gunScale) if loadedGunScale is not None: gunScale = loadedGunScale loadedCapsuleScale = cfg.get('cam_capsule_scale', capsuleScale) if loadedCapsuleScale is not None: capsuleScale = loadedCapsuleScale bspModels = ((TankPartNames.getIdx(TankPartNames.CHASSIS), vDesc.chassis.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.HULL), vDesc.hull.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.TURRET), vDesc.turret.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.GUN), vDesc.gun.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.GUN) + 1, vDesc.hull.hitTester.bspModelName, capsuleScale), (TankPartNames.getIdx(TankPartNames.GUN) + 2, vDesc.turret.hitTester.bspModelName, capsuleScale), (TankPartNames.getIdx(TankPartNames.GUN) + 3, vDesc.gun.hitTester.bspModelName, gunScale)) collisionAssembler = BigWorld.CollisionAssembler(bspModels, self.__spaceId) resources.append(collisionAssembler) physicalTracksBuilders = vDesc.chassis.physicalTracks for name, builder in physicalTracksBuilders.iteritems(): resources.append(builder.createLoader('{0}PhysicalTrack'.format(name))) BigWorld.loadResourceListBG(tuple(resources), makeCallbackWeak(self.__onResourcesLoaded, self.__curBuildInd)) return
def loadComponentSystem(componentSystem, callback, resourceMapping=None): componentSystem = weakref.ref(componentSystem) resourceLoadingList = [ loader.resourceLoader for loader in resourceMapping.itervalues() ] wrappedCallback = None if callback is None else stricted_loading.makeCallbackWeak( callback) loadingCallback = functools.partial(_processLoadedList, componentSystem, wrappedCallback, resourceMapping) BigWorld.loadResourceListBG(resourceLoadingList, loadingCallback) return
def __createDeliveryEffect(self, config): effect = self.__getEffect(config.getBotDeliveryEffect()) if effect is not None: effectPath = effect.path BigWorld.loadResourceListBG( (AnimationSequence.Loader(effectPath, self.__spaceID), ), makeCallbackWeak(self.__onDeliverEffectLoaded, effectPath, self.__deliveryPosition)) return else: return
def _populate(self): super(MapsTrainingBattleGoals, self)._populate() self.sessionProvider.addArenaCtrl(self) ctrl = self.sessionProvider.shared.feedback if ctrl is not None: ctrl.destroyGoal += self._destroyGoal if self.sessionProvider.shared.arenaPeriod.getPeriod() != ARENA_PERIOD.BATTLE: self.as_setVisibleS(False) g_playerEvents.onArenaPeriodChange += self._onArenaPeriodChange g_playerEvents.onRoundFinished += self.__onRoundFinished self.mapsTrainingController.requestInitialDataFromServer(makeCallbackWeak(self._setGoals)) return
def __updateSequences(self, outfit): resources = camouflages.getModelAnimatorsPrereqs( outfit, self.__spaceId) resources.extend( camouflages.getAttachmentsAnimatorsPrereqs(self.__attachments, self.__spaceId)) if not resources: self.__clearModelAnimators() return BigWorld.loadResourceListBG( tuple(resources), makeCallbackWeak(self.__onAnimatorsLoaded, self.__curBuildInd, outfit))
def __requestModelsRefresh(self): self._onRequestModelsRefresh() self._isTurretDetached = self._vehicle.isTurretDetached modelsSetParams = self.modelsSetParams assembler = model_assembler.prepareCompoundAssembler( self.typeDescriptor, modelsSetParams, self.spaceID, self.isTurretDetached) collisionAssembler = model_assembler.prepareCollisionAssembler( self.typeDescriptor, self.isTurretDetached, self.spaceID) BigWorld.loadResourceListBG((assembler, collisionAssembler), makeCallbackWeak(self.__onModelsRefresh, modelsSetParams.state), loadingPriority(self._vehicle.id))
def attachStickers(self, model, parentNode, isDamaged, toPartRootMatrix=None): self.detachStickers() self.__model = model if toPartRootMatrix is not None: self.__toPartRootMatrix = toPartRootMatrix self.__parentNode = parentNode self.__isDamaged = isDamaged self.__stickerModel.setupSuperModel(self.__model, self.__toPartRootMatrix) self.__parentNode.attach(self.__stickerModel) replayCtrl = BattleReplay.g_replayCtrl for slotType, slots in self.__slotsByType.iteritems(): if slotType != SlotTypes.CLAN or self.__clanID == 0 or replayCtrl.isPlaying and replayCtrl.isOffline: if slotType != SlotTypes.CLAN: self.__doAttachStickers(slotType) elif slotType == SlotTypes.CLAN: serverSettings = self.lobbyContext.getServerSettings() if serverSettings is not None and serverSettings.roaming.isInRoaming( ) or self.__isLoadingClanEmblems: continue self.__isLoadingClanEmblems = True accountRep = Account.g_accountRepository if accountRep is None: LOG_ERROR( 'Failed to attach stickers to the vehicle - account repository is not initialized' ) continue fileCache = accountRep.customFilesCache fileServerSettings = accountRep.fileServerSettings clan_emblems = fileServerSettings.get('clan_emblems') if clan_emblems is None: continue url = None try: url = clan_emblems['url_template'] % self.__clanID except: LOG_ERROR( 'Failed to attach stickers to the vehicle - server returned incorrect url format: %s' % clan_emblems['url_template']) continue clanCallback = stricted_loading.makeCallbackWeak( self.__onClanEmblemLoaded) fileCache.get(url, clanCallback) return
def __createMarkerArea(self, config, equipmentDescr): markerArea = CGF.GameObject(self.__spaceID) effect3D = self.__getEffect(config.getBotDeliveryMarker()) if effect3D is not None: effectPath = effect3D.path markerTerrainPosition = self.__deliveryPosition - equipmentDescr.botSpawnPointOffset BigWorld.loadResourceListBG( (AnimationSequence.Loader(effectPath, self.__spaceID), ), makeCallbackWeak(self.__on3dEffectLoaded, equipmentDescr, effectPath, markerTerrainPosition)) return markerArea else: _logger.error('Marker Effect is not defined!') return
def __init__(self): BigWorld.UserDataObject.__init__(self) self.__prevTime = BigWorld.time() self.__angularVelocity = 2 * math.pi / self.rotationPeriod if not self.rotateClockwise: self.__angularVelocity *= -1 self.__currentAngle = 0.0 self.__updateCallbackId = None self.__model = None self.__modelMatrix = None self.__sound = None self.__animator = None BigWorld.loadResourceListBG((self.modelName, self.pixieName), makeCallbackWeak(self.__onResourcesLoaded)) return
def __onArenaVehicleKilled(self, victimID, attackerID, equipmentID, reason, numVehiclesAffected): for targetID, model in self._entries.iteritems(): if victimID == model.getOwnVehicleID( ) and targetID not in self.__callbacksIDs: model.setAlive(False) if GUI_SETTINGS.showMinimapDeath and not GUI_SETTINGS.permanentMinimapDeath: self._invoke(model.getID(), 'setDead', False) self.__callbacksIDs[targetID] = BigWorld.callback( _MINIMAP_ENTRY_DEAD_TIME, makeCallbackWeak( self.__removeSpottedVehicleStaticMarker, targetID)) else: self.__removeSpottedVehicleStaticMarker(targetID) break
def __createDeliveryEffect(self, config): effectAnimation = Svarog.GameObject(self.__spaceID) effectDescr = config.getBotDeliveryEffect() effect = effectDescr.enemy if self.__teamID != BigWorld.player( ).team else effectDescr.ally if effect is not None: effectPath = effect.path BigWorld.loadResourceListBG( (AnimationSequence.Loader(effectPath, self.__spaceID), ), makeCallbackWeak(self.__onDeliverEffectLoaded, effectAnimation, effectPath, self.__deliveryPosition)) return else: _logger.error('Delivery Effect is not defined!') return
def _start(self, data, args): data['bindNodeRef'] = data['entity'].model.node(self._bindNode) if data['bindNodeRef'] is not None: data['beamMP'] = LaserSightMatrixProvider() data['beamMP'].beamMatrix = data['bindNodeRef'] data['beamModelRef'] = BigWorld.Model('') data['beamModelRef'].addMotor(BigWorld.Servo(data['beamMP'].beamMatrix)) player = BigWorld.player() player.addModel(data['beamModelRef']) for beamSeq in self._beamSeqs.itervalues(): loader = AnimationSequence.Loader(beamSeq, player.spaceID) data['animatorRefs'][beamSeq] = loader.loadSync() BigWorld.loadResourceListBG((loader,), makeCallbackWeak(self.__onSequenceLoaded, beamSeq, data)) return
def __init__(self, data, position): super(_StaticObjectMarker3D, self).__init__() self.__path = data.get('path') offset = data.get('offset', Math.Vector3(0, 0, 0)) self.__model = None self.__isMarkerVisible = True self.__action = data.get('action') self.__animator = None self.__modelOwner = None self.__destroyed = False if self.__path is not None: modelPosition = Math.Vector3(position[:]) + offset BigWorld.loadResourceListBG( (self.__path, ), makeCallbackWeak(self.__onModelLoaded, modelPosition)) return
def onSpaceLoaded(self): self.__spaceLoaded = True if _ENABLE_PRECACHE: self.__precacheVehicle(self.__arena.vehicles) if self.__arena.guiType == ARENA_GUI_TYPE.BATTLE_ROYALE: brprereqs = set() cachedDescs = set() for veh in self.__arena.vehicles.values(): vDesc = veh['vehicleType'] if vDesc.name in cachedDescs: continue cachedDescs.add(vDesc.name) brprereqs.update(self.__getWholeVehModels(vDesc)) BigWorld.loadResourceListBG( list(brprereqs), makeCallbackWeak(_wholeVehicleResourcesLoaded, brprereqs))
def _loadSkyBoxes(self, callback=None, immediate=False): if self.loaded: if callback: callback() elif not immediate: BigWorld.loadResourceListBG( self.skyBoxes, makeCallbackWeak(self._onLoadSkyBoxes, callback)) else: resourceRefs = {} for i in self.skyBoxes: try: resourceRefs[i] = BigWorld.Model(i) except ValueError: resourceRefs[i] = BigWorld.Model('') self._onLoadSkyBoxes(callback, resourceRefs)
def attachStickers(self, model, parentNode, isDamaged, toPartRootMatrix = None): self.detachStickers() self.__model = model if toPartRootMatrix is not None: self.__toPartRootMatrix = toPartRootMatrix self.__parentNode = parentNode self.__isDamaged = isDamaged self.__stickerModel.setupSuperModel(self.__model, self.__toPartRootMatrix) self.__parentNode.attach(self.__stickerModel) replayCtrl = BattleReplay.g_replayCtrl for slotType, slots in self.__slotsByType.iteritems(): if slotType != SlotTypes.CLAN or self.__clanID == 0 or replayCtrl.isPlaying and replayCtrl.isOffline: if slotType != SlotTypes.CLAN: self.__doAttachStickers(slotType) elif slotType == SlotTypes.CLAN: serverSettings = g_lobbyContext.getServerSettings() if serverSettings is not None and serverSettings.roaming.isInRoaming() or self.__isLoadingClanEmblems: continue self.__isLoadingClanEmblems = True accountRep = Account.g_accountRepository if accountRep is None: LOG_ERROR('Failed to attach stickers to the vehicle - account repository is not initialized') continue fileCache = accountRep.customFilesCache fileServerSettings = accountRep.fileServerSettings clan_emblems = fileServerSettings.get('clan_emblems') if clan_emblems is None: continue url = None try: url = clan_emblems['url_template'] % self.__clanID except: LOG_ERROR('Failed to attach stickers to the vehicle - server returned incorrect url format: %s' % clan_emblems['url_template']) continue clanCallback = stricted_loading.makeCallbackWeak(self.__onClanEmblemLoaded) fileCache.get(url, clanCallback) return