107 lines
3.3 KiB
Plaintext
107 lines
3.3 KiB
Plaintext
/*
|
|
文件名:FatalismStone_BackPack.nut
|
|
路径:Project/FatalismStone/FatalismStone_BackPack.nut
|
|
创建日期:2025-08-27 17:54
|
|
文件用途:魂石背包类
|
|
*/
|
|
|
|
//魂石背包类
|
|
class FatalismStone_BackPack {
|
|
|
|
//背包总格子数
|
|
GridCount = 77;
|
|
//穿戴总格子数
|
|
WearCount = 6;
|
|
|
|
StoneArr = null;
|
|
|
|
|
|
constructor() {
|
|
StoneArr = [];
|
|
|
|
//魂石单个数据回包
|
|
Rindro_BaseToolClass.RegisterHexPack(21000012, function(Pack) {
|
|
local Uuid = Pack.GetInt();
|
|
local Info = {
|
|
Cultivation = Pack.GetInt().tofloat() * 0.01,
|
|
}
|
|
foreach(StoneObject in StoneArr) {
|
|
if (!StoneObject) continue;
|
|
if (StoneObject.Uuid == Uuid) {
|
|
StoneObject.InitializeData(Info);
|
|
break;
|
|
}
|
|
}
|
|
}.bindenv(this));
|
|
|
|
//魂石多个数据回包
|
|
Rindro_BaseToolClass.RegisterHexPack(21000014, function(Pack) {
|
|
local Count = Pack.GetInt();
|
|
for (local i = 0; i< Count; i++) {
|
|
local Uuid = Pack.GetInt();
|
|
local Info = {
|
|
Cultivation = Pack.GetInt().tofloat() * 0.01,
|
|
}
|
|
foreach(StoneObject in StoneArr) {
|
|
if (!StoneObject) continue;
|
|
if (StoneObject.Uuid == Uuid) {
|
|
StoneObject.InitializeData(Info);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}.bindenv(this));
|
|
}
|
|
|
|
//通过数据构造背包 反序列化
|
|
function Deserialize(N_Data) {
|
|
local BackpackData = N_Data[0];
|
|
local WearData = N_Data[1];
|
|
|
|
//转换背包数据
|
|
local BackPackArr = [];
|
|
for (local i = 0; i<(GridCount * 3); i++) {
|
|
local StoneId = BackpackData.add(i * 8).readInt();
|
|
local StoneUuid = BackpackData.add(i * 8 + 4).readInt();
|
|
if (StoneId != 0 && StoneUuid != 0) {
|
|
local StoneObj = FatalismStone_Stone(StoneId);
|
|
StoneObj.Stone_Type = i / GridCount;
|
|
StoneObj.Uuid = StoneUuid;
|
|
BackPackArr.append(StoneObj);
|
|
} else {
|
|
BackPackArr.append(null);
|
|
}
|
|
}
|
|
//转化穿戴数据
|
|
local WearArr = [];
|
|
for (local i = 0; i< WearCount; i++) {
|
|
local StoneId = WearData.add(i * 8).readInt();
|
|
local StoneUuid = WearData.add(i * 8 + 4).readInt();
|
|
if (StoneId != 0 && StoneUuid != 0) {
|
|
local StoneObj = FatalismStone_Stone(StoneId);
|
|
StoneObj.Uuid = StoneUuid;
|
|
WearArr.append(StoneObj);
|
|
} else {
|
|
WearArr.append(null);
|
|
}
|
|
}
|
|
|
|
//两段数据放入总数据
|
|
StoneArr.extend(BackPackArr);
|
|
StoneArr.extend(WearArr);
|
|
}
|
|
|
|
//获取魂石的列表 3为身上穿戴的
|
|
function GetList(Page) {
|
|
local SliceLength = GridCount;
|
|
if (Page == 3) SliceLength = WearCount;
|
|
return StoneArr.slice(Page * 77, Page * 77 + SliceLength);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
L_Windows_List <- [];
|
|
getroottable().rawdelete("LenheartPluginsInitFlag");
|
|
getroottable().rawdelete("EventList_Obj")
|
|
getroottable().rawdelete("FatalismStone_Obj"); |