2021-05-13 04:09:46 +00:00
|
|
|
import { AnimatableTileFactory } from './animatable_tile_factory.js';
|
2021-05-12 04:48:16 +00:00
|
|
|
import { SequenceTile } from './sequence_tile.js';
|
|
|
|
|
import { TileFactory } from './tile_factory.js';
|
|
|
|
|
|
2021-05-13 04:09:46 +00:00
|
|
|
export class SequenceTileFactory extends AnimatableTileFactory {
|
2021-05-12 04:48:16 +00:00
|
|
|
tile_factories: TileFactory[];
|
|
|
|
|
delay: number;
|
|
|
|
|
repeat: boolean;
|
|
|
|
|
|
|
|
|
|
constructor(tile_factories: TileFactory[], delay: number, repeat: boolean) {
|
|
|
|
|
super(
|
|
|
|
|
tile_factories[0].layer_name,
|
|
|
|
|
tile_factories[0].width,
|
|
|
|
|
tile_factories[0].height,
|
|
|
|
|
);
|
|
|
|
|
this.tile_factories = tile_factories;
|
|
|
|
|
this.delay = delay;
|
|
|
|
|
this.repeat = repeat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build(tileset: string): SequenceTile {
|
|
|
|
|
const tiles = [];
|
|
|
|
|
|
|
|
|
|
for (const tile_factory of this.tile_factories) {
|
|
|
|
|
tiles.push(tile_factory.build(tileset));
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-17 04:26:18 +00:00
|
|
|
return new SequenceTile(...this.animatable_tile_args(), tiles, this.delay, this.repeat);
|
2021-05-12 04:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
copy(): SequenceTileFactory {
|
|
|
|
|
return new SequenceTileFactory(this.tile_factories, this.delay, this.repeat);
|
|
|
|
|
}
|
|
|
|
|
}
|