-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSSMPEssentialsPlugin.cs
More file actions
84 lines (67 loc) · 2.27 KB
/
SSMPEssentialsPlugin.cs
File metadata and controls
84 lines (67 loc) · 2.27 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
80
81
82
83
84
using System;
using System.Collections.Generic;
using BepInEx;
using HarmonyLib;
using SSMPEssentials.Client.Modules;
using SSMPEssentials.Utils.Tests;
using SSMPEssentials.Utils;
namespace SSMPEssentials;
// TODO - adjust the plugin guid as needed
[BepInAutoPlugin(id: "io.github.bobbythecatfish.ssmp.essentials", version: Utils.Config.Version)]
[BepInDependency("ssmp", BepInDependency.DependencyFlags.HardDependency)]
public partial class SSMPEssentialsPlugin : BaseUnityPlugin
{
TestManager testManager = new TestManager();
public static readonly List<Action> NextFrames = [];
List<Action> _nextFrames = [];
internal static SSMPEssentialsPlugin instance;
private void Awake()
{
instance = this;
// Put your initialization logic here
SSMP.Api.Client.ClientAddon.RegisterAddon(new Client.Client());
SSMP.Api.Server.ServerAddon.RegisterAddon(new Server.Server());
Utils.Config.Init(Config);
Logger.LogInfo($"Plugin {Name} ({Id}) has loaded!");
var harmony = new Harmony("ssmp.essentials");
harmony.PatchAll();
//Harmony.CreateAndPatchAll(typeof(MaskerPatch), "ssmp.essentials");
//Harmony.CreateAndPatchAll(typeof(DamageHeroPatch), "ssmp.essentials");
//Harmony.CreateAndPatchAll(typeof(HealthPatch), "ssmp.essentials");
HeroController.OnHeroInstanceSet += InitializeHCModules;
}
private void InitializeHCModules(HeroController controller)
{
HeroController.OnHeroInstanceSet -= InitializeHCModules;
Spectate.CreateFreecamUI();
PlayerDeaths.Init();
controller.OnDeath += PlayerDeaths.OnDeath;
PlayerHealth.BlueHealthAddListener();
}
private void Update()
{
if (Utils.Config.TestsEnabled)
{
testManager.Update();
}
if (_nextFrames.Count > 0)
{
var actions = _nextFrames.ToArray();
_nextFrames.Clear();
foreach (var action in actions)
{
action.Invoke();
}
}
Inputs.Update();
}
private void LateUpdate()
{
if (NextFrames.Count > 0)
{
_nextFrames = [.. NextFrames];
NextFrames.Clear();
}
Spectate.Update();
}
}