def __init__(self): super(VehicleStateController, self).__init__() self.__eManager = Event.EventManager() self.onVehicleStateUpdated = Event.Event(self.__eManager) self.onVehicleControlling = Event.Event(self.__eManager) self.onPostMortemSwitched = Event.Event(self.__eManager) self.onRespawnBaseMoving = Event.Event(self.__eManager) self.__waitingTI = TimeInterval(VEHICLE_WAINING_INTERVAL, self, '_waiting') self.__updateTI = TimeInterval(VEHICLE_UPDATE_INTERVAL, self, '_update') self.__vehicleID = 0 self.__updater = _PlayerVehicleUpdater() self.__isRqToSwitch = False
def __init__(self, parentObj, totalTime, timeLeft, siegeState, engineState): super(_PythonUpdater, self).__init__(parentObj, totalTime, timeLeft, siegeState, engineState) self._timeInterval = TimeInterval(0.05, self, '_tick') self._startTime = BigWorld.serverTime() self._finishTime = self._startTime + timeLeft
def start(self): self._interval = TimeInterval(_TARGET_UPDATE_INTERVAL, self, '_update') ctrl = g_sessionProvider.shared.crosshair raise ctrl is not None or AssertionError( 'Crosshair controller is not found') ctrl.onCrosshairViewChanged += self._onCrosshairViewChanged return
def __init__(self, updater, vehicle): """ Constructor. Initializes internal variables based on vehicle state. :param updater: An instance of _VehicleUpdater class, that creates this handler. :param vehicle: Vehicle to be tracked. :return: """ super(_EngineStateHandler, self).__init__(updater) if vehicle is not None and vehicle.appearance is not None: self.__gear = vehicle.appearance.gear else: self.__gear = _STOPPED_ENGINE_GEAR self.__vehMoveAnimTimer = TimeInterval(_VEHICLE_ANIM_DURATION, self, '_stopVehMoveAnim') self.__engineStartAnimTimer = TimeInterval(_VEHICLE_ANIM_DURATION, self, '_stopEngineStartAnim') return
def startTimer(self, device, duration): self.TIMERS[device]['duration'] = duration if self.TIMERS[device]['timer'] is not None: return self.TIMERS[device]['timer'] = TimeInterval(0.1, self, '{}OnTimer'.format(device)) self.TIMERS[device]['timer'].start() as_event(EVENTS[device])
def start(self): """ Sets up and starts the timer to invalidate handlers. """ if self.__updateTI is None: self.__updateTI = TimeInterval(VEHICLE_UPDATE_INTERVAL, self, '_update') self.__updateTI.start() return
def updateBlur(self): if self.hotKeyDown or (player().getVehicleAttached() is None): return if self.timer is not None and self.timer.isStarted(): self.timer.stop() self.timer = None self.timer = TimeInterval(infoPanelConfig['delay'], self, 'hide') self.timer.start()
def __init__(self, panel, typeID, viewID, totalTime): super(_PythonTimer, self).__init__(panel, typeID, viewID, totalTime) self._timeInterval = TimeInterval(1.0, self, '_tick') self._startTime = BigWorld.serverTime() if totalTime: self._finishTime = self._startTime + totalTime else: self._finishTime = 0
def output(self): if config.get(self.S_SHOW_HIT_NO_DAMAGE) or data.data['isDamage']: self.groupDamages() if self.strLastHit: if (self.timerLastHit is not None) and self.timerLastHit.isStarted: self.timerLastHit.stop() timeDisplayLastHit = float(parser(config.get(self.S_TIME_DISPLAY_LAST_HIT))) self.timerLastHit = TimeInterval(timeDisplayLastHit, self, 'hideLastHit') self.timerLastHit.start() as_event('ON_LAST_HIT')
def _startTick(self): if self._totalTime: timeLeft = max(0, self._finishTime - BigWorld.serverTime()) if timeLeft: self._setViewSnapshot(timeLeft) self._timeInterval = TimeInterval(self.__interval, self, '_tick') firstShortPeriod = float(self._totalTime) % self.__interval if round(firstShortPeriod, 4) > 0.0: self.__short1stPeriodCbId = BigWorld.callback(firstShortPeriod, self.__onShort1stPeriodFinished) else: self._timeInterval.restart()
def addTimer(self, device, duration): if device in self.timers: self.timers[device]['timer'].stop() self.timers.update({ device: { 'duration': duration, 'timer': TimeInterval(0.1, self, '{}OnTimer'.format(device)) } }) self.timers[device]['timer'].start() self.eventHandler(device)
def __init__(self, panel, typeID, viewID, totalTime, finishTime, startTime=None, interval=1.0, **kwargs): super(PythonTimer, self).__init__(panel, typeID, viewID, totalTime, finishTime, startTime, **kwargs) self._timeInterval = TimeInterval(interval, self, '_tick')
def updateLastHit(self): timeDisplayLastHit = float( config.get('damageLog/lastHit/timeDisplayLastHit')) self.lastHit = self.parser( config.get('damageLog/lastHit/formatLastHit')) #, True) if self.lastHit: if (self.timerLastHit is not None) and (self.timerLastHit.isStarted): self.timerLastHit.stop() self.timerLastHit = TimeInterval(timeDisplayLastHit, self, 'hideLastHit') self.timerLastHit.start() as_event('ON_LAST_HIT')
def output(self): macroes = None if (((data.data['attackReasonID'] in [2, 3]) and config.get(self.section + 'groupDamagesFromRamming_WorldCollision')) or ((data.data['attackReasonID'] == 1) and config.get(self.section + 'groupDamagesFromFire'))): dataLog = data.data.copy() attackerID = data.data['attackerID'] attackReasonID = data.data['attackReasonID'] if attackerID in self.dictVehicle: if (attackReasonID in self.dictVehicle[attackerID] and ('time' in self.dictVehicle[attackerID][attackReasonID]) and ('damage' in self.dictVehicle[attackerID][attackReasonID]) and ((BigWorld.serverTime() - self.dictVehicle[attackerID][attackReasonID]['time']) < 1)): self.dictVehicle[attackerID][attackReasonID]['time'] = BigWorld.serverTime() self.dictVehicle[attackerID][attackReasonID]['damage'] += data.data['damage'] key = self.dictVehicle[attackerID][attackReasonID] dataLog['damage'] = key['damage'] dataLog['dmgRatio'] = dataLog['damage'] * 100 // data.data['maxHealth'] if (attackReasonID == 1) and (key['beginFire'] is not None): dataLog['fireDuration'] = BigWorld.time() - key['beginFire'] else: dataLog['fireDuration'] = None else: self.dictVehicle[attackerID][attackReasonID] = {'time': BigWorld.serverTime(), 'damage': data.data['damage'], 'beginFire': beginFire if attackReasonID == 1 else None} dataLog['fireDuration'] = BigWorld.time() - beginFire if attackReasonID == 1 else None else: self.dictVehicle[attackerID] = {} self.dictVehicle[attackerID][attackReasonID] = {'time': BigWorld.serverTime(), 'damage': data.data['damage'], 'beginFire': beginFire if attackReasonID == 1 else None} dataLog['fireDuration'] = BigWorld.time() - beginFire if attackReasonID == 1 else None macroes = getValueMacroes(self.section, dataLog) self.strLastHit = parser(config.get(self.section + 'formatLastHit'), macroes) else: if config.get(self.section + 'showHitNoDamage') or data.data['isDamage']: macroes = getValueMacroes(self.section, data.data) self.strLastHit = parser(config.get(self.section + 'formatLastHit'), macroes) else: self.strLastHit = '' if self.strLastHit: if macroes is None: macroes = getValueMacroes(self.section, data.data) if (self.timerLastHit is not None) and self.timerLastHit.isStarted: self.timerLastHit.stop() timeDisplayLastHit = float(parser(config.get(self.section + 'timeDisplayLastHit'), macroes)) self.timerLastHit = TimeInterval(timeDisplayLastHit, self, 'hideLastHit') self.timerLastHit.start() self.shadow = shadow_value(self.section, macroes) as_event('ON_LAST_HIT') return
def __init__(self): super(VehicleStateController, self).__init__() self.__eManager = Event.EventManager() self.onVehicleStateUpdated = Event.Event(self.__eManager) self.onVehicleControlling = Event.Event(self.__eManager) self.onPostMortemSwitched = Event.Event(self.__eManager) self.onRespawnBaseMoving = Event.Event(self.__eManager) self.__cachedStateValues = {} self.__waitingTI = TimeInterval(VEHICLE_WAINING_INTERVAL, self, '_waiting') self.__vehicleID = 0 self.__updater = None self.__isRqToSwitch = False self.__isInPostmortem = False return
def __init__(self): """ Constructor. Initializes internal variables. """ super(VehicleStateController, self).__init__() self.__eManager = Event.EventManager() self.onVehicleStateUpdated = Event.Event(self.__eManager) self.onVehicleControlling = Event.Event(self.__eManager) self.onPostMortemSwitched = Event.Event(self.__eManager) self.onRespawnBaseMoving = Event.Event(self.__eManager) self.__waitingTI = TimeInterval(VEHICLE_WAINING_INTERVAL, self, '_waiting') self.__vehicleID = 0 self.__updater = None self.__isRqToSwitch = False self.__isInPostmortem = False return
def start(self): if self._gui is None: return else: if self._updateTI: self._updateTI.stop() for markerID in self._markers.iterkeys(): if markerID not in self._attachGUIToMarkersCallback: self._attachGUIToMarkersCallback[ markerID] = BigWorld.callback( 0.0, partial(self._attachGUIToMarkers, markerID=markerID)) self._updateTI = TimeInterval(self._UPDATE_TICK_LENGTH, self, '_tickUpdate') self._updateTI.start() return
def __init__(self, viewObject, typeID, viewID, totalTime, finishTime, startTime=None, interval=1.0, secondInRow=False, **kwargs): super(PythonTimer, self).__init__(viewObject, typeID, viewID, totalTime, finishTime, startTime, secondInRow=secondInRow, **kwargs) self._timeInterval = TimeInterval(interval, self, '_tick')
def currentTimeReload(self): self.macros['timer'] = round(self.finishTime - BigWorld.serverTime(), 1) self.config['timeTextAfterReload'] = float( config.get('damageLog/timeReload/timeTextAfterReload')) if self.macros['timer'] > 0: self.currentTime = self.parser( config.get('damageLog/timeReload/formatTimer')) else: self.timerReloadAttacker.stop() if self.config['timeTextAfterReload'] > 0: self.timerReloadAttacker = TimeInterval( self.config['timeTextAfterReload'], self, 'afterTimerReload') self.currentTime = self.parser( config.get('damageLog/timeReload/formatTimerAfterReload')) self.timerReloadAttacker.start() else: self.currentTime = '' as_event('ON_TIMER_RELOAD')
def timeReload(self): reload_orig = self.data['typeDescriptor'].gun['reloadTime'] crew = 0.94 if self.data['typeDescriptor'].miscAttrs[ 'crewLevelIncrease'] != 0 else 1 if (self.data['typeDescriptor'].gun['clip'][0] == 1) and ( self.data['typeDescriptor'].miscAttrs['gunReloadTimeFactor'] != 0): rammer = self.data['typeDescriptor'].miscAttrs[ 'gunReloadTimeFactor'] else: rammer = 1 self.macros['timer'] = round(reload_orig * crew * rammer, 1) self.currentTime = self.parser( config.get('damageLog/timeReload/formatTimer')) as_event('ON_TIMER_RELOAD') self.finishTime = self.macros['timer'] + BigWorld.serverTime() if (self.timerReloadAttacker is not None) and (self.timerReloadAttacker.isStarted): self.timerReloadAttacker.stop() self.timerReloadAttacker = TimeInterval(0.1, self, 'currentTimeReload') self.timerReloadAttacker.start()
def __init__(self, config): self.__config = config self.__panels = [] self.__isSetHandler = False self.__visible = False self.__crosshairPosition = [0, 0] self.__onShoot = None self.__onShot = None self.__onShotResult = None self.__intervalHandlers = Event() self.__eventHandlers = Event() self.__keyHandlers = {} interval = config['common']['updateInterval'] self.__timeInterval = TimeInterval(interval, self, 'onWatchStats') g_eventBus.addListener(events.AppLifeCycleEvent.INITIALIZED, self.onAppInitialized) g_eventBus.addListener(events.AppLifeCycleEvent.DESTROYED, self.onAppDestroyed) appLoader = dependency.instance(IAppLoader) appLoader.onGUISpaceEntered += self.onGUISpaceEntered appLoader.onGUISpaceLeft += self.onGUISpaceLeft g_statsCollector.eventHandlers.clear()
def start(self): self.__timeInterval = TimeInterval(self.__UPDATE_INTERVAL, self, '_DebugPanel__update') self.__timeInterval.start() self.__update()
def startControl(self): self._timeInterval = TimeInterval(_UPDATE_INTERVAL, self, '_update') self._timeInterval.start()
def _createTimer(self, nextActionTime): self._nextTime = nextActionTime self._timer = TimeInterval(1, self, '_updateTime') self._timer.start()
def start(self): if self.__updateTI is None: self.__updateTI = TimeInterval(VEHICLE_UPDATE_INTERVAL, self, '_update') self.__updateTI.start() return
def __init__(self, panel, typeID, viewID, totalTime, startTime = None): super(PythonTimer, self).__init__(panel, typeID, viewID, totalTime, startTime) self._timeInterval = TimeInterval(1.0, self, '_tick')
def start(self): self._interval = TimeInterval(_TARGET_UPDATE_INTERVAL, self, '_update') ctrl = self.sessionProvider.shared.crosshair ctrl.onCrosshairViewChanged += self._onCrosshairViewChanged