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

Last change on this file since 405 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
Line 
1using JetBrains.Annotations;
2using Webserver;
3using Webserver.UrlHandlers;
4
5namespace MapRendering {
6 [UsedImplicitly]
7 public class ModApi : IModApi {
8 public void InitMod (Mod _modInstance) {
9 ModEvents.GameShutdown.RegisterHandler (GameShutdown);
10 ModEvents.CalcChunkColorsDone.RegisterHandler (CalcChunkColorsDone);
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 };
20 }
21
22 private void GameShutdown () {
23 MapRenderer.Shutdown ();
24 }
25
26 private void CalcChunkColorsDone (Chunk _chunk) {
27 MapRenderer.RenderSingleChunk (_chunk);
28 }
29 }
30}
Note: See TracBrowser for help on using the repository browser.