game_sync/tools/xlsx2proto/templ/gpb_mgr_ts.templ

45 lines
1.2 KiB
Plaintext

{{define "gpb_mgr_ts"}}
// Code generated by xlsx2proto.
// DO NOT EDIT!
import { ConfHolder } from "./ConfLoader";
export class {{.ProtoName}} implements ConfHolder {
public datas:server.{{.ProtoName}}Array | null = null;
public pool:Map<number,server.{{.ProtoName}}> = new Map<number,server.{{.ProtoName}}>();
private static instacne:{{.ProtoName}} | null = null;
public static getInstance():{{.ProtoName}}{
if (this.instacne == null){
this.instacne = new {{.ProtoName}}();
}
return this.instacne;
}
//反序列化
decode(buff: Uint8Array): Error|null {
this.datas = server.{{.ProtoName}}Array.decode(buff);
this.arrangeData();
return null;
}
//
public clear():void{
this.datas =null;
this.pool.clear();
{{.ProtoName}}.instacne = null;
}
//将数组转换成为字典
private arrangeData(){
if (this.datas != null){
for (let k of this.datas.Arr.keys()){
let id = this.datas.Arr[k].Id;
this.pool.set(id!,this.datas.Arr[k] as server.{{.ProtoName}})
}
}
}
}
{{end}}