-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
79 lines (55 loc) · 2.14 KB
/
Plugin.cs
File metadata and controls
79 lines (55 loc) · 2.14 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
using System;
using CandyChances.Patchs;
using Exiled.API.Features;
using HarmonyLib;
using Scp330 = Exiled.Events.Handlers.Scp330;
using Server = Exiled.Events.Handlers.Server;
namespace CandyChances
{
public class Plugin : Plugin<Config, Translation>
{
private Harmony harmony;
private EventHandlers eventHandlers;
internal static Plugin Instance { get; private set; }
public override string Author => "ZurnaSever";
public override string Name => "Candy Chances";
public override string Prefix => "CandyChances";
public override Version Version { get; } = new Version(3, 3, 0);
public override Version RequiredExiledVersion { get; } = new Version(9, 10, 0);
public override void OnEnabled()
{
Instance = this;
eventHandlers = new EventHandlers();
Server.RoundStarted += eventHandlers.OnRoundStarted;
Scp330.EatenScp330 += eventHandlers.OnEatenScp330;
Scp330.InteractingScp330 += eventHandlers.OnInteractingScp330;
harmony = new Harmony(Prefix + DateTime.Now.Ticks);
DoDynamicPatchs(harmony);
base.OnEnabled();
}
public override void OnDisabled()
{
Server.RoundStarted -= eventHandlers.OnRoundStarted;
Scp330.EatenScp330 -= eventHandlers.OnEatenScp330;
Scp330.InteractingScp330 -= eventHandlers.OnInteractingScp330;
harmony.UnpatchAll(harmony.Id);
harmony = null;
eventHandlers = null;
Instance = null;
base.OnDisabled();
}
private void DoDynamicPatchs(Harmony harmony)
{
harmony.PatchSingleType(typeof(CandyChanceOverridePatch));
if (Config.OverrideBowlCandys)
{
harmony.PatchSingleType(typeof(Scp330CandiesPatch));
if (Config.TryReplicateHalloweenCandys)
{
harmony.PatchSingleType(typeof(HauntedRainbow));
harmony.PatchSingleType(typeof(PismaticCloudPatch));
}
}
}
}
}