def delayCallback(self, seconds, func, *args, **kwargs): curId = self.__callbacks.get(func) if curId is not None: BigWorld.cancelCallback(curId) del self.__callbacks[func] curId = BigWorld.callback(seconds, functools.partial(self.__funcWrapper, func, *args, **kwargs)) self.__callbacks[func] = curId
def destroy(self): BigWorld.player().arena.onPeriodChange -= self.__arenaPeriodChanged if self.__startEngineCbk is not None: BigWorld.cancelCallback(self.__startEngineCbk) self._vehicle = None self._gearUpCbk = None return
def resetAll(): global isReset try: if eAP.armorCallBack is not None: BigWorld.cancelCallback(eAP.armorCallBack) except Exception: pass if not isReset: utills.eDebug("Resetting AP") eAP.front__visible = True eAP.front_sqrt_xscale = 1.0 eAP.front_txt_alpha = 100 eAP.front_txt_x = 0.0 eAP.front_x = 0.0 eAP.side_sqrt_xscale = 0.0 eAP.side_txt_alpha = 100 eAP.side_txt_x = 0.0 eAP.side_x = 0.0 eAP.armorCallBack = None ME_Tank.callbackID = None ME_Tank.effFrontArmor = None ME_Tank.effSideArmor = None ME_Tank.front = None ME_Tank.leftArc = None ME_Tank.player = None ME_Tank.playerVehicle = None ME_Tank.playerVehicleID = None ME_Tank.rightArc = None ME_Tank.side = None ME_Tank.tankType = "Tank" ME_Tank.hullHeight = None AnglePanel.enable = False isReset = True
def _dispose(self): if self.__updateVehiclesTimerId is not None: BigWorld.cancelCallback(self.__updateVehiclesTimerId) self.__updateVehiclesTimerId = None g_gameCtrl.rentals.onRentChangeNotify -= self._updateRent g_gameCtrl.igr.onIgrTypeChanged -= self._updateIgrType super(TankCarousel, self)._dispose()
def _clearWaiters(self): if self._waiters is not None: while len(self._waiters): _, callbackID = self._waiters.popitem() BigWorld.cancelCallback(callbackID) return
def _callbackWrapper(self, requestType, callback, cooldown, *args): callbackID = self._waiters.pop(requestType, None) if callbackID is not None: BigWorld.cancelCallback(callbackID) self._cooldown.adjust(requestType, cooldown) callback(*args) return
def clear(self): if self.__timerCallback is not None: BigWorld.cancelCallback(self.__timerCallback) self.__timerCallback = None self.isSubscribed = False self.isRunning = False return
def __delRepairMarker(self, repairID): handle, callbackID, _, _ = self.__markers.pop(repairID, (None, None, None, None)) if handle is not None: self._parentObj.destroyStaticMarker(handle) if callbackID is not None: BigWorld.cancelCallback(callbackID) return
def destroy(self): self.stop() self.onCommandReceived.clear() self.onCommandReceived = None self.onAmmoSettingChanged.clear() self.onAmmoSettingChanged = None g_playerEvents.onBattleResultsReceived -= self.__onBattleResultsReceived g_playerEvents.onAccountBecomePlayer -= self.__onAccountBecomePlayer g_playerEvents.onArenaPeriodChange -= self.__onArenaPeriodChange from account_helpers.settings_core.SettingsCore import g_settingsCore g_settingsCore.onSettingsChanged -= self.__onSettingsChanging self.enableAutoRecordingBattles(False) self.__replayCtrl.replayFinishedCallback = None self.__replayCtrl.controlModeChangedCallback = None self.__replayCtrl.clientVersionDiffersCallback = None self.__replayCtrl.playerVehicleIDChangedCallback = None self.__replayCtrl.battleChatMessageCallback = None self.__replayCtrl.ammoButtonPressedCallback = None self.__replayCtrl.lockTargetCallback = None self.__replayCtrl.cruiseModeCallback = None self.__replayCtrl.equipmentIdCallback = None self.__replayCtrl = None self.__settings = None self.__videoCameraMatrix = None self.__warpTime = -1.0 self.__arenaPeriod = -1 if self.__timeWarpCleanupCb is not None: BigWorld.cancelCallback(self.__timeWarpCleanupCb) self.__timeWarpCleanupCb = None return
def stop(self, finished = False, reason = TUTORIAL_STOP_REASON.DEFAULT): if self._tutorialStopped: return else: if self.__callbackID is not None: BigWorld.cancelCallback(self.__callbackID) self.__callbackID = None if self._funcScene is not None: self._funcScene.leave() if self._data is not None: self._data.clear() GlobalStorage.clearFlags() if self._sound is not None: self._sound.stop() self._sound = None if self._gui is not None: self._gui.fini(isItemsRevert=self._descriptor.isItemsRevertIfStop(reason)) self._gui = None if finished: self._cache.setFinished(True).write() else: self._cache.update(self._currentChapter, self._flags.getDict() if self._flags else None) self._cache = None g_tutorialWeaver.clear() clearTutorialProxy() self.removeEffectsInQueue() self._nextChapter = False self._tutorialStopped = True self._initialized = 0 return
def onLoadedCallback(self, pixie, effectID, clone): if self.__node.isDangling: return False elif not self.__activated: return False effectDesc = self.__effects[effectID] prevPixie = effectDesc[PixieNode._PIXIE_REF] if prevPixie is not None: self.__detach(effectDesc) if effectDesc[PixieNode._PIXIE_TTL] > 0.0: ttlCbk = self.__ttlCallbacks.get(effectID, None) if ttlCbk is not None: BigWorld.cancelCallback(ttlCbk) if clone: pixie = pixie.clone() self.__attachTTL(effectDesc, effectID, pixie) return True elif effectDesc[PixieNode._PIXIE_ENABLED]: if clone: pixie = pixie.clone() effectDesc[PixieNode._PIXIE_REF] = pixie self.__attach(pixie) return True else: return False
def __destroy(self): LOG_DEBUG('Hangar successfully destroyed.') MusicController.g_musicController.unloadCustomSounds() if self.__cam == BigWorld.camera(): self.__cam.spaceID = 0 BigWorld.camera(None) BigWorld.worldDrawEnabled(False) self.__cam = None self.__loadingStatus = 0.0 if self.__vAppearance is not None: self.__vAppearance.destroy() self.__vAppearance = None self.__onLoadedCallback = None self.__boundingRadius = None if self.__waitCallback is not None: BigWorld.cancelCallback(self.__waitCallback) self.__waitCallback = None g_keyEventHandlers.remove(self.handleKeyEvent) g_mouseEventHandlers.remove(self.handleMouseEventGlobal) BigWorld.SetDrawInflux(False) MapActivities.g_mapActivities.stop() if self.__spaceId is not None and BigWorld.isClientSpace(self.__spaceId): if self.__spaceMappingId is not None: BigWorld.delSpaceGeometryMapping(self.__spaceId, self.__spaceMappingId) BigWorld.clearSpace(self.__spaceId) BigWorld.releaseSpace(self.__spaceId) self.__spaceMappingId = None self.__spaceId = None self.__vEntityId = None BigWorld.wg_disableSpecialFPSMode() g_postProcessing.disable() FovExtended.instance().resetFov() return
def __cancelRejoinCallback(self): """Clear rejoin callback """ if self.__reJoinCallbackID is not None: BigWorld.cancelCallback(self.__reJoinCallbackID) self.__reJoinCallbackID = None return
def stop(self): g_playerEvents.onPrebattlesListReceived -= self.__pe_onPrebattlesListReceived self.__callback = None if self.__callbackID is not None: BigWorld.cancelCallback(self.__callbackID) self.__callbackID = None return
def __clearHideCallbacks(self): for _, callbackID in self.__callbackIDs.items(): if callbackID is not None: BigWorld.cancelCallback(callbackID) self.__callbackIDs.clear() return
def markCell(self, cellIndexes, duration): if not self.__isStarted: return if cellIndexes < 0: return (columnCount, rowCount,) = Minimap.__MINIMAP_CELLS column = cellIndexes / columnCount % columnCount row = cellIndexes % columnCount if self.__marks.has_key(cellIndexes): BigWorld.cancelCallback(self.__marks[cellIndexes][1]) self._removeCellMark(cellIndexes) arenaDesc = BigWorld.player().arena.arenaType (bottomLeft, upperRight,) = arenaDesc.boundingBox viewpoint = (upperRight + bottomLeft) * 0.5 viewpointTranslate = Math.Matrix() viewpointTranslate.setTranslate((viewpoint.x, 0.0, viewpoint.y)) spaceSize = upperRight - bottomLeft pos = (column * spaceSize[0] / columnCount - spaceSize[0] * 0.5, 0, -row * spaceSize[1] / rowCount + spaceSize[0] * 0.5) m = Math.Matrix() m.setTranslate(Math.Matrix(viewpointTranslate).applyPoint(pos)) player = BigWorld.player() if player.isTeleport: tmpPointUp = (pos[0], 1000.0, pos[2]) tmpPointDown = (pos[0], -1000.0, pos[2]) colRes = BigWorld.collide(player.spaceID, tmpPointUp, tmpPointDown) height = colRes[0][1] player.base.vehicle_teleport((pos[0], height, pos[2]), 0) mark = self.__ownUI.addEntry(m, self.zIndexManager.getIndexByName('cell')) self.__ownUI.entryInvoke(mark, ('gotoAndStop', ['cellFlash'])) self._playAttention(None) callbackID = BigWorld.callback(duration, partial(self._removeCellMark, cellIndexes)) self.__marks[cellIndexes] = (mark, callbackID)
def onLeaveWorld(self): self.models = [] if self.__decisionCallbackId is not None: BigWorld.cancelCallback(self.__decisionCallbackId) self.__decisionStrategy = None FlockLike.destroy(self) return
def onStop(self): if self.__startDelayId is not None: BigWorld.cancelCallback(self.__startDelayId) self.__startDelayId = None self.__stopDelayId = None self.__vibrationObject.stopEffect(self.handle) self.__stopDelayId = BigWorld.callback(EffectsSettings.DELAY_BETWEEN_EFFECTS, self.__delayedStop)
def __cancelCooldownCallback(self): if self.__cooldownCallback is not None: BigWorld.cancelCallback(self.__cooldownCallback) self.__cooldownCallback = None self.__cooldownBuildings = [] self.__cooldownPassed = False return
def __delFlagMarker(self, flagID): handle, callbackID = self.__markers.pop(flagID, (None, None)) if handle is not None: self._parentObj.destroyStaticMarker(handle) if callbackID is not None: BigWorld.cancelCallback(callbackID) return
def destroy(self): for callbackFunc, callbackId in self.__callbacks.iteritems(): if callbackId is not None: BigWorld.cancelCallback(callbackId) self.__callbacks = {} return
def start(self): if self.isPeriodic() and self.__possibility < random.uniform(0.0, 1.0): self.__startTime += self.__period return else: if self.__firstLaunch is True: BigWorld.addModel(self.__model) self.__model.forceReflect = True self.__motor = BigWorld.WGWarplaneMotor(self.__curve, 0) self.__model.addMotor(self.__motor) self.__endTime = self.__motor.totalTime + self.__startTime if self.__endTime <= Timer.getTime(): self.__fadedIn = True else: self.__motor.restart(Timer.getTime() - self.__startTime) self.__firstLaunch = False else: self.pause() if self.__motor is not None: self.__model.addMotor(self.__motor) self.__motor.restart() self.__endTime = self.__motor.totalTime + self.__startTime if self.__cbID is not None: BigWorld.cancelCallback(self.__cbID) if self.__sound is not None: self.__sound.stopAll() self.__sound = None self.__fadedIn = False self.__model.visible = 1 self.__startTime += self.__period self.__waitEnterWorld() return
def stop(self): if self.__onStopCallbackId is not None: BigWorld.cancelCallback(self.__onStopCallbackId) self.__onStopCallbackId = None self.onStop(self) self.__isRunning = False return
def __endEventCallback(self, sound): self.pause() self.__isOver = True if self.__cbID is not None: BigWorld.cancelCallback(self.__cbID) self.__cbID = None return
def start(self): if self.__onStopCallbackId is not None: BigWorld.cancelCallback(self.__onStopCallbackId) self.__onStopCallbackId = None if self.__duration is not None: self.__onStopCallbackId = BigWorld.callback(self.__duration, self.stop) self.__isRunning = True
def setupToolTip(self, component, toolTipInfo): if not self.toolTipGUIs.has_key(toolTipInfo.templateName): ERROR_MSG("Setting up tool tip with missing template '%s'" % (toolTipInfo.templateName,)) return else: if self.toolTipGUI != self.toolTipGUIs[toolTipInfo.templateName] and self.toolTipGUI in self.rootGUI.children: self.rootGUI.delChild(self.toolTipGUI) self.toolTipGUI = None if toolTipInfo.infoArea: infoArea = toolTipInfo.infoArea else: infoArea = (0.0, 0.0, component.width, component.height) self.infoAreaLeft, self.infoAreaTop = component.localToScreen((infoArea[0], infoArea[1])) self.infoAreaRight, self.infoAreaBottom = component.localToScreen((infoArea[2], infoArea[3])) showFunction = partial(self._showToolTip, component, toolTipInfo) if self.showToolTipCallback is not None: BigWorld.cancelCallback(self.showToolTipCallback) self.showToolTipCallback = None if toolTipInfo.delayType and toolTipInfo.delayType == ToolTip.IMMEDIATE_TOOL_TIP: showFunction() self.showToolTipCallback = None else: self.showToolTipCallback = BigWorld.callback(ToolTip.DELAY_TIME, showFunction) return
def __stopUpdateScreen(self): if self.__timerCallback is not None: BigWorld.cancelCallback(self.__timerCallback) self.__timerCallback = None if self.__queueCallback is not None: BigWorld.cancelCallback(self.__queueCallback) self.__queueCallback = None
def __onStateChanged(self, repairPointID, action, timeLeft = 0): if repairPointID not in self.__markers: LOG_ERROR('Got repair point state changed for not available repair point: ', repairPointID, action, timeLeft) return else: if action in (constants.REPAIR_POINT_ACTION.START_REPAIR, constants.REPAIR_POINT_ACTION.COMPLETE_REPAIR, constants.REPAIR_POINT_ACTION.BECOME_READY): handle, callbackID, repairPos, wasActive, isAlly = self.__markers[repairPointID] isActive = action in (constants.REPAIR_POINT_ACTION.START_REPAIR, constants.REPAIR_POINT_ACTION.BECOME_READY) if wasActive == isActive: return if callbackID is not None: BigWorld.cancelCallback(callbackID) callbackID = None self._parentObj.invokeMarker(handle, 'setIcon', ['active' if isActive else 'cooldown', isAlly]) self._parentObj.invokeMarker(handle, 'setLabel', ['']) self.__markers[repairPointID] = (handle, callbackID, repairPos, isActive, isAlly) if not isActive: self.__initTimer(int(math.ceil(timeLeft)), repairPointID) elif action == constants.REPAIR_POINT_ACTION.BECOME_DISABLED: handle, callbackID, _, _, _ = self.__markers.pop(repairPointID) self._parentObj.destroyStaticMarker(handle) if callbackID is not None: BigWorld.cancelCallback(callbackID) return
def enable(self, effectID, enable): effectDesc = self.__effects.get(effectID, None) if self.__node.isDangling or effectDesc is None: return False else: if effectDesc[PixieNode._PIXIE_ENABLED] != enable: if enable: self.__activated = True if effectDesc[PixieNode._PIXIE_TTL] > 0.0: ttlCbk = self.__ttlCallbacks.get(effectID, None) if ttlCbk is not None: BigWorld.cancelCallback(ttlCbk) self.__ttlCallbacks[effectID] = BigWorld.callback(effectDesc[PixieNode._PIXIE_TTL], partial(self.__detachTTL, effectID)) else: PixieCache.getPixie(effectDesc[PixieNode._PIXIE_NAME], (weakref.ref(self), effectID)) else: pixieRef = effectDesc[PixieNode._PIXIE_REF] if pixieRef is None: PixieCache.getPixie(effectDesc[PixieNode._PIXIE_NAME], (weakref.ref(self), effectID)) else: self.__attach(pixieRef) elif effectDesc[PixieNode._PIXIE_REF] is not None and effectDesc[PixieNode._PIXIE_TTL] == 0.0: self.__detach(effectDesc) effectDesc[PixieNode._PIXIE_ENABLED] = enable return
def onLogin(self, user, password, host, hdlr, isSocialToken2Login = False): self.__onLoggingTryingEndHdlr = hdlr self.__kickedFromServer = False self.__kickPeripheryID = None if self.__closeCallbackId: BigWorld.cancelCallback(self.__closeCallbackId) self.__closeCallbackId = None if not isSocialToken2Login: if not self.__validateCredentials(user.lower().strip(), password.strip()): self.__onLoggingTryingEndHdlr() return Waiting.show('login') self.__loginDataLoader.host = host self.__loginDataLoader.user = user self.__loginDataLoader.passLength = len(password) self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host) password = pwd_token.generate(password) if len(self.__loginDataLoader.token2): password = '' token2 = self.__loginDataLoader.token2 if AUTO_LOGIN_QUERY_URL == host: g_preDefinedHosts.autoLoginQuery(lambda host: connectionManager.connect(getHostURL(host, token2), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)) return else: host = g_preDefinedHosts.byUrl(host) connectionManager.connect(getHostURL(host, token2, True), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd) return
def _isCriticalAchieved(self): criticalTimeValue, musicStopPredelay = self.criticalValue if self._period is not None and self._totalTime is not None: self._initialized = True if self._period == ARENA_PERIOD.BATTLE and self._totalTime is not None and self._totalTime <= criticalTimeValue: if self.__stopEpicTimeRemainedCooldown is not None: BigWorld.cancelCallback(self.__stopEpicTimeRemainedCooldown) LOG_DEBUG('[EPIC Drone] Time Remained. Cooldown canceled') self.__stopEpicTimeRemainedCooldown = None return self._updateValidValue(True) else: if self.isSatisfied(): criticalTimeValue, musicStopPredelay = self.criticalValue if self.__stopEpicTimeRemainedCooldown is None: LOG_DEBUG( '[EPIC Drone] Time Remained. Stop music EpicTimeRemainedCooldown has been started - musicStopPredelay: ', musicStopPredelay) self.__stopEpicTimeRemainedCooldown = BigWorld.callback( musicStopPredelay, partial(self.__onEpicTimeRemainedCooldownOver, time.time())) return False
def onLeaveWorld(self): self.__settingsCore.onSettingsChanged -= self.__onSettingsChanged g_eventBus.removeListener(MarkersManagerEvent.MARKERS_CREATED, self._onMarkersCreated, EVENT_BUS_SCOPE.BATTLE) for callbackID in self._callbacks.itervalues(): BigWorld.cancelCallback(callbackID) self._callbacks = {} self.__destroyAreaGameObject() for area in self._areas.itervalues(): area.destroy() self._areas = {} self.__mainAreaID = None for animator in self._sequences: if animator: animator.stop() self._sequences = [] self._equipment = None return
def __tick(self): if self.__nextActionTime > 0 and self.__recoveryActivated: diffTime = self.__nextActionTime - BigWorld.serverTime() timerText = time_utils.getTimeLeftFormat(diffTime) if diffTime > 0: self.__cooldownTimerCallback = BigWorld.callback( 1, self.__tick) self.as_updateTimerS( i18n.makeString(INGAME_GUI.RECOVERY_COOLDOWN, cooldown=timerText)) else: self.__nextActionTime = -1 self.as_updateTimerS( i18n.makeString(INGAME_GUI.RECOVERY_COOLDOWN, cooldown=timerText)) self.__cooldownTimerCallback = None self.__cancelHideCallback(_CALLBACK_HIDE.COOLDOWN) self.as_displayCooldownS(False, False) elif self.__cooldownTimerCallback: BigWorld.cancelCallback(self.__cooldownTimerCallback) self.__cooldownTimerCallback = None return
def stop(self): while self.__aoiToFarCallbacksIDs: _, callbackID = self.__aoiToFarCallbacksIDs.popitem() if callbackID is not None: BigWorld.cancelCallback(callbackID) while self.__destroyCallbacksIDs: _, callbackID = self.__destroyCallbacksIDs.popitem() if callbackID is not None: BigWorld.cancelCallback(callbackID) g_sessionProvider.removeArenaCtrl(self) g_eventBus.removeListener(events.GameEvent.SHOW_EXTENDED_INFO, self.__handleShowExtendedInfo, scope=EVENT_BUS_SCOPE.BATTLE) ctrl = g_sessionProvider.shared.feedback if ctrl is not None: ctrl.onMinimapVehicleAdded -= self.__onMinimapVehicleAdded ctrl.onMinimapVehicleRemoved -= self.__onMinimapVehicleRemoved ctrl.onMinimapFeedbackReceived -= self.__onMinimapFeedbackReceived super(ArenaVehiclesPlugin, self).stop() return
def _dispose(self): ScaleformFileLoader.disableStreaming() self.__backgroundMode.hide() if self.__capsLockCallbackID is not None: BigWorld.cancelCallback(self.__capsLockCallbackID) self.__capsLockCallbackID = None self.connectionMgr.onRejected -= self._onLoginRejected self.connectionMgr.onKickWhileLoginReceived -= self._onKickedWhileLogin self.connectionMgr.onQueued -= self._onHandleQueue self._servers.onServersStatusChanged -= self.__updateServersList g_playerEvents.onAccountShowGUI -= self._clearLoginView g_playerEvents.onEntityCheckOutEnqueued -= self._onEntityCheckoutEnqueued g_playerEvents.onAccountBecomeNonPlayer -= self._onAccountBecomeNonPlayer if self._entityEnqueueCancelCallback: g_eventBus.removeListener(BootcampEvent.QUEUE_DIALOG_CANCEL, self._onEntityCheckoutCanceled, EVENT_BUS_SCOPE.LOBBY) self._serversDP.fini() self._serversDP = None self._entityEnqueueCancelCallback = None View._dispose(self) return
def stop(self): if self.__cbID is not None: BigWorld.cancelCallback(self.__cbID) self.__cbID = None if self.__model is not None: if self.__motor is not None and self.__motor in self.__model.motors: self.__model.delMotor(self.__motor) if self.__model in BigWorld.models(): BigWorld.delModel(self.__model) self.__model = None self.__motor = None self.__curve = None if self.__sound is not None: self.__sound.stopAll() self.__sound = None if self.__particle[1] is not None and self.__particle[ 1].pixie is not None: self.__particle[0].detach(self.__particle[1].pixie) self.__particle[1].destroy() self.__particle = (None, None) self.__firstLaunch = True return
def __notifyAutoLoader(self, state): actualTime = state.getActualValue() baseTime = state.getBaseValue() if self.__shellsInClip == 0 and state.isReloading(): timeGone = baseTime - actualTime clipInterval = self.__guiSettings.getClipInterval() if clipInterval > timeGone: actualTime = clipInterval - timeGone baseTime = clipInterval if self.__autoReloadCallbackID is not None: BigWorld.cancelCallback(self.__autoReloadCallbackID) self.__autoReloadCallbackID = BigWorld.callback( actualTime, self.__autoReloadFirstShellCallback) self.__scaledInterval = clipInterval self.__reloadAnimator.setClipAutoLoading(0, 0) else: self.__reloadAnimator.setClipAutoLoading( actualTime, self.__reCalcFirstShellAutoReload(baseTime)) actualTime = baseTime = 0 self.__autoReloadSnapshot = state self.__reloadAnimator.setShellLoading(actualTime, baseTime) return
def destroy(self): if not self.__isStarted: self.__vehiclesWaitStart = [] return else: while len(self.__aoiToFarCallbacks): _, callbackID = self.__aoiToFarCallbacks.popitem() if callbackID is not None: BigWorld.cancelCallback(callbackID) self.__isStarted = False self.__entries = {} self.__cameraHandle = None self.__marks = None self.__backMarkers.clear() setattr(self.__parentUI.component, 'minimap', None) from account_helpers.SettingsCore import g_settingsCore g_settingsCore.onSettingsChanged -= self.setupMinimapSettings AccountSettings.setSettings('minimapSize', self.__mapSizeIndex) self.__parentUI = None g_repeatKeyHandlers.remove(self.handleRepeatKeyEvent) return
def enable(self, targetPos, saveZoom, isRemoteCamera=False): self.__prevTime = BigWorld.time() player = BigWorld.player() if saveZoom: self.__zoom = self.__cfg['zoom'] else: self.__cfg['zoom'] = self.__zoom = self.__cfg['zooms'][0] self.__applyZoom(self.__zoom) self.__setupCamera(targetPos) vehicle = player.getVehicleAttached() if self.__waitVehicleCallbackId is not None: BigWorld.cancelCallback(self.__waitVehicleCallbackId) if vehicle is None: self.__waitVehicleCallbackId = BigWorld.callback( 0.1, self.__waitVehicle) else: self.__showVehicle(False) self.__isRemoteCamera = isRemoteCamera BigWorld.camera(self.__cam) if self.__cameraUpdate(False) >= 0.0: self.delayCallback(0.0, self.__cameraUpdate) return
def setup(playerVehicle, localPlayer): global isReset if BigWorld.player() or hasattr(localPlayer, 'isOnArena') and playerVehicle is not None: try: if ME_Tank.callbackID is not None: BigWorld.cancelCallback(ME_Tank.callbackID) except Exception: pass ME_Tank.getPlayerTankValues() eAP.showArmorPanel() AnglePanel.showProtractor() if ME_Tank.tankType != "Tank" and AnglePanel.enable: AnglePanel.initialValues() AnglePanel.updateProtractor(0.0, 0.0, int(ME_Tank.leftArc), int(ME_Tank.rightArc)) if eAP.enable: eAP.updateEffArmor(ME_Tank.effFrontArmor, 0, 0) isReset = False as_event('ON_ARMOR') else: ME_Tank.callbackID = BigWorld.callback(0.5, setup)
def _findPlayerFeedbackByAttack(self, vehicleID, newHealth, attackerID, attackReasonID): if not self.__isPEEnabled or not newHealth or not attackerID or attackerID != avatar_getter.getPlayerVehicleID( ): return else: vo = self.__arenaDP.getVehicleInfo(vehicleID) if self.__arenaDP.isAllyTeam(vo.team): return if attackReasonID >= len(_AR): return LOG_DEBUG( "Enemy's vehicle health has been changed by player action", newHealth, _AR[attackReasonID]) if _AR[attackReasonID] == 'ramming': if self.__rammingCallbackID is None: self.__setRammingCooldown() self.__pushPlayerEvent(_EVENT_ID.PLAYER_DAMAGED_HP_ENEMY) else: BigWorld.cancelCallback(self.__rammingCallbackID) self.__setRammingCooldown() return
def stop(self, finished=False): if self._stopped: return else: if self._currentState: self._currentState.destroy() self._currentState = None if self.__callbackID is not None: BigWorld.cancelCallback(self.__callbackID) self.__callbackID = None if self._funcScene is not None: self._funcScene.leave() if self._funcChapterCtx is not None: self._funcChapterCtx.clear() if self._data is not None: self._data.clear() GlobalStorage.clearFlags() if self._sound is not None: self._sound.stop() self._sound = None if self._gui is not None: self._gui.fini() self._gui = None if finished: self._cache.setFinished(True).write() else: self._cache.update(self._currentChapter, self._flags.getDict() if self._flags else None) self._cache = None g_tutorialWeaver.clear() clearTutorialProxy() self.removeEffectsInQueue() self._nextChapter = False self._stopped = True self._initialized = 0 self._triggeredEffects.clear() LOG_DEBUG('Tutorial is stopped', self.getID()) self.onStopped() return
def stop(self, finished=False): """ Stops the process of training. :param finished: if it equals True than training completed. """ if self._stopped: return else: if self.__callbackID is not None: BigWorld.cancelCallback(self.__callbackID) self.__callbackID = None if self._funcScene is not None: self._funcScene.leave() if self._data is not None: self._data.clear() GlobalStorage.clearFlags() if self._sound is not None: self._sound.stop() self._sound = None if self._gui is not None: self._gui.fini() self._gui = None if finished: self._cache.setFinished(True).write() else: self._cache.update( self._currentChapter, self._flags.getDict() if self._flags else None) self._cache = None g_tutorialWeaver.clear() clearTutorialProxy() self.removeEffectsInQueue() self._nextChapter = False self._stopped = True self._initialized = 0 self._triggeredEffects.clear() self.onStopped() return
def activate(self): typeDescr = self.typeDescriptor wheelConfig = typeDescr.chassis.generalWheelsAnimatorConfig if self.wheelsAnimator is not None and wheelConfig is not None: self.wheelsAnimator.createCollision(wheelConfig, self.collisions) super(CommonTankAppearance, self).activate() self.wheelsGameObject.activate() for go in self.filterRetrieverGameObjects: go.activate() if not self.isObserver: self._chassisDecal.attach() if not self.isObserver: self._startSystems() self.filter.enableLagDetection( not self.damageState.isCurrentModelDamaged) if self.__periodicTimerID is not None: BigWorld.cancelCallback(self.__periodicTimerID) self.__periodicTimerID = BigWorld.callback(PERIODIC_UPDATE_TIME, self.__onPeriodicTimer) self.setupGunMatrixTargets(self.filter) for lodCalculator in self.allLodCalculators: lodCalculator.setupPosition( DataLinks.linkMatrixTranslation(self.compoundModel.matrix)) for modelAnimator in self.__modelAnimators: modelAnimator.animator.setEnabled(True) modelAnimator.animator.start() if hasattr(self.filter, 'placingCompensationMatrix' ) and self.swingingAnimator is not None: self.swingingAnimator.placingCompensationMatrix = self.filter.placingCompensationMatrix self.swingingAnimator.worldMatrix = self.compoundModel.matrix if self.isObserver: self.compoundModel.visible = False self._connectCollider() self._attachStickers() return
def fini(self): g_eventBus.removeListener( events.LobbySimpleEvent.NOTIFY_CURSOR_OVER_3DSCENE, self.__onNotifyCursorOver3dScene) g_eventBus.removeListener( events.LobbySimpleEvent.NOTIFY_CURSOR_DRAGGING, self.__onNotifyCursorDragging) g_eventBus.removeListener(events.CustomizationEvent.SHOW, self.__onShowCustomization, scope=EVENT_BUS_SCOPE.LOBBY) g_currentVehicle.onChanged -= self.__onVehicleChanged self.hangarSpace.onSpaceDestroy -= self.__onSpaceDestroy self.hangarSpace.onSpaceCreate -= self.__onSpaceCreate Windowing.removeWindowAccessibilityHandler( self.__onWindowAccessibilityChanged) self.stopHighlighter() self._eventsManager.clear() self.__cleanupSuspendHighlighterCallback() self.__showCustomizationKwargs = None if self.__showCustomizationCallbackId is not None: BigWorld.cancelCallback(self.__showCustomizationCallbackId) self.__showCustomizationCallbackId = None return
def __parseData(self, data): if self.__cbExitState: BigWorld.cancelCallback(self.__cbExitState) self.__cbExitState = None if data.finishTime > 0.0: self.__finishTime = data.finishTime self.__cbExitState = BigWorld.callback(self.__finishTime, self._context.cameraManager.leaveState) self.__returnToNormal = data.finishLength if hasattr(data, 'lagHalfLife'): self.__lagHalfLife = data.lagHalfLife strategyData = {} self.__parseNodePositions(data, strategyData) self.__parseNodeTargets(data, strategyData) self.__parseTargets(data, strategyData) self.__parseFOVs(data, strategyData) self.__parsePositions(data, strategyData) self.__parseRotations(data, strategyData) self.__parseEffects(data, strategyData) if hasattr(data, 'linkingType'): strategyData['linkingType'] = data.linkingType else: LOG_ERROR("Linking type isn't exist!") return strategyData
def _action(self, basePointIndex, action, nextActionTime): if action in (SECTOR_BASE_ACTION.ENTER, SECTOR_BASE_ACTION.ENTER_WHILE_CD): self._controller.onVehicleEntered(self._type, basePointIndex, None) self._inCircleIdx = basePointIndex elif action in (SECTOR_BASE_ACTION.LEAVE, SECTOR_BASE_ACTION.LEAVE_WHILE_CD): self._controller.onVehicleLeft(self._type, basePointIndex) self._inCircleIdx = -1 elif action == SECTOR_BASE_ACTION.COOLDOWN: duration = self._getTime(nextActionTime) self._sessionProvider.invalidateVehicleState( VEHICLE_VIEW_STATE.CAPTURE_BLOCKED, duration) if self.__blockedCB is not None: BigWorld.cancelCallback(self.__blockedCB) self.__blockedCB = None self.__blockedCB = BigWorld.callback(duration, self.__stopBlockState) else: if action == SECTOR_BASE_ACTION.CAPTURED: return LOG_WARNING('SectorBasePlugin: NO SUCH ACTION ', action) return
def onUnload(self): arena = getattr(BigWorld.player(), 'arena', None) if not g_sessionProvider.getCtx().isInBattle or arena is None: return else: CommandMapping.g_instance.onMappingChanged -= self.setCommands arena.onPeriodChange -= self.__onSetArenaTime arena.onNewVehicleListReceived -= self.__updatePlayers arena.onNewStatisticsReceived -= self.__updatePlayers arena.onVehicleAdded -= self.__updatePlayers arena.onVehicleStatisticsUpdate -= self.__updatePlayers arena.onVehicleKilled -= self.__updatePlayers arena.onAvatarReady -= self.__updatePlayers if self.__timerCallBackId: BigWorld.cancelCallback(self.__timerCallBackId) self.__timerCallBackId = None if self.__debugCallBackId: BigWorld.cancelCallback(self.__debugCallBackId) self.__debugCallBackId = None if self._colorManager: self._colorManager.dispossessUI() _LogitechScreen.onUnload(self) return
def onLoadedCallback(self, pixie, effectID, clone): if self.__node.isDangling: return False effectDesc = self.__effects[effectID] prevPixie = effectDesc[PixieNode._PIXIE_REF] if prevPixie is not None: self.__detach(effectDesc) if effectDesc[PixieNode._PIXIE_TTL] > 0.0: ttlCbk = self.__ttlCallbacks.get(effectID, None) if ttlCbk is not None: BigWorld.cancelCallback(ttlCbk) if clone: pixie = pixie.clone() self.__attachTTL(effectDesc, effectID, pixie) return True elif effectDesc[PixieNode._PIXIE_ENABLED]: if clone: pixie = pixie.clone() effectDesc[PixieNode._PIXIE_REF] = pixie self.__attach(pixie) return True else: return False
def setEquipment(self, intCD, quantity, stage, timeRemaining, totalTime): super(EquipmentsReplayPlayer, self).setEquipment(intCD, quantity, stage, timeRemaining, totalTime) self.__percents.pop(intCD, None) self.__percentGetters.pop(intCD, None) self.__times.pop(intCD, None) self.__timeGetters.pop(intCD, None) if stage in (EQUIPMENT_STAGES.DEPLOYING, EQUIPMENT_STAGES.COOLDOWN, EQUIPMENT_STAGES.SHARED_COOLDOWN): equipment = self._equipments[intCD] self.__percentGetters[intCD] = equipment.getCooldownPercents if self.__callbackID is not None: BigWorld.cancelCallback(self.__callbackID) self.__callbackID = None if equipment.getTotalTime() > 0: self.__timeGetters[intCD] = equipment.getTimeRemaining if self.__callbackTimeID is not None: BigWorld.cancelCallback(self.__callbackTimeID) self.__callbackTimeID = None self.__timeLoop() self.__timeLoopInSeconds() return
def destroy(self): if self.__inited: g_keyEventHandlers.remove(self.__handleKeyEvent) g_eventBus.removeListener(events.LobbySimpleEvent.NOTIFY_CURSOR_OVER_3DSCENE, self.__onNotifyCursorOver3dScene) self.onSpaceDestroy(self.__spaceInited and not self.__spaceDestroyedDuringLoad) self.__videoCameraController.destroy() self.__isModelLoaded = False if self.__spaceInited: LOG_DEBUG('HangarSpace::destroy') self.__inited = False self.__spaceInited = False self.__space.destroy() elif self.spaceLoading(): LOG_DEBUG('HangarSpace::destroy - delayed until space load done') self.__spaceDestroyedDuringLoad = True self.__space.destroy() self.__inited = False self.__spaceInited = False if self.__delayedRefreshCallback is not None: BigWorld.cancelCallback(self.__delayedRefreshCallback) self.__delayedRefreshCallback = None self.gameSession.onPremiumNotify -= self.onPremiumChanged return
def __updateNotifications(self, newState, timeToNextMode): if self.__sounds is None: return else: goToSiegeMode = newState == VEHICLE_SIEGE_STATE.SWITCHING_ON goToBaseMode = newState == VEHICLE_SIEGE_STATE.SWITCHING_OFF siegeModeEnabled = newState == VEHICLE_SIEGE_STATE.ENABLED siegeModeDisabled = newState == VEHICLE_SIEGE_STATE.DISABLED isValidState = goToSiegeMode or goToBaseMode or siegeModeEnabled or siegeModeDisabled if not isValidState: return eventId = SOUND_NOTIFICATIONS.START_TO_SIEGE_MODE if goToBaseMode or siegeModeDisabled: eventId = SOUND_NOTIFICATIONS.START_TO_BASE_MODE isEngineDestroyed = BigWorld.player().deviceStates.get('engine') == 'destroyed' if isEngineDestroyed != self.__engineWasDestroyed: if isEngineDestroyed: SoundGroups.g_instance.playSound2D(SOUND_NOTIFICATIONS.MOVEMENT_LIMITED_ON) else: SoundGroups.g_instance.playSound2D(SOUND_NOTIFICATIONS.MOVEMENT_LIMITED_OFF) self.__engineWasDestroyed = isEngineDestroyed if goToSiegeMode: if self.__siegeCallback is not None: BigWorld.cancelCallback(self.__siegeCallback) self.__siegeCallback = None if not isEngineDestroyed: deltaTime = timeToNextMode - 1.0 if timeToNextMode > 1.0 else 0.0 self.__siegeCallback = BigWorld.callback(deltaTime, self.__onSiegeTimer) shouldStopSound = siegeModeEnabled or siegeModeDisabled or isEngineDestroyed sound = self.__sounds[eventId] if sound is None: return if shouldStopSound: sound.stop() elif not sound.isPlaying: sound.play() return
def __cleanupAfterTimeWarp(self): BigWorld.wg_clearDecals() if self.__replayCtrl.isTimeWarpInProgress: self.__enableInGameEffects(False) self.__timeWarpCleanupCb = BigWorld.callback( 0.0, self.__cleanupAfterTimeWarp) else: if self.__timeWarpCleanupCb is not None: BigWorld.cancelCallback(self.__timeWarpCleanupCb) self.__timeWarpCleanupCb = None self.__warpTime = -1.0 BigWorld.wg_enableGUIBackground(False, False) self.__enableInGameEffects(0.0 < self.__playbackSpeedModifiers[ self.__playbackSpeedIdx] < 8.0) g_replayEvents.onMuteSound(not 0.0 < self.__playbackSpeedModifiers[ self.__playbackSpeedIdx] < 8.0) if self.__wasVideoBeforeRewind: BigWorld.player().inputHandler.onControlModeChanged( 'video', prevModeName='arcade', camMatrix=self.__videoCameraMatrix) self.__wasVideoBeforeRewind = False g_replayEvents.onTimeWarpFinish() return
def sun_controller(isControlled=True): global timeBackup global wasSunControlled if isControlled: timeBackup = BigWorld.timeOfDay('GetTime') if g_config.data['time'] != 24: BigWorld.timeOfDay('%s:0' % g_config.data['time']) else: BigWorld.timeOfDay(time.strftime('%H:%M')) g_config.sunCallback = BigWorld.callback(60.0, sun_controller) wasSunControlled = True elif wasSunControlled: BigWorld.timeOfDay(timeBackup) try: g_config.sunCallback = BigWorld.cancelCallback(getattr(g_config, 'sunCallback', None)) except StandardError: pass
def stop(self): if self.__callbackID is not None: BigWorld.cancelCallback(self.__callbackID) self.__callbackID = None if self.__rammingCallbackID is not None: BigWorld.cancelCallback(self.__rammingCallbackID) self.__rammingCallbackID = None self.__visible.clear() while self.__pending: _, callbackID = self.__pending.popitem() if callbackID is not None: BigWorld.cancelCallback(callbackID) self.__isPEEnabled = False self.__arenaDP = None self.__aimProps = None
def stopControl(self): if self.__callbackID is not None: BigWorld.cancelCallback(self.__callbackID) self.__callbackID = None if self.__rammingCallbackID is not None: BigWorld.cancelCallback(self.__rammingCallbackID) self.__rammingCallbackID = None self.__visible.clear() while self.__pending: _, callbackID = self.__pending.popitem() if callbackID is not None: BigWorld.cancelCallback(callbackID) self.__isPEEnabled = False self.__arenaDP = None self.__arenaVisitor = None self.__attrs = {} return
def __delEntry(self, id, inCallback=False): entry = self.__entries.get(id) if entry is None: return else: self.__ownUI.delEntry(entry['handle']) if entry.get('location') == VehicleLocation.AOI_TO_FAR: callbackId = self.__aoiToFarCallbacks.pop(id, None) if callbackId is not None: BigWorld.cancelCallback(callbackId) if id in self.__enemyEntries: self.__enemyEntries.pop(id) if not len(self.__enemyEntries): if self.__checkEnemyLengthID: BigWorld.cancelCallback(self.__checkEnemyLengthID) self.__checkEnemyLengthID = BigWorld.callback( 5, self.__checkEnemyLength) try: callbackId = self.__deadCallbacks.pop(id) BigWorld.cancelCallback(callbackId) except KeyError: pass return self.__entries.pop(id)
def stop(self): if self.__cbId is not None: BigWorld.cancelCallback(self.__cbId) self.__cbId = None return
def __clearVoiceChatMicDeviceCallback(self): if self.__voiceChatMicDeviceCallback is not None: BigWorld.cancelCallback(self.__voiceChatMicDeviceCallback) self.__voiceChatMicDeviceCallback = None return
def clearRentCallbacks(): for cbID in RENT_CALLBACKS: BigWorld.cancelCallback(cbID) RENT_CALLBACKS.clear()