-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBootstrap.cs
More file actions
71 lines (56 loc) · 3.21 KB
/
Bootstrap.cs
File metadata and controls
71 lines (56 loc) · 3.21 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
namespace Pluton.Rust
{
using System;
using System.IO;
using System.Collections.Generic;
using Core;
using Core.PluginLoaders;
public class Bootstrap : Singleton<Bootstrap>, ISingleton
{
public static string Version => typeof(Bootstrap).Assembly.GetName().Version.ToString();
public void Initialize()
{
Console.WriteLine($"Loading Pluton.Rust, v.{Version}");
System.Reflection.Assembly assembly = GetType().Assembly;
Type[] types = assembly.GetTypes();
for (int i = 0; i < types.Length; i++) {
object[] customAttributes = types[i].GetCustomAttributes(typeof(ConsoleSystem.Factory), false);
if (customAttributes != null && customAttributes.Length != 0) {
ConsoleSystem.Factory factory = customAttributes[0] as ConsoleSystem.Factory;
Type indexType = typeof(ConsoleSystem.Index);
indexType.CallStaticMethod("BuildFields", types[i], factory);
indexType.CallStaticMethod("BuildProperties", types[i], factory);
indexType.CallStaticMethod("BuildFunctions", types[i], factory);
}
}
Singleton<Core.Util>.SetInstance<Util>();
Singleton<PluginLoader>.GetInstance();
Singleton<Hooks>.GetInstance().Initialize();
PluginLoaderHelper.RegisterPluginType<CSSPlugin>(".cs", "csscript");
PluginLoaderHelper.RegisterPluginType<CSPlugin>(".dll", "csharp");
PluginLoaderHelper.RegisterPluginType<PluginLoaders.JSPlugin>(".js", "javascript");
PluginLoaderHelper.RegisterPluginType<PluginLoaders.LUAPlugin>(".lua", "lua");
PluginLoaderHelper.RegisterPluginType<PluginLoaders.PYPlugin>(".py", "python");
PluginLoader<CSSPlugin>.dependencies = new List<Func<bool>>() {
() => CoreConfig.GetInstance().GetBoolValue("csscript", "enabled"),
() => File.Exists(Path.Combine(Core.Util.GetInstance().GetManagedFolder(), "mcs.exe"))
};
PluginLoader<CSPlugin>.dependencies = new List<Func<bool>>() {
() => CoreConfig.GetInstance().GetBoolValue("csharp", "enabled")
};
PluginLoader<PluginLoaders.JSPlugin>.dependencies = new List<Func<bool>>() {
() => CoreConfig.GetInstance().GetBoolValue("javascript", "enabled"),
() => File.Exists(Path.Combine(Core.Util.GetInstance().GetManagedFolder(), "Jint.dll"))
};
PluginLoader<PluginLoaders.LUAPlugin>.dependencies = new List<Func<bool>>() {
() => CoreConfig.GetInstance().GetBoolValue("lua", "enabled"),
() => File.Exists(Path.Combine(Core.Util.GetInstance().GetManagedFolder(), "MoonSharp.Interpreter.dll"))
};
PluginLoader<PluginLoaders.PYPlugin>.dependencies = new List<Func<bool>>() {
() => CoreConfig.GetInstance().GetBoolValue("python", "enabled"),
() => File.Exists(Path.Combine(Core.Util.GetInstance().GetManagedFolder(), "IronPython.Deps.dll"))
};
Console.WriteLine($"[v.{Version}] Pluton.Rust loaded!");
}
}
}