|
| 1 | +import {AbstractConverter} from "./AbstractConverter"; |
| 2 | + |
| 3 | +/** |
| 4 | + * Class DestroyStageConverter |
| 5 | + */ |
| 6 | +class DestroyStageConverter extends AbstractConverter { |
| 7 | + /** |
| 8 | + * @inheritDoc |
| 9 | + */ |
| 10 | + async convert() { |
| 11 | + for await (const from of this.getData()) { |
| 12 | + if (await this.output.exists(from)) { |
| 13 | + this.log.log(`Convert destroy stage ${from}`); |
| 14 | + |
| 15 | + const image = await this.readImage(from); |
| 16 | + |
| 17 | + image.scan(0, 0, image.getWidth(), image.getHeight(), (x, y, idx) => { |
| 18 | + if (image.bitmap.data[idx + 3] === 0) { |
| 19 | + image.bitmap.data[idx] = 255; |
| 20 | + image.bitmap.data[idx + 1] = 255; |
| 21 | + image.bitmap.data[idx + 2] = 255; |
| 22 | + image.bitmap.data[idx + 3] = 1; |
| 23 | + } |
| 24 | + }); |
| 25 | + |
| 26 | + await this.writeImage(from, image); |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + return []; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @inheritDoc |
| 35 | + */ |
| 36 | + static get DATA() { |
| 37 | + return [ |
| 38 | + "textures/environment/destroy_stage_0.png", |
| 39 | + "textures/environment/destroy_stage_1.png", |
| 40 | + "textures/environment/destroy_stage_2.png", |
| 41 | + "textures/environment/destroy_stage_3.png", |
| 42 | + "textures/environment/destroy_stage_4.png", |
| 43 | + "textures/environment/destroy_stage_5.png", |
| 44 | + "textures/environment/destroy_stage_6.png", |
| 45 | + "textures/environment/destroy_stage_7.png", |
| 46 | + "textures/environment/destroy_stage_8.png", |
| 47 | + "textures/environment/destroy_stage_9.png" |
| 48 | + ]; |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +export {DestroyStageConverter}; |
0 commit comments