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