]> git.lizzy.rs Git - dragonblocks.git/commitdiff
Implement per-map sky master
authorElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 1 Jul 2021 13:56:37 +0000 (15:56 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 1 Jul 2021 13:56:37 +0000 (15:56 +0200)
engine/map.js
engine/map_display.js
settings.json

index 7dff2bc09ead0d5b997cf27519aa272ab0e50b49..48c16790a9c434f767ddbd9940a0f3c50b1eaf93 100644 (file)
@@ -37,21 +37,21 @@ dragonblocks.Map = class
        serialize()
        {
                return {
-                       data: this.data,
                        width: this.width,
                        height: this.height,
-                       structures: this.structures,
+                       sky: this.sky,
+                       data: this.data,
                        entities: dblib.removeTmp(this.entities),
+                       structures: this.structures,
                };
        }
 
        deserialize(data)
        {
-               this.data = [];
-
                this.width = data.width;
                this.height = data.height;
-
+               this.sky = data.sky;
+               this.data = [];
                this.entities = [];
                this.structures = data.structures || {};
 
@@ -139,6 +139,13 @@ dragonblocks.Map = class
                        return new dragonblocks.SpawnedEntity(def, this, x, y);
        }
 
+       setSky(sky)
+       {
+               this.sky = sky;
+
+               if (this.active)
+                       dragonblocks.mapMgr.setSky(this.sky);
+       }
 };
 
 dragonblocks.mapMgr = new dragonblocks.ContentMgr(dragonblocks.Map);
index 5e72d9ee677841a1526ee69dbc567972b6601d6f..2c546f2a5f13b124b9bed473785c20e67dafd2c1 100644 (file)
@@ -88,6 +88,8 @@ dragonblocks.MapDisplay = class
                this.map = map;
                this.map.setActive();
 
+               this.setSky(this.map.sky);
+
                this.autoScroll() || this.update();
        }
 
@@ -190,9 +192,8 @@ dragonblocks.registerOnQuit(_ => {
 });
 
 dragonblocks.registerOnStarted(_ => {
-       dragonblocks.mapDisplay.setSky("skyblue");
-       dragonblocks.mapDisplay.setMap(dragonblocks.player.map);
        dragonblocks.mapDisplay.setAnchor(dragonblocks.player);
+       dragonblocks.mapDisplay.setMap(dragonblocks.player.map);
 
        dragonblocks.mapDisplay.setActive();
 });
index 034ef4be534ba160e64f336d2ed9ef5d760cea65..d14f8485a7fe2f0504ab1ee8597290cf4c34bc6e 100644 (file)
@@ -18,7 +18,8 @@
        },
        "map": {
                "width": 250,
-               "height": 100
+               "height": 100,
+               "sky": "skyblue"
        },
        "mapDisplay": {
                "scale": 50