-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventHandlers.cs
67 lines (57 loc) · 2.17 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
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Linq;
using CustomPlayerEffects;
using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Features.Roles;
using Exiled.Events.Commands.Reload;
using Exiled.Events.EventArgs;
using GameCore;
using MEC;
using PlayerStatsSystem;
using UnityEngine;
namespace No049NoZombie
{
using Exiled.API.Features;
/// <summary>
/// General event handlers.
/// </summary>
public class EventHandlers
{
private readonly Plugin plugin;
/// <summary>
/// Initializes a new instance of the <see cref="EventHandlers"/> class.
/// </summary>
/// <param name="plugin">The <see cref="Plugin{TConfig}"/> class reference.</param>
public EventHandlers(Plugin plugin) => this.plugin = plugin;
/// <inheritdoc cref="SpawningEventArgs"/>
public void OnRoundStart(SpawningEventArgs ev)
{
Timing.RunCoroutine(DamageTick());
}
private IEnumerator<float> DamageTick()
{
while (Round.IsStarted)
{
yield return Timing.WaitForSeconds(1f);
List<Player> scpList = Player.Get(player => player.IsScp && player.Role.Type != RoleType.Scp0492).ToList();
if ((Player.Get(RoleType.Scp049).Any() && !plugin.Config.AllScpsDead) || (plugin.Config.AllScpsDead && scpList.Count != 0))
continue;
foreach (Player player in Player.List)
{
if (player.Role.Type == RoleType.Scp0492)
{
player.Hurt(plugin.Config.DamageIntensity,
plugin.Config.AllScpsDead
? "Decayed away from all other SCPs no longer being alive."
: "Decayed away from SCP-049 no longer being alive.");
player.EnableEffect<Poisoned>(400);
PlayerEffect effect = player.GetEffect(EffectType.Poisoned);
effect.Intensity = plugin.Config.PoisonIntensity;
}
}
}
}
}
}