File size: 3,318 Bytes
4ee4376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import dat from 'dat.gui';

export default class debug {
  constructor (options) {
    this.scene = options.scene;
    this.globals = this.scene.globals;
    this.toggleLayer = this.toggleLayerInit();

    this.gui = new dat.GUI();
    this.gui.closed = false;

    let f1 = this.gui.addFolder('Performance');
    f1.add(this.scene.sys.game.loop, 'actualFps', 'FPS').listen();
    f1.add(this.scene.viewport, 'objectsRendered', 'Objects Rendered').listen();
    f1.open();

    let g1 = this.gui.addFolder('Cursor');
    g1.add(this.scene.input, 'x', 'X').listen();
    g1.add(this.scene.input, 'y', 'Y').listen();
    g1.add(this.scene.viewport.worldPoint, 'x', 'WorldPoint X').listen();
    g1.add(this.scene.viewport.worldPoint, 'y', 'WorldPoint Y').listen();
    g1.add(this.scene.city.map.selectedCell, 'x', 'Cell X').listen();
    g1.add(this.scene.city.map.selectedCell, 'y', 'Cell Y').listen();
    //g1.open();
    
    let g2 = this.gui.addFolder('Camera');
    g2.add(this.scene.cameras.main, 'scrollX', 'X').listen();
    g2.add(this.scene.cameras.main, 'scrollY', 'Y').listen();
    g2.add(this.scene.cameras.main, 'zoom', 'Zoom', 0.1, 2).step(0.1).listen();
    g2.open();

    let g3 = this.gui.addFolder('World');
    g3.add(this, 'sleepWakeWorld', 'Sleep / Wake');
    //g3.add(this.scene.city.load, 'open', 'Open City');
    //g3.add(this.city.save, 'saveCity', 'Save City');
    g3.add(this.toggleLayer, 'terrain', 'Toggle Terrain');
    g3.add(this.toggleLayer, 'water', 'Toggle Water');
    g3.add(this.toggleLayer, 'heightmap', 'Toggle Height Map');
    //g3.add(this.toggleLayer, 'road', 'Toggle Road');
    //g3.add(this.toggleLayer, 'power', 'Toggle Power');
    //g3.add(this.toggleLayer, 'building', 'Toggle Building');
    //g3.add(this.toggleLayer, 'zone', 'Toggle Zone');
    //g3.add(this.toggleLayer, 'rail', 'Toggle Rail');
    //g3.add(this.toggleLayer, 'highway', 'Toggle Highway');
    //g3.add(this.toggleLayer, 'subway', 'Toggle Subway');
    //g3.add(this.toggleLayer, 'pipes', 'Toggle Pipes');
    //g3.open();
  }

  toggleLayerInit () {
    return {
      terrain: () => {
        this.scene.city.map.layers.terrain.toggle();
      },
      heightmap: () => {
        this.scene.city.map.layers.heightmap.toggle();
      },
      water: () => {
        this.scene.city.map.layers.water.toggle();
      },
      road: () => {
        this.scene.city.map.layers.road.toggle();
      },
      power: () => {
        this.scene.city.map.layers.power.toggle();
      },
      building: () => {
        this.scene.city.map.layers.building.toggle();
      },
      zone: () => {
        this.scene.city.map.layers.zone.toggle();
      },
      rail: () => {
        this.scene.city.map.layers.rail.toggle();
      },
      highway: () => {
        this.scene.city.map.layers.highway.toggle();
      },
      subway: () => {
        this.scene.city.map.layers.subway.toggle();
      },
      pipes: () => {
        this.scene.city.map.layers.pipes.toggle();
      },
    };
  }

  shutdown () {
    if (this.gui)
      this.gui.destroy();
  }

  loadCity () {
    this.scene.city.globals.loadCity();
  }

  saveCity () {
    this.scene.city.globals.saveCity();
  }

  sleepWakeWorld () {
    if (this.scene.isSleeping)
      this.scene.wake();
    else
      this.scene.sleep();
  }
}