def WaitForSceneReady(self): scene = self.sceneManager.GetRegisteredScene('default') startTime = gametime.GetSimTime() while scene is None and startTime + SEC * 15 < gametime.GetSimTime(): uthread2.Sleep(0.25) if session.solarsystemid is None: raise InvalidClientStateError('Solarsystemid is None in session') scene = self.sceneManager.GetRegisteredScene('default') if scene is None: raise InvalidClientStateError('Failed to find the default space scene')
def UpdateLaunchTubeStateUI(self): tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID) self.UpdateStatusUI(tubeStatus) if tubeStatus.endTime: if tubeStatus.statusID in (TUBE_STATE_RECALLING, TUBE_STATE_LANDING): self.landingStrip.display = True self.scoopIcon.display = False elif tubeStatus.statusID == TUBE_STATE_LAUNCHING: self.launchingStrip.display = True self.launchIcon.display = False else: self.loadingGauge.display = True now = gametime.GetSimTime() duration = float(tubeStatus.endTime - tubeStatus.startTime) loadingProgress = max( 0.0, min(1.0, (now - tubeStatus.startTime) / duration)) self.loadingGauge.SetValue(loadingProgress, animate=False) remainingTime = tubeStatus.endTime - now remainingTimeSeconds = max(float(remainingTime) / SEC, 0.1) self.loadingGauge.SetValueTimed(1.0, remainingTimeSeconds) self.tubeStatusLabel.top = -2 else: self.loadingGauge.SetValue(0) self.loadingGauge.display = False self.landingStrip.display = False self.launchingStrip.display = False self.tubeStatusLabel.top = 0 if tubeStatus.statusID == TUBE_STATE_EMPTY: self.emptyTubeIcon.display = True self.scoopIcon.display = False self.squadronNumber.SetColor(True) else: self.emptyTubeIcon.display = False self.squadronNumber.SetColor(False)
def PlayResultEffects(self, sitesOrdered): self.LogInfo('PlayResultEffects') scene = self.sceneManager.GetRegisteredScene('default') soundLocators = [] invAU = 1.0 / AU vectorCurve = trinity.TriVectorCurve() vectorCurve.value = (invAU, invAU, invAU) self.EnableMouseTracking() try: startTimeSec = float(self.systemReadyTime + SWEEP_START_GRACE_TIME) / SEC lastPlayTimeSec = startTimeSec for delaySec, siteData in sitesOrdered: locatorData = self.siteController.spaceLocations.GetBySiteID( siteData.siteID) if IsSiteInstantlyAccessible(siteData): locatorData.bracket.state = uiconst.UI_NORMAL locatorData.bracket.DoEntryAnimation(enable=True) continue playTimeSec = startTimeSec + delaySec sleepTimeSec = playTimeSec - lastPlayTimeSec lastPlayTimeSec = playTimeSec self.ShowSiteDuringSweep(locatorData, scene, siteData, sleepTimeSec, soundLocators, vectorCurve) currentTimeSec = gametime.GetSimTime() endTimeSec = startTimeSec + SWEEP_CYCLE_TIME_SEC timeLeftSec = endTimeSec - currentTimeSec if timeLeftSec > 0: uthread2.SleepSim(timeLeftSec) self.audio.SendUIEvent('ui_scanner_stop') self.sensorSweepActive = False if not self.IsOverlayActive(): self._Hide() else: for locatorData in self.siteController.spaceLocations.IterLocations( ): if not IsSiteInstantlyAccessible(locatorData.siteData): locatorData.bracket.DoEnableAnimation() locatorData.bracket.state = uiconst.UI_NORMAL uthread2.SleepSim(1.0) self.DoScanEnded(sitesOrdered) except (InvalidClientStateError, KeyError): pass finally: self.sensorSweepActive = False if scene is not None: for tr in soundLocators: if tr in scene.objects: scene.objects.remove(tr) self.audio.SendUIEvent('ui_scanner_stop') self.SendMessage( overlayConst.MESSAGE_ON_SENSOR_OVERLAY_SWEEP_ENDED) self.UpdateVisibleSites()
def _CalculateCurrentScore(self): if self._IsScoring(): timeSinceLastScoreUpdate = gametime.GetSimTime( ) - self.lastUpdatedScoreTime scoringDuration = timeSinceLastScoreUpdate / self.captureTime / float( SEC) score = self.scoreAtLastUpdateTime + scoringDuration * self.scoringRate score = min(1.0, max(score, 0.0)) elif self.scoreAtLastUpdateTime is not None: score = self.scoreAtLastUpdateTime else: score = 0 return score
def _UpdateLoopContent(self): if not self.bracket or self.bracket.destroyed or not self.sublabelInfo: self._KillBracketSubLabel() return False statusText, captureTimestamp = self.sublabelInfo if captureTimestamp is not None: now = gametime.GetSimTime() timeUntil = max(0L, captureTimestamp - now) timeUntilText = self._FormatCountdown(timeUntil) text = ' - '.join(filter(None, [statusText, timeUntilText])) else: text = statusText self.bracket.UpdateSubLabelIfNeeded(text) return True
def OnFighterTubeStateUpdate(self, tubeFlagID): if tubeFlagID == self.tubeFlagID: tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID) self.squadronCont.SetSquadronAction(self.tubeFlagID) if tubeStatus.statusID == TUBE_STATE_EMPTY: self.ShowEmpty() else: self.HideEmpty() if tubeStatus.endTime: self.squadronCont.loadingGauge.display = True now = gametime.GetSimTime() duration = float(tubeStatus.endTime - tubeStatus.startTime) loadingProgress = max( 0.0, min(1.0, (now - tubeStatus.startTime) / duration)) self.squadronCont.loadingGauge.SetValue(loadingProgress, animate=False) remainingTime = tubeStatus.endTime - now remainingTimeSeconds = max(float(remainingTime) / SEC, 0.1) self.squadronCont.loadingGauge.SetValueTimed( 1.0, remainingTimeSeconds) else: self.squadronCont.loadingGauge.display = False
def GetTimeNow(self): return gametime.GetSimTime()
def _InitiateSensorSweep(self): self.LogInfo('Ballpark is ready so we start the sweep timer') self.systemReadyTime = gametime.GetSimTime() self.StartSensorSweep()
def GetAbilityCooldown(self, fighterID, abilitySlotID): cooldown = self.abilityCooldowns.get((fighterID, abilitySlotID), None) if cooldown is not None: startTime, endTime = cooldown if startTime <= gametime.GetSimTime() < endTime: return (startTime, endTime)