Repository navigation
Expand file tree
/
Copy pathProxiStack.cs
More file actions
68 lines (59 loc) · 2.63 KB
/
Copy pathProxiStack.cs
File metadata and controls
68 lines (59 loc) · 2.63 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
using System.Reflection;
using HarmonyLib;
namespace ProxiStack
{
public class ProxiStackMod : IModApi
{
public const string HarmonyId = "com.elternvszombies.proxistack";
private static ProxiStackMod _instance;
public static ProxiStackMod Instance => _instance;
public ProxiStackConfig Config { get; private set; }
public string ModPath { get; private set; }
public void InitMod(Mod _modInstance)
{
_instance = this;
ModPath = _modInstance.Path;
Log.Out("[ProxiStack] Initializing ProxiStack v1.1.9");
Config = new ProxiStackConfig();
Config.Load(System.IO.Path.Combine(ModPath, "ProxiStackConfig.xml"));
Harmony harmony = new Harmony(HarmonyId);
harmony.PatchAll(Assembly.GetExecutingAssembly());
Log.Out("[ProxiStack] Harmony patches registered");
// Registriere das NetPackage in bekannten Paket-Typen von NetPackageManager
try
{
System.Type npm = typeof(NetPackageManager);
var field = npm.GetField("knownPackageTypes", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
if (field == null)
{
Log.Warning("[ProxiStack] NetPackageManager.knownPackageTypes field not found!");
}
else
{
System.Collections.IDictionary dict = field.GetValue(null) as System.Collections.IDictionary;
if (dict == null)
{
Log.Warning("[ProxiStack] NetPackageManager.knownPackageTypes value is null!");
}
else
{
if (!dict.Contains("NetPackageProxiStack"))
{
dict.Add("NetPackageProxiStack", typeof(NetPackageProxiStack));
Log.Out("[ProxiStack] NetPackageProxiStack registered in knownPackageTypes successfully.");
}
else
{
Log.Out("[ProxiStack] NetPackageProxiStack was already present in knownPackageTypes.");
}
}
}
}
catch (System.Exception ex)
{
Log.Warning($"[ProxiStack] NetPackage registration failed with exception: {ex.Message}");
}
Log.Out("[ProxiStack] ProxiStack initialization complete");
}
}
}