-
Notifications
You must be signed in to change notification settings - Fork 1
/
Plugin.cs
74 lines (66 loc) · 2.18 KB
/
Plugin.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MEC;
using PluginAPI.Core;
using PluginAPI.Core.Attributes;
using PluginAPI.Enums;
using PluginAPI.Events;
using PlayerStatsSystem;
using RemoteAdmin;
using YamlDotNet.Core.Tokens;
using PluginAPI.Core.Factories;
using static PlayerStatsSystem.DamageHandlerBase;
namespace OmegaWarhead
{
public class Plugin
{
[PluginConfig]
public Config PluginConfig;
private static CoroutineHandle _coroutineHandle;
private static bool _omegaWarhead;
[PluginEntryPoint("OmegaWarhead", "1.1.0", "Destory the whole facility", "Misaka_ZeroTwo")]
void LoadPlugin()
{
PluginAPI.Events.EventManager.RegisterEvents(this);
}
[PluginEvent(ServerEventType.RoundStart)]
void OnRoundStart()
{
_coroutineHandle = Timing.RunCoroutine(enumerator());
}
[PluginEvent(ServerEventType.RoundEnd)]
void OnRoundEnd(RoundEndEvent ev)
{
Timing.KillCoroutines(_coroutineHandle);
}
[PluginEvent(ServerEventType.WarheadDetonation)]
void OnWarheadDetonated()
{
if (_omegaWarhead)
{
foreach (Player hub in Player.GetPlayers<Player>())
{
hub.ReferenceHub.playerStats.KillPlayer(new CustomReasonDamageHandler(PluginConfig.OmegaWarheadDeathReason, -1f));
}
}
}
[PluginEvent(ServerEventType.WaitingForPlayers)]
void OnWaitingForPlayers()
{
_omegaWarhead = false;
}
IEnumerator<float> enumerator()
{
yield return Timing.WaitForSeconds(PluginConfig.MinutesTillOmegaWarhead * 60);
AlphaWarheadController.Singleton.InstantPrepare();
AlphaWarheadController.Singleton.StartDetonation(false);
AlphaWarheadController.Singleton.IsLocked = true;
_omegaWarhead = true;
Server.SendBroadcast(PluginConfig.OmegaWarheadAnnouncement, PluginConfig.OmegaWarheadAnnouncementDuration);
yield break;
}
}
}