This repository was archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHandler.cs
More file actions
82 lines (70 loc) · 2.92 KB
/
Handler.cs
File metadata and controls
82 lines (70 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using Exiled.Events.EventArgs.Server;
namespace LobbySystem
{
using Exiled.API.Features;
using Exiled.Events.EventArgs.Player;
using UnityEngine;
using MEC;
using PlayerRoles;
using Exiled.API.Enums;
public class Handler
{
private static readonly Config config = Plugin.Instance.Config;
private static Vector3 SpawnPosition =>
Plugin.Instance.Config.SpawnRoom == RoomType.Unknown ? Plugin.Instance.Config.SpawnPosition : Room.Get(Plugin.Instance.Config.SpawnRoom).Position + Vector3.up;
public void OnWaitingForPlayers()
{
GameObject.Find("StartRound").transform.localScale = Vector3.zero;
Timing.RunCoroutine(Lobby());
}
public void OnVerified(VerifiedEventArgs ev)
{
if (!Round.IsLobby) return;
ev.Player.Role.Set(RoleTypeId.Tutorial);
ev.Player.Teleport(SpawnPosition);
}
public void OnChoosingStartTeamQueue(ChoosingStartTeamQueueEventArgs ev)
{
foreach (Player player in Player.List.Where(p => p.IsAlive))
player.Role.Set(RoleTypeId.Spectator);
}
private IEnumerator<float> Lobby()
{
double countdown = Plugin.Instance.Config.LobbyTime;
while (Round.IsLobby)
{
string status;
if (Round.IsLobbyLocked)
{
status = config.PausedStatus;
}
else if (Player.List.Count(p => !p.IsOverwatchEnabled) < Plugin.Instance.Config.MinimumPlayers)
{
countdown = Plugin.Instance.Config.LobbyTime;
status = config.WaitingStatus;
}
else
{
countdown--;
status = config.StartingStatus.Replace("%countdown%", countdown.ToString());
}
string text = config.TextShown
.Replace("%status%", status)
.Replace("%playercount%", Player.List.Count(p => p.IsTutorial).ToString())
.Replace("%maxplayers%", Server.MaxPlayerCount.ToString());
if (config.UseHints)
Map.ShowHint(text, 1);
else
Map.Broadcast(1, text, default, true);
if (countdown == 0)
{
foreach (Player player in Player.List.Where(p => p.IsAlive))
player.Role.Set(RoleTypeId.Spectator);
Round.Start();
yield break;
}
yield return Timing.WaitForSeconds(1);
}
}
}
}