-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSCP294.cs
100 lines (78 loc) · 3.44 KB
/
SCP294.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using Exiled.API.Features;
using Player = Exiled.Events.Handlers.Player;
using Server = Exiled.Events.Handlers.Server;
using System;
using System.Collections.Generic;
using MEC;
using MapEditorReborn.API.Features.Objects;
using SCP294.Classes;
using SCP294.Types;
using HarmonyLib;
using Exiled.API.Enums;
using VoiceChat.Codec;
namespace SCP294
{
public class SCP294 : Plugin<Config.Config>
{
public override string Name => "Ultimate294";
public override string Author => "creepycats";
public override Version Version => new Version(1, 1, 1);
public override PluginPriority Priority => PluginPriority.Highest;
public static SCP294 Instance { get; set; }
public Dictionary<SchematicObject, bool> SpawnedSCP294s { get; set; } = new Dictionary<SchematicObject, bool>();
public Dictionary<SchematicObject, int> SCP294UsesLeft { get; set; } = new Dictionary<SchematicObject, int>();
public Dictionary<SchematicObject, LightSourceObject> SCP294LightSources { get; set; } = new Dictionary<SchematicObject, LightSourceObject>();
public List<string> PlayersNear294 { get; set; } = new List<string>();
public Dictionary<ushort, DrinkInfo> CustomDrinkItems = new Dictionary<ushort, DrinkInfo>();
public DrinkManager DrinkManager = new DrinkManager();
public Dictionary<string, float> PlayerVoicePitch = new Dictionary<string, float>();
private Harmony _harmony;
private CoroutineHandle hintCoroutine;
public Dictionary<ReferenceHub, OpusComponent> Encoders = new Dictionary<ReferenceHub, OpusComponent>();
public override void OnEnabled()
{
Instance = this;
Log.Info($"{Name} v{Version} - made by creepycats");
if (Config.Debug)
Log.Info("Registering events...");
RegisterEvents();
DrinkManager.LoadBaseDrinks();
hintCoroutine = Timing.RunCoroutine(SCP294Object.Handle294Hint());
_harmony = new Harmony("SCP294");
_harmony.PatchAll();
Log.Info("Plugin Enabled!");
}
public override void OnDisabled()
{
if (Config.Debug)
Log.Info("Unregistering events...");
UnregisterEvents();
DrinkManager.UnloadAllDrinks();
Timing.KillCoroutines(hintCoroutine);
_harmony.UnpatchAll();
_harmony = null;
Log.Info("Disabled Plugin Successfully");
}
// NotesToSelf
// OBJECT.EVENT += FUNCTION > Add Function to Callback
// OBJECT.EVENT -= FUNCTION > Remove Function from Callback
private handlers.serverHandler ServerHandler;
private handlers.playerHandler PlayerHandler;
public void RegisterEvents()
{
ServerHandler = new handlers.serverHandler();
PlayerHandler = new handlers.playerHandler();
Server.RoundStarted += ServerHandler.WaitingForPlayers;
Player.ChangingItem += PlayerHandler.ChangingItem;
Player.UsedItem += PlayerHandler.UsedItem;
Player.Joined += PlayerHandler.Joined;
}
public void UnregisterEvents()
{
Server.RoundStarted -= ServerHandler.WaitingForPlayers;
Player.ChangingItem -= PlayerHandler.ChangingItem;
Player.UsedItem -= PlayerHandler.UsedItem;
Player.Joined -= PlayerHandler.Joined;
}
}
}