Ticket #4068: map.js2016-6-21.patch

File map.js2016-6-21.patch, 1.3 KB (added by FeXoR, 8 years ago)

Splits entity/actor gathering from map export

  • binaries/data/mods/public/maps/random/rmgen/map.js

     
    279279    return sumHeight / count;
    280280};
    281281
    282 Map.prototype.getMapData = function()
     282Map.prototype.getFullEntityList = function(rotateForMapExport = false)
    283283{
    284     var data = {};
    285    
    286284    // Build entity array
    287285    var entities = [];
    288286   
     
    297295    for (var i = 0; i < this.objects.length; ++i)
    298296    {
    299297        // Change rotation from simple 2d to 3d befor giving to engine
    300         this.objects[i].rotation.y = PI/2 - this.objects[i].rotation.y;
     298        if (rotateForMapExport)
     299            this.objects[i].rotation.y = PI/2 - this.objects[i].rotation.y;
    301300        entities.push(this.objects[i]);
    302301    }
    303     data.entities = entities;
    304302   
    305     log("Number of entities: "+entities.length);
     303    return entities;
     304};
     305
     306Map.prototype.getMapData = function()
     307{
     308    var data = {};
    306309   
     310    data.entities = this.getFullEntityList(true);
     311   
     312    log("Number of entities: "+ data.entities.length);
     313   
    307314    // Terrain
    308     data.size = this.size;
     315    var size = this.size;
     316    data.size = size;
    309317   
    310318    // Convert 2D heightmap array to flat array
    311319    //  Flat because it's easier to handle by the engine