This repository was archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
80 lines (69 loc) · 2.32 KB
/
Main.cs
File metadata and controls
80 lines (69 loc) · 2.32 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
namespace MarrowUtils;
public class Main : MelonMod
{
internal const string Name = "MarrowUtils";
internal const string Description = "A collection of utilities for BONELAB.";
internal const string Author = "SoulWithMae";
internal const string Company = "Weather Electric";
internal const string Version = "1.0.0";
internal const string DownloadLink = "https://bonelab.thunderstore.io/package/SoulWithMae/MarrowUtils/";
internal static MenuCategory MenuCat { get; private set; }
internal static Assembly CurrAsm { get; } = Assembly.GetExecutingAssembly();
public override void OnInitializeMelon()
{
ModConsole.Setup(LoggerInstance);
Preferences.Setup();
var mainCat = MenuManager.CreateCategory("Weather Electric", "#6FBDFF");
MenuCat = mainCat.CreateCategory("Marrow Utils", "#009dff");
Utility.Initialize();
Hooking.OnLevelInitialized += OnLevelLoad;
Hooking.OnLevelUnloaded += OnLevelUnload;
#if DEBUG
ModConsole.Warning("This is a debug build! Expect unstable behavior!");
#endif
}
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
if (sceneName.ToUpper().Contains("BOOTSTRAP"))
{
AssetWarehouse.OnReady(new Action(WarehouseLoaded));
}
}
private static void WarehouseLoaded()
{
var pallets = AssetWarehouse.Instance.GetPallets();
var crates = AssetWarehouse.Instance.GetCrates();
Utility.WarehouseLoaded(pallets, crates);
}
public override void OnUpdate()
{
Utility.OnUpdate();
}
public override void OnLateUpdate()
{
Utility.OnLateUpdate();
}
public override void OnFixedUpdate()
{
Utility.OnFixedUpdate();
}
private static void OnLevelLoad(LevelInfo levelInfo)
{
Utility.LevelLoad(levelInfo);
}
private static void OnLevelUnload()
{
Utility.LevelUnload();
}
[HarmonyPatch(typeof(AssetPoolee))]
private static class PooleeStart
{
[HarmonyPostfix]
[HarmonyPatch(nameof(AssetPoolee.OnSpawn))]
// ReSharper disable once InconsistentNaming
private static void Postfix(AssetPoolee __instance)
{
Utility.SpawnablePlaced(__instance, __instance.gameObject);
}
}
}