#include "line.j" struct Broadcast timer recorder real progress real tick integer progressLine Line array lines[100] integer lineLength = 0 string name static method create takes string name returns thistype local thistype b = thistype.allocate() set b.name = name set b.lineLength = 0 set b.recorder = null set b.progress = 0 set b.progressLine = 0 return b endmethod method getLength takes nothing returns integer return this.lineLength endmethod method add takes Line line returns thistype set this.lines[this.lineLength] = line set this.lineLength = this.lineLength + 1 return this endmethod method ready takes real tick returns thistype set this.recorder = CreateTimer() set this.tick = tick return this endmethod method nextTick takes nothing returns real if this.getLength() == 0 then return - 4000 // 当前播片没有台词,立即结束 endif if this.progress >= this.lines[this.progressLine].begin then call this.lines[this.progressLine].say() set this.progressLine = this.progressLine + 1 if this.progressLine >= this.getLength() then return - 2000 // 播片台词播放完毕 endif endif set this.progress = this.progress + this.tick return this.progress // 正常运行返回当前播片进度 endmethod endstruct