public async Task Stop() { CommandWindow.Log("Stopping round"); RoundManager.Broadcast("Round has ended."); RoundTime = 600; State = RoundState.INTERMISSION; await Task.Delay(6000); Players.ToList().ForEach(p => { if (p.Status == PlayerStatus.ALIVE) { p.ReviveUnsafe(); TTTPlayer.ClearInventoryUnsafe(PlayerTool.getSteamPlayer(p.SteamID)); } }); await Task.Delay(6000); State = RoundState.SETUP; LevelManager.ClearBarricadesUnsafe(); C4Manager.ClearC4(); TrackerGunManager.ClearTrackedPlayers(); }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously private async Task RoundTimeTick() { if (GetState() == RoundState.SETUP && GetAllPlayers().Count >= Main.Config.MinimumPlayers) { CommandWindow.Log("Enough players, attempting start"); StartRound(); } if (GetState() == RoundState.LIVE) { Round.Players.ToList().ForEach(p => InterfaceManager.SendUIEffectTextUnsafe(8490, p.SteamID, true, "TimerValue", ParseTime(Round.RoundTime))); Round.RoundTime--; if (GetAlivePlayersWithRole(PlayerRole.TRAITOR).Count == 0) { CommandWindow.Log("Innocents win"); Round.Players.ToList().ForEach(p => Task.Run(async() => await InterfaceManager.SendBannerMessage(p.SteamID, 8493, "Innocents win!", 6000, true))); await Round.Stop(); return; } if (GetAlivePlayersWithRole(PlayerRole.DETECTIVE).Count == 0 && RoundManager.GetAlivePlayersWithRole(PlayerRole.INNOCENT).Count == 0) { CommandWindow.Log("Traitors win"); Round.Players.ToList().ForEach(p => Task.Run(async() => await InterfaceManager.SendBannerMessage(p.SteamID, 8492, "Traitors win!", 6000, true))); await Round.Stop(); return; } } }
public async Task Start() { try { CommandWindow.Log("Warmup Starting"); RoundManager.Broadcast("Warmup Starting"); State = RoundState.WARMUP; LevelManager.RespawnItems(); Players.ToList().ForEach(p => InterfaceManager.ClearAllUI(p.SteamID)); await Task.Delay(6000); Players.ToList().ForEach(p => { p.SetStatus(PlayerStatus.ALIVE); p.TeleportToMapUnsafe(); TTTPlayer.ClearInventoryUnsafe(PlayerTool.getSteamPlayer(p.SteamID)); }); await Task.Delay(15000); CommandWindow.Log("Round is live"); RoundManager.Broadcast("The round has started."); RoleManager.GeneratePlayerRoles(); Players.ToList().ForEach(p => { if (p.GetRole() == PlayerRole.TRAITOR || p.GetRole() == PlayerRole.DETECTIVE) { p.SetCredits(2); } }); State = RoundState.LIVE; } catch (Exception ex) { CommandWindow.Log(ex); } }