-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventHandler.cs
75 lines (63 loc) · 1.83 KB
/
EventHandler.cs
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
using Exiled.API.Features;
using Server = Exiled.Events.Handlers.Server;
using PlayerRoles;
using Features = Exiled.API.Features;
using Warhead = Exiled.Events.Handlers.Warhead;
namespace NukeRun
{
public class GenHandler
{
private readonly NukeRun hc;
public GenHandler(NukeRun pluginInstance)
{
hc = pluginInstance;
}
private bool EventEnabled;
public void Start()
{
Server.RoundStarted += OnRoundStart;
Warhead.Detonated += OnWarheadDetonate;
}
public void Stop()
{
Server.RoundStarted -= OnRoundStart;
Warhead.Detonated -= OnWarheadDetonate;
}
public void OnRoundStart()
{
if (UnityEngine.Random.Range(0, 100) <= hc.Config.EventChance)
{
Log.Info("Nuke-run event active");
EventEnabled = true;
}
else {
return;
}
RoundSummary.RoundLock = true;
Features.Warhead.DetonationTimer = hc.Config.DetonationTimer;
Features.Warhead.Start();
Features.Warhead.IsLocked = true;
foreach(Player p in Player.List)
{
p.Broadcast(10, "Nuke-run event. Escape the facility!");
if (p.Role == RoleTypeId.Tutorial)
{
continue;
}
p.Role.Set(RoleTypeId.ClassD);
foreach(ItemType i in hc.Config.StarterItems)
{
p.AddItem(i);
}
}
}
public void OnWarheadDetonate()
{
if (!EventEnabled)
{
return;
}
RoundSummary.RoundLock = false;
}
}
}