/// <summary> /// Updates a one tick. /// </summary> public void UpdateOneSubTick() { LogicTime time = this._level.GetLogicTime(); if (this._state != 2 || !this._battleOver) { this.SubTick(); if (time.IsFullTick()) { this._level.Tick(); } } if (this._state == 2 || this._state == 3 || this._state == 5) { if (this._battleTimer != null && this._battleTimer.GetRemainingSeconds(time) == 0 || this._level.GetBattleEndPending()) { this.SetBattleOver(); } } time.IncreaseTick(); }
public void Update(int ms) { if (this.m_initialized && !this.m_ended) { int totalSubTick = LogicTime.GetMSInTicks(ms); if (this.m_clientSubTick < this.m_serverSubTick + totalSubTick) { if (!this.m_end) { return; } totalSubTick = this.m_clientSubTick - this.m_serverSubTick; this.m_ended = true; } for (int i = 0; i < 2; i++) { Dictionary <long, LiveReplaySpectatorEntry> spectators = this.m_spectatorList[i]; if (spectators.Count >= 1) { LiveReplayDataMessage liveReplayDataMessage = new LiveReplayDataMessage(); liveReplayDataMessage.SetServerSubTick(this.m_serverSubTick + totalSubTick); liveReplayDataMessage.SetCommands(this.GetCommands(this.m_serverSubTick, this.m_serverSubTick + totalSubTick)); if (i == 0) { liveReplayDataMessage.SetViewerCount(this.m_spectatorList[0].Count); liveReplayDataMessage.SetEnemyViewerCount(this.m_spectatorList[1].Count); } else { liveReplayDataMessage.SetViewerCount(this.m_spectatorList[1].Count); liveReplayDataMessage.SetEnemyViewerCount(this.m_spectatorList[0].Count); } foreach (LiveReplaySpectatorEntry entry in spectators.Values) { entry.SendPiranhaMessageToProxy(liveReplayDataMessage); } if (this.m_ended) { foreach (LiveReplaySpectatorEntry entry in spectators.Values) { entry.SendPiranhaMessageToProxy(new LiveReplayEndMessage()); } } } } this.m_serverSubTick += totalSubTick; } }
public static PoseCredentials CreateCredentials(long userNo, int serviceRoleType) { var newCredentials = new PoseCredentials(); newCredentials._userNo = userNo; newCredentials._serviceRoleType = serviceRoleType; newCredentials._expireTime = LogicTime.GetUnixTimeNow(DateTime.UtcNow.AddMilliseconds(TOKEN_EXPIRE_IN)); return(newCredentials); }
/// <summary> /// Gets the remaining guard time. /// </summary> public int GetGuardRemainingSeconds() { int startTime = this._startGuardTime - this._level.GetLogicTime(); if (startTime <= 0) { startTime = 0; } return(LogicMath.Max(LogicTime.GetTicksInSeconds(this._guardTime + startTime), 0)); }
public PoseCredentials CheckCredentialValid() { PoseCredentials credentials = ServerContext.Current.DecryptCredentials(); credentials.IsAuthenticated = false; if (credentials != PoseCredentials.Default && LogicTime.FromUnixTimeStamp(credentials.ExpireTime) > DateTime.UtcNow) { credentials.IsAuthenticated = true; } return(credentials); }
public void SetShieldRemainingSeconds(int secs) { this.m_shieldTime = LogicTime.GetSecondsInTicks(secs) + this.m_level.GetLogicTime().GetTick(); int logicTime = this.m_level.GetLogicTime().GetTick(); int startGuardTime = this.m_shieldTime; if (this.m_shieldTime < logicTime) { startGuardTime = logicTime; } this.m_startGuardTime = startGuardTime; }
/// <summary> /// Sets the guard remaining seconds. /// </summary> public void SetGuardRemainingSeconds(int secs) { this._guardTime = LogicTime.GetSecondsInTicks(secs); int logicTime = this._level.GetLogicTime(); int startGuardTime = logicTime; if (this._shieldTime >= logicTime) { startGuardTime = this._shieldTime; } this._startGuardTime = startGuardTime; }
public LogicCooldown(int targetGlobalId, int cooldownSecs) { this.m_targetGlobalId = targetGlobalId; this.m_cooldownTime = LogicTime.GetCooldownSecondsInTicks(cooldownSecs); }
/// <summary> /// Loads the home state. /// </summary> public void LoadHomeState(LogicClientHome home, LogicAvatar homeOwnerAvatar, int currentTimestamp, int secondsSinceLastSave, int secondsSinceLastMaintenance) { if (home != null) { this._state = 1; if (LogicDataTables.GetGlobals().StartInLastUsedVillage()) { int lastUsedVillage = homeOwnerAvatar.GetVillageToGoTo(); if (!this._level.GetMissionManager().HasTravel(homeOwnerAvatar)) { lastUsedVillage = 0; } if (lastUsedVillage < 0) { Debugger.Warning("VillageToGoTo<0"); } else { if (lastUsedVillage > 1) { Debugger.Warning("VillageToGoTo too big"); } else { this._level.SetVillageType(lastUsedVillage); } } } this._secondsSinceLastMaintenance = secondsSinceLastMaintenance; this._currentTimestamp = currentTimestamp; this._configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON())); this._calendar.Load(home.GetCalendarJSON(), currentTimestamp); if (this._battleTimer != null) { this._battleTimer.Destruct(); this._battleTimer = null; } this._level.SetHome(home, true); this._level.SetHomeOwnerAvatar(homeOwnerAvatar); this._level.FastForwardTime(secondsSinceLastSave); homeOwnerAvatar.SetLevel(this._level); this._level.LoadingFinished(); this._shieldTime = LogicTime.GetSecondsInTicks(home.GetShieldDurationSeconds()); this._guardTime = LogicTime.GetSecondsInTicks(home.GetGuardDurationSeconds()); this._maintenanceTime = LogicTime.GetSecondsInTicks(home.GetNextMaintenanceSeconds()); int logicTime = this._level.GetLogicTime(); int startGuardTime = logicTime; if (this._shieldTime >= logicTime) { startGuardTime = this._shieldTime; } this._startGuardTime = startGuardTime; if (LogicDataTables.GetGlobals().UseVillageObjects()) { this._level.LoadVillageObjects(); } } }
/// <summary> /// Sets the maintenance remaining seconds. /// </summary> public void SetMaintenanceRemainingSeconds(int secs) { this._maintenanceTime = LogicTime.GetSecondsInTicks(secs) + this._level.GetLogicTime(); }
/// <summary> /// Gets the remaining shield time. /// </summary> public int GetShieldRemainingSeconds() { return(LogicMath.Max(LogicTime.GetTicksInSeconds(this._shieldTime - this._level.GetLogicTime()), 0)); }
public void OnClientTurnReceived(int subTick, int checksum, LogicArrayList <LogicCommand> commands) { if (this.m_destructed || this.m_logicGameMode.GetState() == 4 || this.m_logicGameMode.GetState() == 5) { return; } int currentTimestamp = TimeUtil.GetTimestamp(); int logicTimestamp = this.m_logicGameMode.GetStartTime() + LogicTime.GetTicksInSeconds(subTick); if (currentTimestamp + 1 >= logicTimestamp) { if (commands != null) { this.m_serverCommandStorage.CheckExecutableServerCommands(subTick, commands); for (int i = 0; i < commands.Size(); i++) { this.m_logicGameMode.GetCommandManager().AddCommand(commands[i]); } } int previousSubTick = this.m_logicGameMode.GetLevel().GetLogicTime().GetTick(); try { this.m_logicWatch.Start(); for (int i = 0, count = subTick - previousSubTick; i < count; i++) { this.m_logicGameMode.UpdateOneSubTick(); if (this.m_logicWatch.ElapsedMilliseconds >= GameMode.MAX_LOGIC_LOOP_TIME) { Logging.Error(string.Format("GameMode.onClientTurnReceived: logic update stopped because it took too long. ({0}ms for {1} updates)", this.m_logicWatch.ElapsedMilliseconds, i)); break; } } GameModeClusterManager.ReportLogicUpdateSpeed(this.m_logicWatch.ElapsedMilliseconds); this.m_logicWatch.Reset(); } catch (LogicException exception) { Logging.Error("GameMode.onClientTurnReceived: logic exception thrown: " + exception + " (acc id: " + (long)this.m_session.AccountId + ")"); ServerErrorMessage serverErrorMessage = new ServerErrorMessage(); serverErrorMessage.SetErrorMessage(exception.Message); this.m_session.SendPiranhaMessage(serverErrorMessage, 1); this.m_session.SendMessage(new StopSessionMessage(), 1); } catch (Exception exception) { Logging.Error("GameMode.onClientTurnReceived: exception thrown: " + exception + " (acc id: " + (long)this.m_session.AccountId + ")"); this.m_session.SendMessage(new StopSessionMessage(), 1); } this.CheckChecksum(checksum); if (this.m_avatarChangeListener != null) { this.SaveState(); } if (this.m_liveReplayId != null) { this.UpdateLiveReplay(subTick, commands); } if (this.m_logicGameMode.IsBattleOver()) { this.m_shouldDestruct = true; } if (this.m_shouldDestruct) { this.m_session.DestructGameMode(); } } else { this.m_session.SendMessage(new StopSessionMessage(), 1); } }
public void SetPersonalBreakCooldownSeconds(int secs) { this.m_personalBreakTime = LogicTime.GetSecondsInTicks(secs) + this.m_level.GetLogicTime().GetTick(); }
public int GetPersonalBreakCooldownSeconds() { return(LogicMath.Max(LogicTime.GetTicksInSeconds(this.m_personalBreakTime - this.m_level.GetLogicTime().GetTick()), 0)); }
public void FastForwardTime(int secs) { this.m_cooldownTime = LogicMath.Max(this.m_cooldownTime - LogicTime.GetCooldownSecondsInTicks(secs), 0); }
/// <summary> /// Gets the remaining guard time. /// </summary> public int GetMaintenanceRemainingSeconds() { return(LogicMath.Max(LogicTime.GetTicksInSeconds(this._maintenanceTime - this._level.GetLogicTime()), 0)); }
public int GetCooldownSeconds() { return(LogicTime.GetCooldownTicksInSeconds(this.m_cooldownTime)); }
/// <summary> /// Initializes a new instance of the <see cref="LogicTeamGoalTimer"/> class. /// </summary> internal LogicTeamGoalTimer(Alliance alliance) { this.Alliance = alliance; this.Time = new LogicTime(); this.Timer = new LogicTimer(this.Time); }