This repository has been archived by the owner on Mar 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
EventHandlers.cs
72 lines (67 loc) · 1.98 KB
/
EventHandlers.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
using Exiled.API.Features;
using Exiled.Events.EventArgs;
using Exiled.API.Enums;
using System.Linq;
using MEC;
namespace XPSystem
{
class EventHandlers
{
public void OnJoined(VerifiedEventArgs ev)
{
if (ev.Player.DoNotTrack)
{
ev.Player.OpenReportWindow(Main.Instance.Config.DNTHint);
return;
}
PlayerLog log = new PlayerLog()
{
LVL = 0,
XP = 0
};
Main.players[ev.Player.UserId] = log;
Timing.CallDelayed(0.15f, () => API.EvaluateRank(ev.Player, log));
}
public void OnKill(DyingEventArgs ev)
{
if (ev.Target == null)
{
return;
}
Player killer = ev.Handler.Type == DamageType.PocketDimension ? Player.Get(RoleType.Scp106).FirstOrDefault() : ev.Killer;
if (killer == null)
{
return;
}
if (LookUp(killer.Role, ev.Target.Role, out int xp))
{
API.AddXP(killer, xp);
}
}
public void OnEscape(EscapingEventArgs ev)
{
API.AddXP(ev.Player, Main.Instance.Config.EscapeXP[ev.Player.Role]);
}
public void OnRoundEnd(RoundEndedEventArgs ev)
{
foreach (Player player in Player.List)
{
if (player.LeadingTeam == ev.LeadingTeam)
{
API.AddXP(player, Main.Instance.Config.TeamWinXP);
}
}
YamlPly.Save();
}
public bool LookUp(RoleType killer, Exiled.API.Features.Roles.Role target, out int xp)
{
xp = 0;
if (Main.Instance.Config.KillXP.TryGetValue(killer, out var xp106) && xp106.TryGetValue(target, out var xp1))
{
xp = xp1;
return true;
}
return false;
}
}
}