-
Notifications
You must be signed in to change notification settings - Fork 0
/
SigmaAVC.cs
54 lines (50 loc) · 1.58 KB
/
SigmaAVC.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
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
using KSP_AVC;
namespace Sigma88LoadingScreensPlugin
{
[KSPAddon(KSPAddon.Startup.Instantly, true)]
public class SigmaAVC : MonoBehaviour
{
static bool first = true;
static bool skip = false;
void Awake()
{
if (first && Assembly.GetExecutingAssembly() == LoadingScreenSettings.TheChosenOne.assembly && AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == "KSP-AVC") != null)
{
first = false;
DontDestroyOnLoad(this);
}
else
{
DestroyImmediate(this);
}
}
void Update()
{
if (!skip && AddonLibrary.Populated)
{
skip = true;
try
{
FieldInfo addons = typeof(AddonLibrary).GetFields(BindingFlags.NonPublic | BindingFlags.Static).Skip(1).FirstOrDefault();
List<Addon> list = (List<Addon>)addons.GetValue(null);
string path = Assembly.GetExecutingAssembly().Location.Replace(".dll", ".sigma");
if (File.Exists(path))
{
Addon addon = new Addon(path);
list.Add(addon);
addons.SetValue(addons, list);
}
}
catch
{
}
DestroyImmediate(this);
}
}
}
}