-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMod.cs
More file actions
50 lines (39 loc) · 1.64 KB
/
Copy pathMod.cs
File metadata and controls
50 lines (39 loc) · 1.64 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
using Game.Modding;
using Game;
using Colossal.IO.AssetDatabase;
using Game.SceneFlow;
using MapTextureReplacer.Locale;
using HarmonyLib;
using Colossal.Logging;
using System.IO;
using MapTextureReplacer.Systems;
namespace MapTextureReplacer
{
public class Mod : IMod
{
private Harmony? _harmony;
public static MapTextureReplacerOptions? Options { get; set; }
public static ILog log = LogManager.GetLogger($"{nameof(MapTextureReplacer)}.{nameof(Mod)}").SetShowsErrorsInUI(false);
public static ILog errorLog = LogManager.GetLogger($"{nameof(MapTextureReplacer)}.UserError").SetShowsErrorsInUI(true);
public static string ModPath = "";
public void OnLoad(UpdateSystem updateSystem)
{
_harmony = new($"{nameof(MapTextureReplacer)}.{nameof(Mod)}");
_harmony.PatchAll(typeof(Mod).Assembly);
Options = new(this);
Options.RegisterInOptionsUI();
GameManager.instance.localizationManager.AddSource("en-US", new LocaleEN(Options));
AssetDatabase.global.LoadSettings(nameof(MapTextureReplacer), Options, new MapTextureReplacerOptions(this));
if (GameManager.instance.modManager.TryGetExecutableAsset(this, out var asset))
{
ModPath = asset.path;
}
updateSystem.UpdateAt<MapTextureReplacerSystem>(SystemUpdatePhase.PreSimulation);
updateSystem.UpdateAt<MapTextureReplacerUISystem>(SystemUpdatePhase.UIUpdate);
}
public void OnDispose()
{
_harmony?.UnpatchAll($"{nameof(MapTextureReplacer)}.{nameof(Mod)}");
}
}
}