-
Notifications
You must be signed in to change notification settings - Fork 2
/
DCECore.cs
62 lines (51 loc) · 1.83 KB
/
DCECore.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
55
56
57
58
59
60
61
62
using System;
using System.Reflection;
using IRBTModUtils.Logging;
using System.IO;
using Newtonsoft.Json;
using DropCostsEnhanced.Data;
using CustomComponents;
namespace DropCostsEnhanced
{
public class DCECore
{
internal static DeferringLogger modLog;
internal static Settings settings;
internal static string modDir;
internal static DateTime cacheValidUntil;
internal static float cachedDifficulty;
public static void Init(string modDirectory, string settingsJSON)
{
modDir = modDirectory;
try
{
using (StreamReader reader = new StreamReader($"{modDir}/settings.json"))
{
string jdata = reader.ReadToEnd();
settings = JsonConvert.DeserializeObject<Settings>(jdata);
settings.initHolders();
}
}
catch (Exception ex)
{
// modLog.Error?.Write(ex);
}
modLog = new DeferringLogger(modDirectory, "DropCostEnhanced", "DCE", settings.debug, settings.trace);
try
{
cachedDifficulty = 0f;
cacheValidUntil = DateTime.UtcNow;
CustomComponents.Registry.RegisterSimpleCustomComponents(Assembly.GetExecutingAssembly());
DropCostManager.Instance.Initialize();
AmmoCostManager.Instance.Initialize();
HeatCostManager.Instance.Initialize();
DifficultyManager.Instance.Initialize();
}
catch (Exception e)
{
modLog.Error?.Write(e);
}
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ca.jwolf.DropCostsEnhanced");
}
}
}