引入luban配表 需要命令行 npm install buffer
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "2bce8fa5-2ca5-44eb-89aa-d46f7e26d71b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { _decorator, resources, BufferAsset, Component } from "cc";
|
||||
import * as cfg from "../../schema/schema";
|
||||
import ByteBuf from "db://assets/Scripts/luban/ByteBuf";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@ccclass("ConfigManager")
|
||||
export default class ConfigManager extends Component {
|
||||
public static tables: cfg.Tables = null;
|
||||
private static dataMap = new Map<string, Uint8Array>();
|
||||
public static jsonFileNames: string[] = [];
|
||||
|
||||
onLoad() {
|
||||
this.loadAllConfig();
|
||||
}
|
||||
|
||||
public loadConfigName(): void {
|
||||
ConfigManager.jsonFileNames = cfg.Tables.getTableNames();
|
||||
}
|
||||
|
||||
public loadAllConfig() {
|
||||
this.loadConfigName();
|
||||
let promises: Promise<unknown>[] = [];
|
||||
for (let curFileName of ConfigManager.jsonFileNames) {
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
resources.load("test/" + curFileName, BufferAsset, (err, data) => {
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
promise.then((data: BufferAsset) => {
|
||||
if (data) {
|
||||
ConfigManager.dataMap.set(
|
||||
curFileName,
|
||||
new Uint8Array(data.buffer().slice(0, data.buffer().byteLength))
|
||||
);
|
||||
} else {
|
||||
console.error("静态配置加载失败" + curFileName);
|
||||
}
|
||||
});
|
||||
promises.push(promise);
|
||||
}
|
||||
Promise.all(promises).then((values) => {
|
||||
console.log("静态配置加载完成");
|
||||
ConfigManager.tables = new cfg.Tables(this.getFileData);
|
||||
for (let item of ConfigManager.tables.Tbitem.getDataList()) {
|
||||
console.log(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
private getFileData(fileName: string): ByteBuf {
|
||||
if (ConfigManager.dataMap.has(fileName)) {
|
||||
return new ByteBuf(ConfigManager.dataMap.get(fileName));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fbd435ab-238b-4ae8-a5ee-1823eec61491",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,18 +1,29 @@
|
||||
import { _decorator, Component, EditBox, Node,Label,Sprite,UITransform } from "cc";
|
||||
import {
|
||||
_decorator,
|
||||
Component,
|
||||
EditBox,
|
||||
Node,
|
||||
Label,
|
||||
Sprite,
|
||||
UITransform,
|
||||
} from "cc";
|
||||
// 首先加载 polyfills 以确保兼容性
|
||||
import "../../utils/polyfills";
|
||||
import { DialogManager } from "../../manager/DialogManager";
|
||||
import { ChatAIService } from "../../core/ChatAIService";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {InnerMsgCode} from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||
import {ChatContentsLayout} from "../components/ChatContentsLayout";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import { InnerMsgCode } from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||
import { ChatContentsLayout } from "../components/ChatContentsLayout";
|
||||
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import GameRootUI from "db://assets/Scripts/Main/Common/GameRootUI";
|
||||
import {ImagePopup} from "../components/ImagePopup";
|
||||
import {girlDetailInfo, GirlsData} from "db://assets/Scripts/Main/Config/cfg/characters";
|
||||
import { ImagePopup } from "../components/ImagePopup";
|
||||
import {
|
||||
girlDetailInfo,
|
||||
GirlsData,
|
||||
} from "db://assets/Scripts/Main/Config/cfg/characters";
|
||||
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
||||
import {VideoRoleType} from "db://assets/Scripts/Main/Common/GlobalValue";
|
||||
import { VideoRoleType } from "db://assets/Scripts/Main/Common/GlobalValue";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("ChatPanel")
|
||||
@@ -34,44 +45,56 @@ export class ChatPanel extends li_BaseView {
|
||||
@property(ImagePopup)
|
||||
popUpImage: ImagePopup = null;
|
||||
|
||||
id:number
|
||||
id: number;
|
||||
private _nodeTab: any = {};
|
||||
|
||||
openUIDataCT(data)
|
||||
{
|
||||
openUIDataCT(data) {
|
||||
this.id = data;
|
||||
// 设置当前聊天的角色ID
|
||||
ChatAIService.Instance.setCurrentRole(this.id);
|
||||
}
|
||||
|
||||
onLoadCT()
|
||||
{
|
||||
Utils.parseNode(this.node,this._nodeTab);
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
this.register();
|
||||
this.refresh(this.id);
|
||||
}
|
||||
register()
|
||||
{
|
||||
Utils.addInnerEL(InnerMsgCode.Chat_DialogRefresh,this,this.onDialogUpdate);
|
||||
register() {
|
||||
Utils.addInnerEL(
|
||||
InnerMsgCode.Chat_DialogRefresh,
|
||||
this,
|
||||
this.onDialogUpdate
|
||||
);
|
||||
}
|
||||
refresh(id:number) {
|
||||
refresh(id: number) {
|
||||
this.id = id;
|
||||
const data = girlDetailInfo.filter(value=>value.baseInfo.id == id)[0];
|
||||
if(!data) return;
|
||||
const data = girlDetailInfo.filter((value) => value.baseInfo.id == id)[0];
|
||||
if (!data) return;
|
||||
this.girlName.string = data.baseInfo.name;
|
||||
ResManager.I.changeBundleSpriteFrame(this.girlImg,data.baseInfo.pic.url,"Chat18x",()=>{
|
||||
let sizeTran = this.girlImg.node.parent.getComponent(UITransform);
|
||||
Utils.adjustBgPixelRatioToSize(sizeTran.contentSize,this.girlImg.node,2);
|
||||
ResManager.I.changeBundleSpriteFrame(
|
||||
this.girlImg,
|
||||
data.baseInfo.pic.url,
|
||||
"Chat18x",
|
||||
() => {
|
||||
let sizeTran = this.girlImg.node.parent.getComponent(UITransform);
|
||||
Utils.adjustBgPixelRatioToSize(
|
||||
sizeTran.contentSize,
|
||||
this.girlImg.node,
|
||||
2
|
||||
);
|
||||
}
|
||||
);
|
||||
let uiTransform: UITransform =
|
||||
this._nodeTab.BgFrame.getComponent(UITransform);
|
||||
|
||||
Utils.sendInnerMsg(InnerMsgCode.SimplePlayVide, {
|
||||
path: data.pics[0].url,
|
||||
size: uiTransform.contentSize,
|
||||
});
|
||||
let uiTransform:UITransform = this._nodeTab.BgFrame.getComponent(UITransform);
|
||||
|
||||
Utils.sendInnerMsg(InnerMsgCode.SimplePlayVide,{path:data.pics[0].url,size:uiTransform.contentSize} )
|
||||
|
||||
}
|
||||
onDialogUpdate()
|
||||
{
|
||||
this.layout.UpdateDialog(DialogManager.getInstance().getDialogs())
|
||||
onDialogUpdate() {
|
||||
this.layout.UpdateDialog(DialogManager.getInstance().getDialogs());
|
||||
}
|
||||
protected onEnable(): void {
|
||||
if (!this.manager) this.manager = DialogManager.getInstance();
|
||||
@@ -86,15 +109,11 @@ export class ChatPanel extends li_BaseView {
|
||||
|
||||
this.editBox.string = "";
|
||||
|
||||
DialogManager.getInstance().updateDialog(true, str,true);
|
||||
DialogManager.getInstance().updateDialog(true, str, true);
|
||||
|
||||
// 使用新的sendMessage方法,传入角色ID
|
||||
const ret = await ChatAIService.Instance.sendMessage(this.id, str);
|
||||
console.log(ret);
|
||||
|
||||
if (ret == null) {
|
||||
console.warn("rep null");
|
||||
}
|
||||
if (this.manager) {
|
||||
this.manager.updateDialog(false, ret);
|
||||
}
|
||||
@@ -104,11 +123,7 @@ export class ChatPanel extends li_BaseView {
|
||||
//this.popUpImage.refresh("Image/1/blur_naked_1");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
returnBtn()
|
||||
{
|
||||
returnBtn() {
|
||||
this.onClose();
|
||||
GameRootUI.I.showDefaultView();
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "61e402ea-effd-46e7-96e3-aa97fd4e36b1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
import b from "buffer/index.js";
|
||||
const { Buffer } = b;
|
||||
|
||||
export enum EDeserializeError {
|
||||
OK,
|
||||
NOT_ENOUGH,
|
||||
EXCEED_SIZE,
|
||||
}
|
||||
|
||||
|
||||
const MIN_CAPACITY: number = 16
|
||||
|
||||
const f_2power32 = Math.pow(2, 32)
|
||||
const f_2power56 = Math.pow(2, 56)
|
||||
|
||||
export default class ByteBuf {
|
||||
private static emptyBuff: Buffer = Buffer.allocUnsafe(0)
|
||||
|
||||
constructor(bytes?: Uint8Array) {
|
||||
this._bytes = bytes != null ? Buffer.from(bytes) : ByteBuf.emptyBuff
|
||||
this._readerIndex = 0
|
||||
this._writerIndex = bytes != null ? bytes.length : 0
|
||||
}
|
||||
|
||||
|
||||
Replace(bytes: Uint8Array) {
|
||||
this._bytes = Buffer.from(bytes)
|
||||
this._readerIndex = 0
|
||||
this._writerIndex = bytes.length
|
||||
}
|
||||
|
||||
Replace2(bytes: Uint8Array, beginPos: number, endPos: number) {
|
||||
this._bytes = Buffer.from(bytes, beginPos, endPos - beginPos)
|
||||
this._readerIndex = beginPos
|
||||
this._writerIndex = endPos
|
||||
}
|
||||
|
||||
private _bytes: Buffer
|
||||
|
||||
// get Bytes(): Buffer { return this._bytes }
|
||||
|
||||
private _readerIndex: number
|
||||
// get this._readerIndex(): number { return this._readerIndex }
|
||||
// set this._readerIndex(value: number) { this._readerIndex = value }
|
||||
|
||||
private _writerIndex: number
|
||||
// get this._writerIndex(): number { return this._writerIndex }
|
||||
// set this._writerIndex(value: number) { this._writerIndex = value }
|
||||
|
||||
get capacity(): number { return this._bytes.length }
|
||||
get size(): number { return this._writerIndex - this._readerIndex }
|
||||
get empty(): boolean { return this._writerIndex <= this._readerIndex }
|
||||
get notEmpty(): boolean { return this._writerIndex > this._readerIndex }
|
||||
|
||||
getBytesNotSafe(): Buffer { return this._bytes }
|
||||
|
||||
addReadIndex(add: number) {
|
||||
this._readerIndex += add
|
||||
}
|
||||
|
||||
private static emptyBytes: Uint8Array = new Uint8Array()
|
||||
|
||||
copyData(): Uint8Array {
|
||||
const n = this.remaining
|
||||
if (n > 0) {
|
||||
return new Uint8Array(this._bytes.buffer.slice(this._readerIndex, this._writerIndex))
|
||||
} else {
|
||||
return ByteBuf.emptyBytes
|
||||
}
|
||||
}
|
||||
|
||||
get remaining(): number { return this._writerIndex - this._readerIndex }
|
||||
|
||||
discardReadBytes() {
|
||||
this._bytes.copyWithin(0, this._readerIndex, this._writerIndex)
|
||||
this._writerIndex -= this._readerIndex
|
||||
this._readerIndex = 0
|
||||
}
|
||||
|
||||
|
||||
clear() {
|
||||
this._readerIndex = this._writerIndex = 0
|
||||
}
|
||||
|
||||
|
||||
private static propSize(initSize: number, needSize: number): number {
|
||||
for (let i = Math.max(initSize, MIN_CAPACITY); i <<= 1;) {
|
||||
if (i >= needSize) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ensureRead(size: number) {
|
||||
if (this._readerIndex + size > this._writerIndex) {
|
||||
throw new Error()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private canRead(size: number): boolean {
|
||||
return (this._readerIndex + size <= this._writerIndex)
|
||||
}
|
||||
|
||||
readBool(): boolean {
|
||||
this.ensureRead(1)
|
||||
return this._bytes[this._readerIndex++] != 0
|
||||
}
|
||||
|
||||
readByte(): number {
|
||||
this.ensureRead(1)
|
||||
return this._bytes[this._readerIndex++]
|
||||
}
|
||||
|
||||
readShort(): number {
|
||||
this.ensureRead(1)
|
||||
const buf = this._bytes
|
||||
const h = buf.readUInt8(this._readerIndex)
|
||||
if (h < 0x80) {
|
||||
this._readerIndex++
|
||||
return h
|
||||
}
|
||||
else if (h < 0xc0) {
|
||||
this.ensureRead(2)
|
||||
const x = buf.readUInt16BE(this._readerIndex) & 0x3fff
|
||||
this._readerIndex += 2
|
||||
return x
|
||||
}
|
||||
else if ((h == 0xff)) {
|
||||
this.ensureRead(3)
|
||||
const x = buf.readInt16BE(this._readerIndex + 1)
|
||||
this._readerIndex += 3
|
||||
return x
|
||||
}
|
||||
else {
|
||||
throw new Error()
|
||||
}
|
||||
}
|
||||
|
||||
readInt(): number {
|
||||
const buf = this._bytes
|
||||
|
||||
this.ensureRead(1)
|
||||
const h = buf.readUInt8(this._readerIndex)
|
||||
if (h < 0x80) {
|
||||
this._readerIndex++
|
||||
return h
|
||||
}
|
||||
else if (h < 0xc0) {
|
||||
this.ensureRead(2)
|
||||
const x = buf.readUInt16BE(this._readerIndex) & 0x3fff
|
||||
this._readerIndex += 2
|
||||
return x
|
||||
}
|
||||
else if (h < 0xe0) {
|
||||
// console.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
||||
this.ensureRead(3)
|
||||
const x = ((h & 0x1f) << 16) | (buf.readUInt16BE(this._readerIndex + 1))
|
||||
this._readerIndex += 3
|
||||
return x
|
||||
}
|
||||
else if (h < 0xf0) {
|
||||
this.ensureRead(4)
|
||||
// console.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
||||
const x = buf.readInt32BE(this._readerIndex) & 0x0fffffff
|
||||
this._readerIndex += 4
|
||||
return x
|
||||
}
|
||||
else {
|
||||
this.ensureRead(5)
|
||||
const x = buf.readInt32BE(this._readerIndex + 1)
|
||||
this._readerIndex += 5
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
readFint(): number {
|
||||
this.ensureRead(4)
|
||||
const x = this._bytes.readInt32LE()
|
||||
this._readerIndex += 4
|
||||
return x
|
||||
}
|
||||
|
||||
readLongAsNumber(): number {
|
||||
const buf = this._bytes
|
||||
///
|
||||
/// 警告! 如有修改,记得调整 TryDeserializeInplaceOctets
|
||||
this.ensureRead(1)
|
||||
const h = buf.readUInt8(this._readerIndex)
|
||||
if (h < 0x80) {
|
||||
this._readerIndex++
|
||||
return h
|
||||
}
|
||||
else if (h < 0xc0) {
|
||||
this.ensureRead(2)
|
||||
const x = buf.readUInt16BE(this._readerIndex) & 0x3fff
|
||||
// console.log(`== read long :${x} index:${this._readerIndex}`)
|
||||
this._readerIndex += 2
|
||||
return x
|
||||
}
|
||||
else if (h < 0xe0) {
|
||||
// console.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
||||
this.ensureRead(3)
|
||||
const x = ((h & 0x1f) << 16) | (buf.readUInt16BE(this._readerIndex + 1))
|
||||
this._readerIndex += 3
|
||||
return x
|
||||
}
|
||||
else if (h < 0xf0) {
|
||||
this.ensureRead(4)
|
||||
// console.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
||||
const x = buf.readInt32BE(this._readerIndex) & 0x0fffffff
|
||||
this._readerIndex += 4
|
||||
return x
|
||||
}
|
||||
else if (h < 0xf8) {
|
||||
this.ensureRead(5)
|
||||
const xl = buf.readUInt32BE(this._readerIndex + 1)
|
||||
const xh = h & 0x07
|
||||
this._readerIndex += 5
|
||||
return xh * 0x100000000 + xl
|
||||
}
|
||||
else if (h < 0xfc) { // 1111 10xx - - - - -
|
||||
this.ensureRead(6)
|
||||
const xl = buf.readUInt32BE(this._readerIndex + 2)
|
||||
const xh = buf.readUInt16BE(this._readerIndex) & 0x3ff
|
||||
this._readerIndex += 6
|
||||
return xh * 0x100000000 + xl
|
||||
}
|
||||
else if (h < 0xfe) {
|
||||
this.ensureRead(7)
|
||||
const xl = buf.readUInt32BE(this._readerIndex + 3)
|
||||
const xh = (buf.readUInt32BE(this._readerIndex) >> 8) & 0x1ffff
|
||||
this._readerIndex += 7
|
||||
return xh * 0x100000000 + xl
|
||||
}
|
||||
else if (h < 0xff) { // 1111 1110, - - - - - - -
|
||||
this.ensureRead(8)
|
||||
// TODO 是否要对 < Number.MAX_SAFE_INTEGER 优化处理?
|
||||
const xl = buf.readUInt32BE(this._readerIndex + 4)
|
||||
const xh = buf.readUInt32BE(this._readerIndex) & 0xffffff
|
||||
this._readerIndex += 8
|
||||
return xh * f_2power32 + xl
|
||||
}
|
||||
else {
|
||||
this.ensureRead(9)
|
||||
const x = buf.readBigInt64BE(this._readerIndex + 1)
|
||||
// const xl = buf.readUInt32BE(this._readerIndex + 5)
|
||||
// const xh = buf.readInt32BE(this._readerIndex + 1)
|
||||
this._readerIndex += 9
|
||||
return Number(x)
|
||||
}
|
||||
}
|
||||
|
||||
readLong(): bigint {
|
||||
const buf = this._bytes
|
||||
///
|
||||
this.ensureRead(1)
|
||||
const h = buf.readUInt8(this._readerIndex)
|
||||
if (h < 0x80) {
|
||||
this._readerIndex++
|
||||
return BigInt(h)
|
||||
}
|
||||
else if (h < 0xc0) {
|
||||
this.ensureRead(2)
|
||||
const x = buf.readUInt16BE(this._readerIndex) & 0x3fff
|
||||
this._readerIndex += 2
|
||||
return BigInt(x)
|
||||
}
|
||||
else if (h < 0xe0) {
|
||||
this.ensureRead(3)
|
||||
const x = ((h & 0x1f) << 16) | (buf.readUInt16BE(this._readerIndex + 1))
|
||||
this._readerIndex += 3
|
||||
return BigInt(x)
|
||||
}
|
||||
else if (h < 0xf0) {
|
||||
this.ensureRead(4)
|
||||
const x = buf.readInt32BE(this._readerIndex) & 0x0fffffff
|
||||
this._readerIndex += 4
|
||||
return BigInt(x)
|
||||
}
|
||||
else if (h < 0xf8) {
|
||||
this.ensureRead(5)
|
||||
const xl = buf.readUInt32BE(this._readerIndex + 1)
|
||||
const xh = h & 0x07
|
||||
this._readerIndex += 5
|
||||
return BigInt(xh * 0x100000000 + xl)
|
||||
}
|
||||
else if (h < 0xfc) { // 1111 10xx - - - - -
|
||||
this.ensureRead(6)
|
||||
const xl = buf.readUInt32BE(this._readerIndex + 2)
|
||||
const xh = buf.readUInt16BE(this._readerIndex) & 0x3ff
|
||||
this._readerIndex += 6
|
||||
return BigInt(xh * 0x100000000 + xl)
|
||||
}
|
||||
else if (h < 0xfe) {
|
||||
this.ensureRead(7)
|
||||
const xl = buf.readUInt32BE(this._readerIndex + 3)
|
||||
const xh = (buf.readUInt32BE(this._readerIndex) >> 8) & 0x1ffff
|
||||
this._readerIndex += 7
|
||||
return BigInt(xh * 0x100000000 + xl)
|
||||
}
|
||||
else if (h < 0xff) { // 1111 1110, - - - - - - -
|
||||
this.ensureRead(8)
|
||||
// TODO 是否要对 < Number.MAX_SAFE_INTEGER 优化处理?
|
||||
const xl = buf.readUInt32BE(this._readerIndex + 4)
|
||||
const xh = buf.readUInt32BE(this._readerIndex) & 0xffffff
|
||||
// console.log(`== read8 ${xl} ${xh}`)
|
||||
this._readerIndex += 8
|
||||
return (BigInt(xh) << BigInt(32)) | BigInt(xl)
|
||||
}
|
||||
else {
|
||||
this.ensureRead(9)
|
||||
const x = buf.readBigInt64BE(this._readerIndex + 1)
|
||||
// const xl = buf.readUInt32BE(this._readerIndex + 5)
|
||||
// const xh = buf.readInt32BE(this._readerIndex + 1)
|
||||
this._readerIndex += 9
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
readFloat(): number {
|
||||
this.ensureRead(4)
|
||||
const x = this._bytes.readFloatLE(this._readerIndex)
|
||||
this._readerIndex += 4
|
||||
return x
|
||||
}
|
||||
|
||||
readDouble(): number {
|
||||
this.ensureRead(8)
|
||||
const x = this._bytes.readDoubleLE(this._readerIndex)
|
||||
this._readerIndex += 8
|
||||
return x
|
||||
}
|
||||
|
||||
readSize(): number {
|
||||
return this.readInt()
|
||||
}
|
||||
|
||||
// marshal int
|
||||
// n -> (n << 1) ^ (n >> 31)
|
||||
// read
|
||||
// (x >>> 1) ^ ((x << 31) >> 31)
|
||||
// (x >>> 1) ^ -(n&1)
|
||||
// WriteSint(x: number)
|
||||
// {
|
||||
// WriteUint(((uint)x << 1) ^ ((uint)x >> 31))
|
||||
// }
|
||||
|
||||
// readSint: number()
|
||||
// {
|
||||
// x: number = readUint()
|
||||
// return (int)((x >> 1) ^ ((x & 1) << 31))
|
||||
// }
|
||||
|
||||
|
||||
// marshal long
|
||||
// n -> (n << 1) ^ (n >> 63)
|
||||
// read
|
||||
// (x >>> 1) ^((x << 63) >> 63)
|
||||
// (x >>> 1) ^ -(n&1L)
|
||||
// WriteSlong(long x)
|
||||
// {
|
||||
// WriteUlong(((ulong)x << 1) ^ ((ulong)x >> 63))
|
||||
// }
|
||||
|
||||
// long readSlong()
|
||||
// {
|
||||
// long x = readLong()
|
||||
// return ((long)((ulong)x >> 1) ^ ((x & 1) << 63))
|
||||
// }
|
||||
|
||||
// // Uint8Array, [start, end)
|
||||
// static Func < Uint8Array, int, int, string > StringCacheFinder { get set }
|
||||
|
||||
readString(): string {
|
||||
const n = this.readSize()
|
||||
if (n > 0) {
|
||||
this.ensureRead(n)
|
||||
const s = this._bytes.toString("utf-8", this._readerIndex, this._readerIndex + n)
|
||||
this._readerIndex += n
|
||||
return s
|
||||
}
|
||||
else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
readBytes(): Uint8Array {
|
||||
const n = this.readSize()
|
||||
if (n > 0) {
|
||||
this.ensureRead(n)
|
||||
const x = Buffer.from(this._bytes.slice(this._readerIndex, this._readerIndex + n))
|
||||
this._readerIndex += n
|
||||
return x
|
||||
}
|
||||
else {
|
||||
return ByteBuf.emptyBuff
|
||||
}
|
||||
}
|
||||
|
||||
readArrayBuffer(): ArrayBuffer {
|
||||
return this.readBytes().buffer
|
||||
}
|
||||
|
||||
SkipBytes() {
|
||||
const n = this.readSize()
|
||||
this.ensureRead(n)
|
||||
this._readerIndex += n
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "547c38d1-76a2-4bee-9000-29c96b2a7958",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "d847d059-a5e7-46b6-b224-253ed497f46c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
import ByteBuf from '../luban/ByteBuf'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export namespace demo {
|
||||
export class item {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this.id = _buf_.readInt()
|
||||
this.name = _buf_.readString()
|
||||
this.desc = _buf_.readString()
|
||||
this.count = _buf_.readInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
readonly id: number
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
readonly name: string
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
readonly desc: string
|
||||
/**
|
||||
* 个数
|
||||
*/
|
||||
readonly count: number
|
||||
|
||||
resolve(tables:Tables) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export namespace demo {
|
||||
export class Reward {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this.id = _buf_.readInt()
|
||||
this.name = _buf_.readString()
|
||||
this.desc = _buf_.readString()
|
||||
this.count = _buf_.readInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
readonly id: number
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
readonly name: string
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
readonly desc: string
|
||||
/**
|
||||
* 个数
|
||||
*/
|
||||
readonly count: number
|
||||
|
||||
resolve(tables:Tables) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class vector2 {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this.x = _buf_.readFloat()
|
||||
this.y = _buf_.readFloat()
|
||||
}
|
||||
|
||||
readonly x: number
|
||||
readonly y: number
|
||||
|
||||
resolve(tables:Tables) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class vector3 {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this.x = _buf_.readFloat()
|
||||
this.y = _buf_.readFloat()
|
||||
this.z = _buf_.readFloat()
|
||||
}
|
||||
|
||||
readonly x: number
|
||||
readonly y: number
|
||||
readonly z: number
|
||||
|
||||
resolve(tables:Tables) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class vector4 {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this.x = _buf_.readFloat()
|
||||
this.y = _buf_.readFloat()
|
||||
this.z = _buf_.readFloat()
|
||||
this.w = _buf_.readFloat()
|
||||
}
|
||||
|
||||
readonly x: number
|
||||
readonly y: number
|
||||
readonly z: number
|
||||
readonly w: number
|
||||
|
||||
resolve(tables:Tables) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export namespace demo {
|
||||
export class TbReward {
|
||||
private _dataMap: Map<number, demo.Reward>
|
||||
private _dataList: demo.Reward[]
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this._dataMap = new Map<number, demo.Reward>()
|
||||
this._dataList = []
|
||||
for(let n = _buf_.readInt(); n > 0; n--) {
|
||||
let _v: demo.Reward
|
||||
_v = new demo.Reward(_buf_)
|
||||
this._dataList.push(_v)
|
||||
this._dataMap.set(_v.id, _v)
|
||||
}
|
||||
}
|
||||
|
||||
getDataMap(): Map<number, demo.Reward> { return this._dataMap; }
|
||||
getDataList(): demo.Reward[] { return this._dataList; }
|
||||
|
||||
get(key: number): demo.Reward | undefined {
|
||||
return this._dataMap.get(key);
|
||||
}
|
||||
|
||||
resolve(tables:Tables) {
|
||||
for(let data of this._dataList)
|
||||
{
|
||||
data.resolve(tables)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export namespace demo {
|
||||
export class Tbitem {
|
||||
private _dataMap: Map<number, demo.item>
|
||||
private _dataList: demo.item[]
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this._dataMap = new Map<number, demo.item>()
|
||||
this._dataList = []
|
||||
for(let n = _buf_.readInt(); n > 0; n--) {
|
||||
let _v: demo.item
|
||||
_v = new demo.item(_buf_)
|
||||
this._dataList.push(_v)
|
||||
this._dataMap.set(_v.id, _v)
|
||||
}
|
||||
}
|
||||
|
||||
getDataMap(): Map<number, demo.item> { return this._dataMap; }
|
||||
getDataList(): demo.item[] { return this._dataList; }
|
||||
|
||||
get(key: number): demo.item | undefined {
|
||||
return this._dataMap.get(key);
|
||||
}
|
||||
|
||||
resolve(tables:Tables) {
|
||||
for(let data of this._dataList)
|
||||
{
|
||||
data.resolve(tables)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
type ByteBufLoader = (file: string) => ByteBuf
|
||||
|
||||
export class Tables {
|
||||
private _TbReward: demo.TbReward
|
||||
get TbReward(): demo.TbReward { return this._TbReward;}
|
||||
private _Tbitem: demo.Tbitem
|
||||
get Tbitem(): demo.Tbitem { return this._Tbitem;}
|
||||
|
||||
static getTableNames(): string[] {
|
||||
let names: string[] = [];
|
||||
names.push('demo_tbreward');
|
||||
names.push('demo_tbitem');
|
||||
return names;
|
||||
}
|
||||
|
||||
constructor(loader: ByteBufLoader) {
|
||||
this._TbReward = new demo.TbReward(loader('demo_tbreward'))
|
||||
this._Tbitem = new demo.Tbitem(loader('demo_tbitem'))
|
||||
|
||||
this._TbReward.resolve(this)
|
||||
this._Tbitem.resolve(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "330f072d-4952-424b-acb9-1511e42cdfb0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user