source: TFP-WebServer/WebServer/src/ModApi.cs@ 511

Last change on this file since 511 was 511, checked in by alloc, 9 hours ago

Compatibility for V 2.5

File size: 965 bytes
Line 
1using System.Reflection;
2using HarmonyLib;
3using JetBrains.Annotations;
4using Webserver.UrlHandlers;
5
6namespace Webserver {
7 [UsedImplicitly]
8 public class ModApi : IModApi {
9 private Web webInstance;
10 public static Mod ModInstance;
11
12 public void InitMod (Mod _modInstance) {
13 ModEvents.GameStartDone.RegisterHandler (GameStartDone);
14 ModEvents.WorldShuttingDown.RegisterHandler (WorldShuttingDown);
15 ModInstance = _modInstance;
16
17 Harmony.CreateAndPatchAll (Assembly.GetExecutingAssembly ());
18 }
19
20 private void GameStartDone (ref ModEvents.SGameStartDoneData _data) {
21 if (!ConnectionManager.Instance.IsServer) {
22 return;
23 }
24
25 webInstance = new Web (ModInstance.Path);
26 LogBuffer.Init ();
27
28 if (ItemIconHandler.Instance != null) {
29 ThreadManager.StartCoroutine (ItemIconHandler.Instance.LoadIcons ());
30 }
31 }
32
33 private void WorldShuttingDown (ref ModEvents.SWorldShuttingDownData _data) {
34 webInstance?.Disconnect ();
35 }
36 }
37}
Note: See TracBrowser for help on using the repository browser.