source: binary-improvements2/MapRendering/src/ModApi.cs@ 421

Last change on this file since 421 was 406, checked in by alloc, 21 months ago

Only run web server if game is running as server

File size: 768 bytes
RevLine 
[391]1using JetBrains.Annotations;
[402]2using Webserver;
3using Webserver.UrlHandlers;
[224]4
[391]5namespace MapRendering {
6 [UsedImplicitly]
7 public class ModApi : IModApi {
[369]8 public void InitMod (Mod _modInstance) {
[406]9 if (ConnectionManager.Instance.IsServer) {
10 ModEvents.GameShutdown.RegisterHandler (GameShutdown);
11 ModEvents.CalcChunkColorsDone.RegisterHandler (CalcChunkColorsDone);
12 }
13
[402]14 Web.ServerInitialized += _web => {
15 _web.RegisterPathHandler ("/map/", new StaticHandler (
16 $"{GameIO.GetSaveGameDir ()}/map",
17 MapRenderer.GetTileCache (),
18 false,
19 "web.map")
20 );
21 };
[325]22 }
23
[324]24 private void GameShutdown () {
[391]25 MapRenderer.Shutdown ();
[299]26 }
27
[324]28 private void CalcChunkColorsDone (Chunk _chunk) {
[391]29 MapRenderer.RenderSingleChunk (_chunk);
[224]30 }
31 }
[325]32}
Note: See TracBrowser for help on using the repository browser.