rt-graphic-component/components/packages/Platform/common/PlatformTemplate.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-01-03 09:10:35 +08:00
import { JlGraphicTemplate } from 'jl-graphic';
import { JlPlatform } from './JlPlatform.js';
2024-01-11 13:38:16 +08:00
import { THPlatform } from '../THPlatform.js';
import { GPPlatform } from '../GPPlatform.js';
import { StyleType } from '../../../common/common.js';
2024-01-03 09:10:35 +08:00
class PlatformTemplate extends JlGraphicTemplate {
hasdoor;
direction;
2024-01-10 15:46:15 +08:00
styleType;
constructor(dataTemplate, stateTemplate, styleType) {
2024-01-03 09:10:35 +08:00
super(JlPlatform.Type, { dataTemplate, stateTemplate });
2024-01-10 15:46:15 +08:00
this.styleType = styleType;
switch (this.styleType) {
case StyleType.TH:
2024-01-03 09:10:35 +08:00
this.hasdoor = true;
this.direction = 'up';
break;
}
}
new() {
2024-01-10 15:46:15 +08:00
switch (this.styleType) {
case StyleType.GP:
const GP = new GPPlatform();
GP.loadData(this.datas);
GP.loadState(this.states);
return GP;
2024-01-03 09:10:35 +08:00
default:
2024-01-10 15:46:15 +08:00
const TH = new THPlatform();
TH.loadData(this.datas);
TH.loadState(this.states);
return TH;
2024-01-03 09:10:35 +08:00
}
}
}
export { PlatformTemplate };