forked from decaprime/CommunityCommands
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathPlugin.cs
More file actions
66 lines (55 loc) · 1.75 KB
/
Copy pathPlugin.cs
File metadata and controls
66 lines (55 loc) · 1.75 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
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using KindredCommands.Models;
using HarmonyLib;
using ProjectM;
using UnityEngine;
using VampireCommandFramework;
namespace KindredCommands;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInDependency("gg.deca.VampireCommandFramework")]
public class Plugin : BasePlugin
{
internal static Harmony Harmony;
internal static ManualLogSource PluginLog;
public static ManualLogSource LogInstance { get; private set; }
public override void Load()
{
if (Application.productName != "VRisingServer")
return;
PluginLog = Log;
// Plugin startup logic
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} version {MyPluginInfo.PLUGIN_VERSION} is loaded!");
LogInstance = Log;
Database.InitConfig();
// Harmony patching
Harmony = new Harmony(MyPluginInfo.PLUGIN_GUID);
Harmony.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());
// Register all commands in the assembly with VCF
CommandRegistry.RegisterAll();
}
public override bool Unload()
{
CommandRegistry.UnregisterAssembly();
Harmony?.UnpatchSelf();
return true;
}
public void OnGameInitialized()
{
if (!HasLoaded())
{
Log.LogDebug("Attempt to initialize before everything has loaded.");
return;
}
Core.InitializeAfterLoaded();
}
private static bool HasLoaded()
{
// Hack, check to make sure that entities loaded enough because this function
// will be called when the plugin is first loaded, when this will return 0
// but also during reload when there is data to initialize with.
var collectionSystem = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
return collectionSystem?.SpawnableNameToPrefabGuidDictionary.Count > 0;
}
}