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

Last change on this file since 402 was 402, checked in by alloc, 22 months ago
  • Major refactoring
  • Using Utf8Json for (de)serialization
  • Moving APIs to REST
  • Removing dependencies from WebServer and MapRenderer to ServerFixes
File size: 712 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) {
[325]9 ModEvents.GameShutdown.RegisterHandler (GameShutdown);
10 ModEvents.CalcChunkColorsDone.RegisterHandler (CalcChunkColorsDone);
[402]11
12 Web.ServerInitialized += _web => {
13 _web.RegisterPathHandler ("/map/", new StaticHandler (
14 $"{GameIO.GetSaveGameDir ()}/map",
15 MapRenderer.GetTileCache (),
16 false,
17 "web.map")
18 );
19 };
[325]20 }
21
[324]22 private void GameShutdown () {
[391]23 MapRenderer.Shutdown ();
[299]24 }
25
[324]26 private void CalcChunkColorsDone (Chunk _chunk) {
[391]27 MapRenderer.RenderSingleChunk (_chunk);
[224]28 }
29 }
[325]30}
Note: See TracBrowser for help on using the repository browser.