67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
|
import * as PIXI from 'pixi.js'
|
||
|
|
||
|
export class Decor {
|
||
|
texture: PIXI.Texture
|
||
|
decorations: Decoration[] = []
|
||
|
|
||
|
constructor(o: any) {
|
||
|
this.texture = PIXI.Texture.from('./Assets/Decors/'+o.image)
|
||
|
// Load decorations.
|
||
|
for (let d of o.decorations) {
|
||
|
this.decorations.push(new Decoration(this.texture.baseTexture, d))
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export class Decoration {
|
||
|
frames: DecorationFrame[] = []
|
||
|
constructor(t: PIXI.BaseTexture, o: any) {
|
||
|
for (let frame of o.frames) {
|
||
|
this.frames.push(new DecorationFrame(t, frame))
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export class DecorationFrame {
|
||
|
parts: DecorationPart[] = []
|
||
|
time: number = 0
|
||
|
constructor(t: PIXI.BaseTexture, o: any) {
|
||
|
this.time = o.frame_time
|
||
|
for (let p of o.parts) {
|
||
|
this.parts.push(new DecorationPart(t, p))
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export class DecorationPart {
|
||
|
texture: PIXI.Texture
|
||
|
clipX: number = 0
|
||
|
clipY: number = 0
|
||
|
clipWidth: number = 0
|
||
|
clipHeight: number = 0
|
||
|
x: number = 0
|
||
|
y: number = 0
|
||
|
alpha: number = 1
|
||
|
rotation: number = 0
|
||
|
mirror: boolean = false
|
||
|
flip: boolean = false
|
||
|
constructor(t: PIXI.BaseTexture, o: any) {
|
||
|
this.clipX = o.clipX
|
||
|
this.clipY = o.clipY
|
||
|
this.clipWidth = o.clipWidth
|
||
|
this.clipHeight = o.clipHeight
|
||
|
this.x = o.x
|
||
|
this.y = o.y
|
||
|
this.alpha = o.alpha
|
||
|
this.rotation = o.rotation
|
||
|
this.mirror = o.mirror
|
||
|
this.flip = o.flip
|
||
|
// Hmm.
|
||
|
this.texture = new PIXI.Texture(t, new PIXI.Rectangle(this.clipX, this.clipY, this.clipWidth, this.clipHeight))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// This loads a file in an expected Vio Decor format and returns an array of Decor entries.
|
||
|
export function load(obj: any) {
|
||
|
|
||
|
}
|