Repository navigation
Expand file tree
/
Copy pathMod.cs
More file actions
35 lines (31 loc) · 1.39 KB
/
Copy pathMod.cs
File metadata and controls
35 lines (31 loc) · 1.39 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
using System;
using Colossal.Logging;
using Game;
using Game.Modding;
namespace Placemaker
{
public sealed class Mod : IMod
{
public static readonly ILog Log = LogManager.GetLogger(nameof(Placemaker)).SetShowsErrorsInUI(false);
public void OnLoad(UpdateSystem updateSystem)
{
Log.Info($"Placemaker {typeof(Mod).Assembly.GetName().Version} loading");
// Each workstream registers its own systems; a failure in one area is logged and the
// rest still loads, so a broken feature never takes the whole mod (or the game) down.
Try("build", () => Game.Build.BuildRegistration.Register(updateSystem));
Try("tool", () => Game.Tool.ToolRegistration.Register(updateSystem, this));
// In-game test suite: inert unless the command line AND an armed ModsData/Placemaker/suite/run.json ask for it.
Try("suite", () => Game.Suite.SuiteGate.Register(updateSystem));
}
public void OnDispose()
{
try { Game.Tool.ToolRegistration.Unregister(); } catch (Exception e) { Log.Error(e, "Placemaker: tool unregister failed"); }
Game.Services.Reset();
}
private static void Try(string area, Action register)
{
try { register(); }
catch (Exception e) { Log.Error(e, $"Placemaker: registering '{area}' failed"); }
}
}
}