-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
89 lines (75 loc) · 1.89 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System.Reflection;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Unity.Entities;
using Exception = System.Exception;
#if VCF
using VampireCommandFramework;
using VampireCommandFramework.Breadstone;
#endif
#if HARMONY
using HarmonyLib;
#endif
namespace VRisingStarterProject;
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
#if VCF
[BepInDependency("gg.deca.VampireCommandFramework")]
[Reloadable]
#endif
#if WETSTONE
[BepInDependency("xyz.molenzwiebel.wetstone")]
[Wetstone.API.Reloadable]
#endif
public class Plugin : BasePlugin
{
public static ManualLogSource Logger;
private static World _serverWorld;
private static EntityManager _em => Server.EntityManager;
#if HARMONY
private Harmony _harmony;
#endif
public static World Server
{
get
{
if (_serverWorld != null) return _serverWorld;
_serverWorld = GetWorld("Server") ?? throw new Exception($"There is no Server world (yet). Did you install this mod on the Server?");
return _serverWorld;
}
}
public override void Load()
{
#if VCF
CommandRegistry.RegisterAll();
#endif
Logger = Log;
Log.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
#if HARMONY
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
#endif
}
public override bool Unload()
{
#if VCF
CommandRegistry.UnregisterAssembly();
#endif
#if HARMONY
_harmony.UnpatchSelf();
#endif
return true;
}
private static World GetWorld(string name)
{
foreach (var world in World.s_AllWorlds)
if (world.Name == name)
return world;
return null;
}
#if VCF
[Command("test")]
public void TestCommand(ChatCommandContext ctx) {
ctx.Reply("This is a test!");
}
#endif
}