File size: 1,072 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
import tile from './tile';
import * as CONST from '../../constants';

export default class power extends tile {
  constructor (options) {
    options.type = CONST.T_POWER;
    options.layerDepth = CONST.DEPTH_POWER;
    super(options);
  }

  check () {
    if (!super.check()) return false;

    if (![14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,67,68,92].includes(this.id)) return false;

    return true;
  }

  get (id) {
    let tile = super.get(id);

    if (this.cell.position.rotate && tile?.flip)
      this.props.flip = true;

    if (this.props.flip && tile?.flipMode == CONST.ALTERNATE_TILE)
      tile = super.get(tile.rotate[this.rotation]);

    return tile;
  }

  create () {
    if (!this.props.draw || !this.check()) return;

    if (this.cell.position.underwater)
      this.props.offsetY -= this.cell.position.seaLevel;

    if (this.cell.tiles.has(CONST.T_TERRAIN) && this.cell.tiles.getId(CONST.T_TERRAIN) == 269)
      this.props.offsetY -= CONST.LAYER_OFFSET;

    super.create();

    if (this.props.flip)
      this.sprite.setFlipX(true);
  }
}