import { director } from "cc";
import BaseBuffer from "../../engines/buffers/BaseBuffer";
import { GameModel } from "../models/GameModel";


/**
 * 自动合成BUFFER
 */
export default class AutoSyntheticBuffer extends BaseBuffer
{
    constructor(group:string,time:number){
        super(group,time);
    }

    Run(data?:any):void{
        this.mergeBuffer();
        super.Run(data);
    }

    lastTime:number=0;
    /**
     * 心跳
     * @param dt
     */
    Tick(dt:number):void{
        let currentTime:number=director.getCurrentTime();
        if(currentTime-this.lastTime>1000){
            GameModel.single.AutoSynthetic(1);//每秒合成1个
            this.lastTime=currentTime;
        }
    }
}