File size: 863 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
export default class surrounding {
  #map;
  #x;
  #y;

  constructor (options) {
    this.#map  = options.cell.scene.city.map;
    this.#x    = options.cell.x;
    this.#y    = options.cell.y;
  }

  get n () {
    return this.#map.cells?.[this.#x]?.[this.#y - 1];
  }

  get s () {
    return this.#map.cells?.[this.#x]?.[this.#y + 1];
  }

  get e () {
    return this.#map.cells?.[this.#x + 1]?.[this.#y];
  }

  get w () {
    return this.#map.cells?.[this.#x - 1]?.[this.#y];
  }

  get c () {
    return this.#map.cells?.[this.#x]?.[this.#y];
  }

  get ne () {
    return this.#map.cells?.[this.#x + 1]?.[this.#y - 1];
  }

  get nw () {
    return this.#map.cells?.[this.#x - 1]?.[this.#y - 1];
  }

  get se () {
    return this.#map.cells?.[this.#x + 1]?.[this.#y + 1];
  }

  get sw () {
    return this.#map.cells?.[this.#x - 1]?.[this.#y + 1];
  }
}