def __init__(self): super(BattleRoyaleConsumablesPanel, self).__init__() self.__quantityMap = [None] * self._PANEL_MAX_LENGTH self.__equipmentRange = range(self._EQUIPMENT_START_IDX, self._EQUIPMENT_END_IDX + 1) self.__es = EventsSubscriber() return
def __init__(self): super(MinefieldPlayerMessenger, self).__init__() self.__eventsSubscriber = EventsSubscriber() self.__eventsSubscriber.subscribeToEvent( self.__sessionProvider.shared.feedback.onPlayerFeedbackReceived, self._onPlayerFeedbackReceived) self.__equipmentCtrl = self.__sessionProvider.shared.equipments self.__eventsSubscriber.subscribeToEvent( self.__equipmentCtrl.onCombatEquipmentUsed, self.__onCombatEquipmentUsed)
def __init__(self, *args): super(VehicleShotPassionComponent, self).__init__() self.__es = EventsSubscriber() self.__onUpdated() self.__es.subscribeToEvent( self.entity.guiSessionProvider.onUpdateObservedVehicleData, self.__onUpdateObservedVehicleData) player = BigWorld.player() if player is not None and player.inputHandler is not None: self.__es.subscribeToEvent(player.inputHandler.onCameraChanged, self.__onCameraChanged) return
def __init__(self, components=None): if components is None: components = _BATTLE_ROYALE_CFG self.__selectSpawnToggling = set() self.__brSoundControl = None self.__isFullStatsShown = False self.__panelsIsVisible = False self.__es = EventsSubscriber() self.__isAllowToogleGuiVisible = False super(BattleRoyalePage, self).__init__(components, external=(crosshair.CrosshairPanelContainer, BattleRoyaleMarkersManager)) return
class VehicleShotPassionComponent(BigWorld.DynamicScriptComponent): EQUIPMENT_NAME = BattleRoyaleEquipments.SHOT_PASSION def __init__(self, *args): super(VehicleShotPassionComponent, self).__init__() self.__es = EventsSubscriber() self.__onUpdated() self.__es.subscribeToEvent( self.entity.guiSessionProvider.onUpdateObservedVehicleData, self.__onUpdateObservedVehicleData) player = BigWorld.player() if player is not None and player.inputHandler is not None: self.__es.subscribeToEvent(player.inputHandler.onCameraChanged, self.__onCameraChanged) return def getInfo(self): return ShotPassionInfo(self.endTime, self.stage) def set_endTime(self, prev): self.__onUpdated() def set_stage(self, prev): self.__onUpdated() def onDestroy(self): self.__destroy() def onLeaveWorld(self, *args): self.__destroy() def __destroy(self): self.__onUpdated(ShotPassionInfo(0.0, 0)) self.__es.unsubscribeFromAllEvents() self.__es = None return def __onUpdateObservedVehicleData(self, *args, **kwargs): self.__onUpdated() def __onUpdated(self, info=None): self.entity.guiSessionProvider.shared.vehicleState.onEquipmentComponentUpdated( self.EQUIPMENT_NAME, self.entity.id, info or self.getInfo()) def __onCameraChanged(self, cameraName, currentVehicleId=None): if cameraName == 'video': self.__elapsedTime = max(self.endTime - BigWorld.serverTime(), 0.0) self.__updateMarker(self.__elapsedTime) def __updateMarker(self, elapsedTime): feedback = self.entity.guiSessionProvider.shared.feedback data = { 'isShown': bool(elapsedTime), 'isSourceVehicle': False, 'duration': elapsedTime, 'animated': True, 'markerID': BATTLE_MARKER_STATES.SHOT_PASSION_STATE } feedback.onVehicleFeedbackReceived( FEEDBACK_EVENT_ID.VEHICLE_CUSTOM_MARKER, self.entity.id, data)
class MinefieldPlayerMessenger(IProgressionListener, IViewComponentsCtrlListener): MINEFIELD_INSTALLED_ID = 'MINEFIELD_INSTALLED' MINEFIELD_DESTROYED_ID = 'MINEFIELD_DESTROYED' __sessionProvider = dependency.descriptor(IBattleSessionProvider) def __init__(self): super(MinefieldPlayerMessenger, self).__init__() self.__eventsSubscriber = EventsSubscriber() self.__eventsSubscriber.subscribeToEvent( self.__sessionProvider.shared.feedback.onPlayerFeedbackReceived, self._onPlayerFeedbackReceived) self.__equipmentCtrl = self.__sessionProvider.shared.equipments self.__eventsSubscriber.subscribeToEvent( self.__equipmentCtrl.onCombatEquipmentUsed, self.__onCombatEquipmentUsed) def detachedFromCtrl(self, ctrlID): super(MinefieldPlayerMessenger, self).detachedFromCtrl(ctrlID) self.__eventsSubscriber.unsubscribeFromAllEvents() self.__equipmentCtrl = None return def __onCombatEquipmentUsed(self, shooterID, eqID): equipment = vehicles.g_cache.equipments().get(eqID) if equipment is None: return else: playerVehID = self.__sessionProvider.getArenaDP( ).getPlayerVehicleID(True) if playerVehID == shooterID and equipment.name == BattleRoyaleEquipments.MINE_FIELD: self.__sessionProvider.shared.messages.onShowPlayerMessageByKey( self.MINEFIELD_INSTALLED_ID) return def _onPlayerFeedbackReceived(self, events): for e in events: if e.getType() == FEEDBACK_EVENT_ID.EQUIPMENT_TIMER_EXPIRED: itemName = self.__equipmentCtrl.getEquipmentNameByID( e.getTargetID()) if itemName == BattleRoyaleEquipments.MINE_FIELD: self.__sessionProvider.shared.messages.onShowPlayerMessageByKey( self.MINEFIELD_DESTROYED_ID) break
def __init__(self): super(ObserverPlayersPanel, self).__init__() self.__isSyncPlayerList = False self.__observedVehID = None self.__es = EventsSubscriber() return
class ObserverPlayersPanel(IBattleFieldListener, IArenaVehiclesController, BattleRoyalePlayersPanelMeta): __sessionProvider = dependency.descriptor(IBattleSessionProvider) def __init__(self): super(ObserverPlayersPanel, self).__init__() self.__isSyncPlayerList = False self.__observedVehID = None self.__es = EventsSubscriber() return def switchToPlayer(self, vehicleID): handler = avatar_getter.getInputHandler() modeName = handler.ctrlModeName if handler is not None else '' arenaDP = self.__sessionProvider.getArenaDP() vehInfo = arenaDP.getVehicleInfo(vehicleID) if vehInfo.isAlive() and modeName != CTRL_MODE_NAME.VIDEO: if handler.isControlModeChangeAllowed(): self.__sessionProvider.shared.viewPoints.selectVehicle( vehicleID) return def updateVehiclesStats(self, updatedItems, arenaDP): updated = False for _, vStatsVO in updatedItems: updated |= self.__updateStats(vStatsVO) if updated: self.__panelUpdate() def invalidateVehicleStatus(self, flags, vInfoVO, arenaDP): if self.__updateInfo(vInfoVO): self.__panelUpdate() def updateVehiclesInfo(self, updatedItems, arenaDP): updated = False for _, vInfoVO in updatedItems: updated |= self.__updateInfo(vInfoVO) if updated: self.__panelUpdate() def _populate(self): super(ObserverPlayersPanel, self)._populate() self.__isSyncPlayerList = BigWorld.player().observerSeesAll() if self.__isSyncPlayerList: self.__init() self.__sessionProvider.addArenaCtrl(self) self.__es.subscribeToEvent( BigWorld.player().onObserverVehicleChanged, self.__onObserverVehicleChanged) componentSystem = self.__sessionProvider.arenaVisitor.getComponentSystem( ) self.__es.subscribeToEvent( componentSystem.battleRoyaleComponent. onBattleRoyaleDefeatedTeamsUpdate, self.__onTeamDeath) def _dispose(self): if self.__isSyncPlayerList: self.__sessionProvider.removeArenaCtrl(self) self.__es.unsubscribeFromAllEvents() self.__playerList = {} super(ObserverPlayersPanel, self)._dispose() def __onTeamDeath(self, defeatedTeams): self.__updateRanks(defeatedTeams) self.__panelUpdate() def __onObserverVehicleChanged(self): attached = BigWorld.player().getVehicleAttached() if attached: if self.__observedVehID is not None: self.__clearObservedVehicle(self.__observedVehID) self.__observedVehID = attached.id self.__setObservedVehicle(self.__observedVehID) self.__panelUpdate() return def __clearObservedVehicle(self, vehID): data = self.__getPlayerData(vehID) if data: data['isObserved'] = False def __setObservedVehicle(self, vehID): data = self.__getPlayerData(vehID) if data: data['isObserved'] = True def __init(self): self.__playerList = self.__getInitialPlayersList() self.__updateRanks( BigWorld.player().avatarBattleRoyaleComponent.defeatedTeams) if len(self.__playerList) != len( {player['teamIndex'] for player in self.__playerList.itervalues()}): self.as_setSeparatorVisibilityS(True) self.__panelUpdate() def __convertToUIVo(self, inData): requiredFields = [ 'isAlive', 'playerName', 'vehicleID', 'teamIndex', 'vehicleLevel', 'nationIcon', 'vehicleName', 'fragsCount', 'isObserved' ] return { key: value for key, value in inData.items() if key in requiredFields } def __getPlayerData(self, vehicleID): return self.__playerList.get(vehicleID) def __updateLevel(self, vInfo): data = self.__getPlayerData(vInfo) if data is not None: data['vehicleLevel'] = int2roman(self._getVehicleLevel(vInfo)) self.__panelUpdate() return def __updateStats(self, vStats): data = self.__getPlayerData(vStats.vehicleID) return False if not data else _comapareAndSet(data, 'fragsCount', self.__getFrags(vStats)) def __updateInfo(self, vInfo): data = self.__getPlayerData(vInfo.vehicleID) if not data: return False updated = _comapareAndSet(data, 'isAlive', vInfo.isAlive()) if _comapareAndSet(data, 'strCompactDescr', vInfo.vehicleType.strCompactDescr): data['vehicleLevel'] = int2roman(self._getVehicleLevel(vInfo)) updated = True return updated def __panelUpdate(self): outList = [((p['rank'], p['teamIndex'], not p['isCommander'], p['playerName']), self.__convertToUIVo(p)) for p in self.__playerList.itervalues()] outList.sort() deadsIdx = next( (idx for idx, item in enumerate(outList) if item[0][0] > 0), -1) self.as_setPlayersDataS([item[1] for item in outList], deadsIdx) def __updateRanks(self, defeatedTeams): ranks = {team: rank + 1 for rank, team in enumerate(defeatedTeams)} for player in self.__playerList.itervalues(): player['rank'] = ranks.get(player['teamIndex'], 0) def __getInitialPlayersList(self): arenaDP = self.__sessionProvider.getArenaDP() comanders = BigWorld.player().arenaExtraData.get('commanders', []) commandersVehID = { arenaDP.getVehIDByAccDBID(comanderDBID) for comanderDBID in comanders } isCommander = lambda vID: vID in commandersVehID playersList = {} for vInfo, vStats in arenaDP.getActiveVehiclesGenerator(): playersList[vInfo.vehicleID] = self.__makeVOData( vInfo, vStats, isCommander(vInfo.vehicleID)) return playersList def __getFrags(self, vStats): if not vStats: return '' return str(vStats.frags) if vStats.frags != 0 else '' def __makeVOData(self, vInfo, vStats, isCommander): return { 'isAlive': vInfo.isAlive(), 'playerName': vInfo.player.name, 'vehicleID': vInfo.vehicleID, 'teamIndex': vInfo.team, 'vehicleLevel': int2roman(self._getVehicleLevel(vInfo)), 'nationIcon': self.__getNationIcon(NAMES[vInfo.vehicleType.nationID]), 'vehicleName': vInfo.vehicleType.name, 'fragsCount': self.__getFrags(vStats), 'rank': 0, 'isCommander': isCommander, 'isObserved ': False, 'strCompactDescr': vInfo.vehicleType.strCompactDescr } def __getNationIcon(self, nationName): nationEmblems = R.images.gui.maps.icons.battleRoyale.emblems nationEmblemImage = None if hasattr(nationEmblems, nationName): nationEmblem = getattr(nationEmblems, nationName) nationEmblemImage = backport.image(nationEmblem()) return nationEmblemImage def _getVehicleLevel(self, vInfoVO): descriptor = VehicleDescr( compactDescr=vInfoVO.vehicleType.strCompactDescr) return max(descriptor.chassis.level, descriptor.turret.level, descriptor.gun.level, descriptor.radio.level, descriptor.engine.level)
class BattleRoyaleConsumablesPanel(ConsumablesPanel): __slots__ = ('__quantityMap', ) _PANEL_MAX_LENGTH = 10 _AMMO_START_IDX = 0 _AMMO_END_IDX = 1 _EQUIPMENT_START_IDX = 2 _EQUIPMENT_END_IDX = 9 _EQUIPMENT_ICON_PATH = '../maps/icons/battleRoyale/artefact/%s.png' def __init__(self): super(BattleRoyaleConsumablesPanel, self).__init__() self.__quantityMap = [None] * self._PANEL_MAX_LENGTH self.__equipmentRange = range(self._EQUIPMENT_START_IDX, self._EQUIPMENT_END_IDX + 1) self.__es = EventsSubscriber() return def _populate(self): super(BattleRoyaleConsumablesPanel, self)._populate() vehStateCtrl = self.sessionProvider.shared.vehicleState self.__es.subscribeToEvent(vehStateCtrl.onVehicleStateUpdated, self.__onVehicleLootAction) self.__es.subscribeToEvent(BigWorld.player().onObserverVehicleChanged, self.__onEquipmentReset) def _dispose(self): self.__es.unsubscribeFromAllEvents() super(BattleRoyaleConsumablesPanel, self)._dispose() def _getPanelSettings(self): return CONSUMABLES_PANEL_SETTINGS.BATTLE_ROYALE_SETTINGS_ID def _onShellsAdded(self, intCD, descriptor, quantity, _, gunSettings): if intCD in self._cds: return else: slotIdx = self.__getNewSlotIdx(self._AMMO_START_IDX, self._AMMO_END_IDX) if slotIdx is None: return self._addShellSlot(slotIdx, intCD, descriptor, quantity, gunSettings) self._mask |= 1 << slotIdx return def _onShellsUpdated(self, intCD, quantity, *args): if intCD not in self._cds: return super(BattleRoyaleConsumablesPanel, self)._onShellsUpdated(intCD, quantity, *args) def _onNextShellChanged(self, intCD): if intCD not in self._cds: return super(BattleRoyaleConsumablesPanel, self)._onNextShellChanged(intCD) def _onCurrentShellChanged(self, intCD): if intCD not in self._cds: return super(BattleRoyaleConsumablesPanel, self)._onCurrentShellChanged(intCD) def _onGunSettingsSet(self, _): self.__resetShellSlots() self._resetDelayedReload() def _onGunReloadTimeSet(self, currShellCD, state, skipAutoLoader): if currShellCD not in self._cds: return super(BattleRoyaleConsumablesPanel, self)._onGunReloadTimeSet(currShellCD, state, skipAutoLoader) def _onEquipmentAdded(self, intCD, item): if item is None or intCD in self._cds: return else: slotIdx = self.__getNewSlotIdx(self._EQUIPMENT_START_IDX, self._EQUIPMENT_END_IDX) if slotIdx is None: return self._addEquipmentSlot(slotIdx, intCD, item) self._mask |= 1 << slotIdx return def _isAvatarEquipment(self, item): return False def _resetOptDevices(self): pass def _addOptionalDeviceSlot(self, idx, intCD): pass def _updateShellSlot(self, idx, quantity): super(BattleRoyaleConsumablesPanel, self)._updateShellSlot(idx, quantity) prevQuantity = self.__quantityMap[idx] self.__quantityMap[idx] = quantity if prevQuantity is not None and quantity > prevQuantity: self.as_setGlowS(idx, CONSUMABLES_PANEL_SETTINGS.GLOW_ID_GREEN) return def _updateEquipmentSlot(self, idx, item): super(BattleRoyaleConsumablesPanel, self)._updateEquipmentSlot(idx, item) prevQuantity = self.__quantityMap[idx] quantity = self.__quantityMap[idx] = item.getQuantity() if prevQuantity is not None and quantity > prevQuantity: self.as_setGlowS(idx, CONSUMABLES_PANEL_SETTINGS.GLOW_ID_GREEN) return else: currStage = item.getStage() prevStage = item.getPrevStage() if currStage == EQUIPMENT_STAGES.READY and prevStage == EQUIPMENT_STAGES.COOLDOWN: self.as_setGlowS( idx, CONSUMABLES_PANEL_SETTINGS.GLOW_ID_GREEN_SPECIAL) elif currStage == EQUIPMENT_STAGES.COOLDOWN and prevStage in ( EQUIPMENT_STAGES.READY, EQUIPMENT_STAGES.PREPARING, EQUIPMENT_STAGES.ACTIVE): self.as_setGlowS(idx, CONSUMABLES_PANEL_SETTINGS.GLOW_ID_ORANGE) elif currStage == EQUIPMENT_STAGES.READY and prevStage == EQUIPMENT_STAGES.PREPARING: self.as_setEquipmentActivatedS(idx, False) return def _updateOptionalDeviceSlot(self, idx, isOn): pass def _showEquipmentGlow(self, equipmentIndex, glowType=CONSUMABLES_PANEL_SETTINGS.GLOW_ID_ORANGE): pass def _onPostMortemSwitched(self, noRespawnPossible, respawnAvailable): self._reset() def __onEquipmentReset(self): self.__resetEquipmentSlots() self.as_resetS(list()) def __getNewSlotIdx(self, startIdx=0, endIdx=_PANEL_MAX_LENGTH - 1): resultIdx = None for idx in range(startIdx, endIdx + 1): if self._mask & 1 << idx == 0: resultIdx = idx break return resultIdx def __resetShellSlots(self): for idx in range(self._AMMO_START_IDX, self._AMMO_END_IDX + 1): self._mask &= ~(1 << idx) self._cds[idx] = None return def __resetEquipmentSlots(self): for idx in self.__equipmentRange: self._mask &= ~(1 << idx) self._cds[idx] = None return def __onVehicleLootAction(self, state, _): if state != VEHICLE_VIEW_STATE.LOOT: return else: self.__quantityMap = [(numItems if numItems is not None else 0) for numItems in self.__quantityMap] vehStateCtrl = self.sessionProvider.shared.vehicleState if vehStateCtrl is not None: vehStateCtrl.onVehicleStateUpdated -= self.__onVehicleLootAction return
def visualizeShotPassion(self, shotPassionComponent, go): if self.__eventSubscriber is None: self.__eventSubscriber = EventsSubscriber() self.__eventSubscriber.subscribeToContextEvent(self.__guiSessionProvider.shared.vehicleState.onEquipmentComponentUpdated, self.__onEquipmentComponentUpdated, VehicleShotPassionComponent.EQUIPMENT_NAME) self.__launch(shotPassionComponent) return
class ShotPassionManager(CGF.ComponentManager): __guiSessionProvider = dependency.descriptor(IBattleSessionProvider) def __init__(self): super(ShotPassionManager, self).__init__() self.__eventSubscriber = None return def deactivate(self): if self.__eventSubscriber is not None: self.__eventSubscriber.unsubscribeFromAllEvents() self.__eventSubscriber = None return @onAddedQuery(VehicleShotPassionComponent, CGF.GameObject) def visualizeShotPassion(self, shotPassionComponent, go): if self.__eventSubscriber is None: self.__eventSubscriber = EventsSubscriber() self.__eventSubscriber.subscribeToContextEvent(self.__guiSessionProvider.shared.vehicleState.onEquipmentComponentUpdated, self.__onEquipmentComponentUpdated, VehicleShotPassionComponent.EQUIPMENT_NAME) self.__launch(shotPassionComponent) return def endShotPassion(self, vehicle): def postloadSetup(go): go.createComponent(GenericComponents.RedirectorComponent, vehicle.appearance.gameObject) if vehicle is not None and vehicle.isAlive() and vehicle.appearance: equipmentID = vehicles.g_cache.equipmentIDs().get(VehicleShotPassionComponent.EQUIPMENT_NAME) equipment = vehicles.g_cache.equipments()[equipmentID] CGF.loadGameObjectIntoHierarchy(equipment.posteffectPrefab, vehicle.appearance.partsGameObjects.getPartGameObject(TankNodeNames.GUN_INCLINATION, vehicle.appearance.gameObject.spaceID, vehicle.appearance.gameObject), Math.Vector3(0, 0, 0), postloadSetup) return def __launch(self, vehicleShotPassionComponent): def postloadSetup(go): shotPassionComponent = go.findComponentByType(ShotPassionComponent) stage = vehicleShotPassionComponent.getInfo().stage self.__setupVFX(shotPassionComponent.gunNode, stage) self.__setupVFX(shotPassionComponent.turretNode, stage) go.createComponent(GenericComponents.RemoveGoDelayedComponent, vehicleShotPassionComponent.endTime - BigWorld.serverTime()) appearance = vehicleShotPassionComponent.entity.appearance equipmentID = vehicles.g_cache.equipmentIDs().get(VehicleShotPassionComponent.EQUIPMENT_NAME) equipment = vehicles.g_cache.equipments()[equipmentID] loadAppearancePrefab(equipment.usagePrefab, appearance, postloadSetup) def __setupVFX(self, nodeGO, stage): nodeComponent = nodeGO.findComponentByType(ShotPassionNodeComponent) effectTemplate = nodeComponent.effectTemplate nodeGO.removeComponentByType(GenericComponents.AnimatorComponent) nodeGO.createComponent(GenericComponents.AnimatorComponent, effectTemplate.format(math_utils.clamp(0, nodeComponent.maxAnimationStage, stage)), 0, 1, -1, True, '') nodeGO.deactivate() nodeGO.activate() def __onEquipmentComponentUpdated(self, _, vehicleID, equipmentInfo): vehicle = BigWorld.entity(vehicleID) if equipmentInfo.endTime - BigWorld.serverTime() > 0: effectGO = self.getEffectGO(vehicle.entityGameObject) if not effectGO.isValid(): return shotPassionComponent = effectGO.findComponentByType(ShotPassionComponent) self.__setupVFX(shotPassionComponent.turretNode, equipmentInfo.stage) self.__setupVFX(shotPassionComponent.gunNode, equipmentInfo.stage) else: self.endShotPassion(vehicle) def getEffectGO(self, partGO): return CGF.HierarchyManager(partGO.spaceID).findFirstNode(partGO, BattleRoyaleEquipments.SHOT_PASSION) @onRemovedQuery(VehicleShotPassionComponent, CGF.GameObject, UpgradeInProgressComponent) def inBattleUpgradeCompleted(self, shotPassionComponent, gameObject, _): self.__launch(shotPassionComponent)
class BattleRoyalePage(BattleRoyalePageMeta, ISpawnListener): __PANELS_FOR_SHOW_HIDE = [ BATTLE_VIEW_ALIASES.CONSUMABLES_PANEL, BATTLE_VIEW_ALIASES.BATTLE_LEVEL_PANEL ] def __init__(self, components=None): if components is None: components = _BATTLE_ROYALE_CFG self.__selectSpawnToggling = set() self.__brSoundControl = None self.__isFullStatsShown = False self.__panelsIsVisible = False self.__es = EventsSubscriber() self.__isAllowToogleGuiVisible = False super(BattleRoyalePage, self).__init__(components, external=(crosshair.CrosshairPanelContainer, BattleRoyaleMarkersManager)) return def showSpawnPoints(self): visibleComponents = [BATTLE_VIEW_ALIASES.BR_SELECT_RESPAWN] if ARENA_BONUS_TYPE_CAPS.checkAny(BigWorld.player().arena.bonusType, ARENA_BONUS_TYPE_CAPS.SQUADS): visibleComponents.extend([ BATTLE_VIEW_ALIASES.BATTLE_TEAM_PANEL, BATTLE_VIEW_ALIASES.BATTLE_MESSENGER ]) if not self.__selectSpawnToggling: self.__selectSpawnToggling.update( set(self.as_getComponentsVisibilityS()) - set(visibleComponents)) self._setComponentsVisibility(visible=visibleComponents, hidden=self.__selectSpawnToggling) self.app.enterGuiControlMode(BATTLE_VIEW_ALIASES.BR_SELECT_RESPAWN) def closeSpawnPoints(self): self.__isAllowToogleGuiVisible = True if self.__selectSpawnToggling: self._setComponentsVisibility( visible=self.__selectSpawnToggling, hidden=[BATTLE_VIEW_ALIASES.BR_SELECT_RESPAWN]) self.__selectSpawnToggling.clear() self.app.leaveGuiControlMode(BATTLE_VIEW_ALIASES.BR_SELECT_RESPAWN) def isFullStatsShown(self): return self.__isFullStatsShown def _canShowPostmortemTips(self): if avatar_getter.isObserverSeesAll(): return False else: arenaDP = self.sessionProvider.getArenaDP() enemiesTeamCount = len({ vInfo.team for vInfo, _ in arenaDP.getActiveVehiclesGenerator() if vInfo.isAlive() }) bonusType = BigWorld.player().arenaBonusType isTournament = bonusType in ( ARENA_BONUS_TYPE.BATTLE_ROYALE_TRN_SOLO, ARENA_BONUS_TYPE.BATTLE_ROYALE_TRN_SQUAD) if enemiesTeamCount <= 1 or isTournament: postmortemPanel = self.getComponent( BATTLE_VIEW_ALIASES.POSTMORTEM_PANEL) if postmortemPanel is not None: postmortemPanel.as_setSpectatorPanelVisibleS(False) super(BattleRoyalePage, self).as_setPostmortemTipsVisibleS(True) return False return not self.__isFullStatsShown and super( BattleRoyalePage, self)._canShowPostmortemTips( ) and BigWorld.player().isFollowWinner() def _toggleFullStats(self, isShown, permanent=None, tabIndex=None): manager = self.app.containerManager if manager.isModalViewsIsExists(): return else: self.__isFullStatsShown = isShown if permanent is None: permanent = set() permanent.add('minimap') if isShown: progressionWindow = self.__getProgressionWindowCtrl() if progressionWindow: progressionWindow.closeWindow() if self.__selectSpawnToggling: return super(BattleRoyalePage, self)._toggleFullStats(isShown, permanent, tabIndex) return def _populate(self): super(BattleRoyalePage, self)._populate() progressionWindowCtrl = self.__getProgressionWindowCtrl() if progressionWindowCtrl: self.__es.subscribeToEvent(progressionWindowCtrl.onTriggered, self.__onConfWindowTriggered) spawnCtrl = self.sessionProvider.dynamic.spawn if spawnCtrl: spawnCtrl.addRuntimeView(self) self.sessionProvider.getCtx().setPlayerFullNameFormatter( BattleRoyalePlayerFullNameFormatter()) if avatar_getter.isObserverSeesAll(): self.__es.subscribeToEvent( avatar_getter.getInputHandler().onCameraChanged, self.__onCameraChanged) self.__brSoundControl = BRBattleSoundController() self.__brSoundControl.init() deathScreenCtrl = self.sessionProvider.dynamic.deathScreen if deathScreenCtrl: deathScreenCtrl.onShowDeathScreen += self.__onShowDeathScreen def _startBattleSession(self): super(BattleRoyalePage, self)._startBattleSession() vehStateCtrl = self.sessionProvider.shared.vehicleState if vehStateCtrl is not None: vehStateCtrl.onVehicleStateUpdated += self.__onVehicleStateUpdated ammoCtrl = self.sessionProvider.shared.ammo if ammoCtrl is not None: ammoCtrl.onGunSettingsSet += self.__onGunSettingsSet return def _stopBattleSession(self): super(BattleRoyalePage, self)._stopBattleSession() vehStateCtrl = self.sessionProvider.shared.vehicleState if vehStateCtrl is not None: vehStateCtrl.onVehicleStateUpdated -= self.__onVehicleStateUpdated ammoCtrl = self.sessionProvider.shared.ammo if ammoCtrl is not None: ammoCtrl.onGunSettingsSet -= self.__onGunSettingsSet return def _onRegisterFlashComponent(self, viewPy, alias): super(BattleRoyalePage, self)._onRegisterFlashComponent(viewPy, alias) if alias == BATTLE_VIEW_ALIASES.BR_SELECT_RESPAWN: self._setComponentsVisibility(hidden=[alias]) return if avatar_getter.isObserverSeesAll(): if alias == BATTLE_VIEW_ALIASES.BATTLE_MESSENGER: self._setComponentsVisibility(hidden=[alias]) elif alias == BATTLE_VIEW_ALIASES.PLAYERS_PANEL: self._setComponentsVisibility(hidden=[alias]) def _toggleGuiVisible(self): componentsVisibility = self.as_getComponentsVisibilityS() if BATTLE_VIEW_ALIASES.BR_SELECT_RESPAWN in componentsVisibility: return if not self.__isAllowToogleGuiVisible: return super(BattleRoyalePage, self)._toggleGuiVisible() def _dispose(self): deathScreenCtrl = self.sessionProvider.dynamic.deathScreen if deathScreenCtrl: deathScreenCtrl.onShowDeathScreen -= self.__onShowDeathScreen spawnCtrl = self.sessionProvider.dynamic.spawn if spawnCtrl: spawnCtrl.removeRuntimeView(self) if self.__brSoundControl is not None: self.__brSoundControl.destroy() self.__brSoundControl = None self.__selectSpawnToggling.clear() self.__es.unsubscribeFromAllEvents() super(BattleRoyalePage, self)._dispose() return def _switchToPostmortem(self): BigWorld.player().setIsObserver() def __onCameraChanged(self, ctrlMode, _=None): teamPanelAliases = (CTRL_MODE_NAME.POSTMORTEM, CTRL_MODE_NAME.VIDEO) if ctrlMode in teamPanelAliases: args = { 'hidden': {BATTLE_VIEW_ALIASES.BATTLE_TEAM_PANEL}, 'visible': {BATTLE_VIEW_ALIASES.PLAYERS_PANEL} } else: args = { 'hidden': {BATTLE_VIEW_ALIASES.PLAYERS_PANEL}, 'visible': {BATTLE_VIEW_ALIASES.BATTLE_TEAM_PANEL} } args['hidden' if ctrlMode == CTRL_MODE_NAME.VIDEO else 'visible'].add( BATTLE_VIEW_ALIASES.BATTLE_LEVEL_PANEL) self._setComponentsVisibility(**args) def __onConfWindowTriggered(self, isOpened): if isOpened: if not self.as_isComponentVisibleS(self._fullStatsAlias): self._fsToggling = set(self.as_getComponentsVisibilityS()) self._setComponentsVisibility(visible=[], hidden=self._fsToggling) elif self._fsToggling: self._setComponentsVisibility(visible=self._fsToggling, hidden=[]) def __getProgressionWindowCtrl(self): progression = self.sessionProvider.dynamic.progression return progression.getWindowCtrl() if progression else None def __onVehicleStateUpdated(self, state, value): if state == VEHICLE_VIEW_STATE.DEATHZONE_TIMER and value.level is None: vehicle = self.sessionProvider.shared.vehicleState.getControllingVehicle( ) isAlive = vehicle is not None and vehicle.isAlive() self.as_updateDamageScreenS(value.isCausingDamage and isAlive) elif state in (VEHICLE_VIEW_STATE.SWITCHING, VEHICLE_VIEW_STATE.DESTROYED, VEHICLE_VIEW_STATE.CREW_DEACTIVATED): self.as_updateDamageScreenS(False) vehicle = BigWorld.player().getVehicleAttached() if vehicle is None or not vehicle.isAlive() and BigWorld.player( ).isObserver(): if self.__panelsIsVisible: self._setComponentsVisibility( hidden=self.__PANELS_FOR_SHOW_HIDE) self.__panelsIsVisible = False elif not self.__panelsIsVisible: self._setComponentsVisibility(visible=self.__PANELS_FOR_SHOW_HIDE) self.__panelsIsVisible = True if vehicle and not vehicle.isAlive(): if avatar_getter.isBecomeObserverAfterDeath(): self._setComponentsVisibility(visible=[ BATTLE_VIEW_ALIASES.PLAYERS_PANEL, BATTLE_VIEW_ALIASES.CONSUMABLES_PANEL ]) BigWorld.player().setIsObserver() return def __onGunSettingsSet(self, _): progressionWindowCtrl = self.__getProgressionWindowCtrl() if progressionWindowCtrl and progressionWindowCtrl.isWindowOpened(): isDualGunVehicle = self.sessionProvider.getArenaDP( ).getVehicleInfo().vehicleType.isDualGunVehicle dualGunAlias = BATTLE_VIEW_ALIASES.DUAL_GUN_PANEL if not isDualGunVehicle: if dualGunAlias in self._fsToggling: self._fsToggling.remove(dualGunAlias) def __onShowDeathScreen(self): if self.as_isComponentVisibleS(self._fullStatsAlias): self._setComponentsVisibility( visible={self._fullStatsAlias}, hidden=[BATTLE_VIEW_ALIASES.BR_PLAYER_STATS_IN_BATTLE]) self._fsToggling.add(BATTLE_VIEW_ALIASES.BR_PLAYER_STATS_IN_BATTLE)