-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathModApiLoader.cs
More file actions
78 lines (62 loc) · 1.97 KB
/
ModApiLoader.cs
File metadata and controls
78 lines (62 loc) · 1.97 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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MSCLoader;
using TommoJProductions.ModApi.Attachable;
namespace TommoJProductions.ModApi
{
/// <summary>
/// Represents behaviour to load modapi stuff. eg bolt assets, load physics raycaster behaviour
/// </summary>
public static class ModApiLoader
{
// Written, 11.07.2022
internal static bool initialized;
#region IEnumerators
internal static IEnumerator loadModApi()
{
// Written, 11.07.2022
while (ModClient.getPOV == null)
{
yield return null;
}
ModClient.getPartManager.load();
ModClient.getBoltManager.load();
if (ModClient.devMode)
{
addDevMode();
}
initialized = true;
ModConsole.Print($"[ModApiLoader] modapi v{ModApi.VersionInfo.version}: Loaded");
}
#endregion
#region Methods
/// <summary>
/// Loads modapi.
/// </summary>
internal static void injectModApi()
{
// Written, 11.09.2023
bool loaded = ModClient.loaded;
Debug.Log("MODAPI_MAIN: Load" + (loaded ? "ed" : "ing"));
if (!loaded)
{
initialized = false;
ModClient.setModApiGo(new GameObject("Mod API Loader"));
ModClient.levelManager = ModClient.modapiGo.AddComponent<LevelManager>();
GameObject.DontDestroyOnLoad(ModClient.modapiGo);
ConsoleCommand.Add(new ConsoleCommands());
}
}
internal static void addDevMode()
{
// Written, 25.08.2022
if (ModClient.devModeBehaviour == null)
{
ModClient.devModeBehaviour = ModClient.modapiGo.AddComponent<DevMode>();
}
}
#endregion
}
}