Last change
on this file since 414 was 406, checked in by alloc, 21 months ago |
Only run web server if game is running as server
|
File size:
768 bytes
|
Line | |
---|
1 | using JetBrains.Annotations;
|
---|
2 | using Webserver;
|
---|
3 | using Webserver.UrlHandlers;
|
---|
4 |
|
---|
5 | namespace MapRendering {
|
---|
6 | [UsedImplicitly]
|
---|
7 | public class ModApi : IModApi {
|
---|
8 | public void InitMod (Mod _modInstance) {
|
---|
9 | if (ConnectionManager.Instance.IsServer) {
|
---|
10 | ModEvents.GameShutdown.RegisterHandler (GameShutdown);
|
---|
11 | ModEvents.CalcChunkColorsDone.RegisterHandler (CalcChunkColorsDone);
|
---|
12 | }
|
---|
13 |
|
---|
14 | Web.ServerInitialized += _web => {
|
---|
15 | _web.RegisterPathHandler ("/map/", new StaticHandler (
|
---|
16 | $"{GameIO.GetSaveGameDir ()}/map",
|
---|
17 | MapRenderer.GetTileCache (),
|
---|
18 | false,
|
---|
19 | "web.map")
|
---|
20 | );
|
---|
21 | };
|
---|
22 | }
|
---|
23 |
|
---|
24 | private void GameShutdown () {
|
---|
25 | MapRenderer.Shutdown ();
|
---|
26 | }
|
---|
27 |
|
---|
28 | private void CalcChunkColorsDone (Chunk _chunk) {
|
---|
29 | MapRenderer.RenderSingleChunk (_chunk);
|
---|
30 | }
|
---|
31 | }
|
---|
32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.