From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XBagDocument.cs | 2047 +++++++++++++++++++++ 1 file changed, 2047 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XBagDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XBagDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XBagDocument.cs b/Client/Assets/Scripts/XMainClient/XBagDocument.cs new file mode 100644 index 00000000..6c4fca29 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XBagDocument.cs @@ -0,0 +1,2047 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using XMainClient.UI; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XBagDocument : XDocComponent + { + public override uint ID + { + get + { + return XBagDocument.uuID; + } + } + + public static DropList DropTable + { + get + { + return XBagDocument.m_DropTable; + } + } + + public static XBagDocument BagDoc + { + get + { + return XSingleton.singleton.Doc.XBagDoc; + } + } + + public static PandoraHeart PandoraHeartTable + { + get + { + return XBagDocument.m_PandoraHeartTable; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("XBagDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static ItemList m_ItemTable = new ItemList(); + + private static DropList m_DropTable = new DropList(); + + private static ChestList m_ChestTable = new ChestList(); + + private static EquipList m_EquipTable = new EquipList(); + + private static EmblemBasic m_EmblemTable = new EmblemBasic(); + + private static FashionList m_FashionTable = new FashionList(); + + private static PandoraHeart m_PandoraHeartTable = new PandoraHeart(); + + private static BagExpandItemListTable m_BagExpandItemListTable = new BagExpandItemListTable(); + + private static Dictionary> m_ChestRange = new Dictionary>(); + + private static Dictionary> m_AuctionRange = new Dictionary>(); + + public XBag ItemBag; + + public static readonly int EquipMax = XBagDocument.BodyPosition(EquipPosition.EQUIP_END); + + public static readonly int FashionMax = XBagDocument.BodyPosition(FashionPosition.FASHION_END); + + public static readonly int EmblemMax = XBagDocument.BodyPosition(EmblemPosition.EMBLEM_END); + + public static readonly int VirtualItemMax = XBagDocument.BodyPosition(ItemEnum.VIRTUAL_ITEM_MAX); + + public static readonly int ArtifactMax = XBagDocument.BodyPosition(ArtifactPosition.ARTIFACT_END); + + private static readonly uint ITEM_PROFESSION_MASK = 100000u; + + public static readonly int QualityCount = 6; + + public XBodyBag EquipBag = new XBodyBag(XBagDocument.EquipMax); + + public XBodyBag EmblemBag = new XBodyBag(XBagDocument.EmblemMax); + + public XBodyBag ArtifactBag = new XBodyBag(XBagDocument.ArtifactMax); + + public ulong[] VirtualItems = new ulong[XBagDocument.VirtualItemMax]; + + public ulong TearsCount = 0UL; + + public List BagExpandDataList = new List + { + new BagExpandData(BagType.ItemBag), + new BagExpandData(BagType.EmblemBag), + new BagExpandData(BagType.EquipBag), + new BagExpandData(BagType.ArtifactBag) + }; + + public static CVSReader.RowDataCompare comp = new CVSReader.RowDataCompare(XBagDocument.DropDataCompare); + + private BagExpandItemListTable.RowData m_usedBagExpandRow = null; + + private Dictionary basicAttrPool = new Dictionary(); + + private Dictionary equipAdditionalAttrPool = new Dictionary(); + + private bool getallEquip = false; + + private int fashionIndex = 0; + + private float fashionTime = 0f; + + public void GetItemsByType(ulong typeFilter, ref List list) + { + for (int i = 0; i < this.ItemBag.Count; i++) + { + ulong num = 1UL << (int)this.ItemBag[i].type; + bool flag = (num & typeFilter) > 0UL; + if (flag) + { + list.Add(this.ItemBag[i]); + } + } + } + + public List GetNotBindItemsByType(int typeFilter) + { + List list = new List(); + for (int i = 0; i < this.ItemBag.Count; i++) + { + bool bBinding = this.ItemBag[i].bBinding; + if (!bBinding) + { + int num = 1 << (int)this.ItemBag[i].type; + bool flag = (num & typeFilter) > 0; + if (flag) + { + list.Add(this.ItemBag[i]); + } + } + } + return list; + } + + public List GetItemsByTypeAndQuality(ulong typeFilter, ItemQuality quality) + { + List list = new List(); + for (int i = 0; i < this.ItemBag.Count; i++) + { + ulong num = 1UL << (int)this.ItemBag[i].type; + bool flag = (num & typeFilter) > 0UL && (ItemQuality)this.ItemBag[i].itemConf.ItemQuality == quality; + if (flag) + { + list.Add(this.ItemBag[i]); + } + } + return list; + } + + public static void Execute(OnLoadedCallback callback = null) + { + XBagDocument.AsyncLoader.AddTask("Table/ItemList", XBagDocument.m_ItemTable, false); + XBagDocument.AsyncLoader.AddTask("Table/ChestList", XBagDocument.m_ChestTable, false); + XBagDocument.AsyncLoader.AddTask("Table/EquipList", XBagDocument.m_EquipTable, false); + XBagDocument.AsyncLoader.AddTask("Table/FashionList", XBagDocument.m_FashionTable, false); + XBagDocument.AsyncLoader.AddTask("Table/EmblemBasic", XBagDocument.m_EmblemTable, false); + XBagDocument.AsyncLoader.AddTask("Table/DropList", XBagDocument.m_DropTable, false); + XBagDocument.AsyncLoader.AddTask("Table/PandoraHeart", XBagDocument.m_PandoraHeartTable, false); + XBagDocument.AsyncLoader.AddTask("Table/BagExpandItemList", XBagDocument.m_BagExpandItemListTable, false); + XBagDocument.AsyncLoader.Execute(callback); + XBagDocument.m_ChestRange.Clear(); + XBagDocument.m_AuctionRange.Clear(); + } + + public static void OnTableLoaded() + { + XBagDocument.BuildChestTable(); + XBagDocument.BuildAuctionRange(); + } + + public static void BuildAuctionRange() + { + ItemList.RowData[] table = XBagDocument.m_ItemTable.Table; + int i = 0; + int num = table.Length; + while (i < num) + { + ItemList.RowData rowData = table[i]; + bool flag = !rowData.CanTrade || rowData.AuctionType == null; + if (!flag) + { + int j = 0; + int num2 = rowData.AuctionType.Length; + while (j < num2) + { + List list; + bool flag2 = !XBagDocument.m_AuctionRange.TryGetValue((uint)rowData.AuctionType[j], out list); + if (flag2) + { + list = new List(); + XBagDocument.m_AuctionRange.Add((uint)rowData.AuctionType[j], list); + } + list.Add(rowData); + j++; + } + } + i++; + } + } + + public static void BuildChestTable() + { + int i = 0; + int num = XBagDocument.m_ChestTable.Table.Length; + while (i < num) + { + List list; + bool flag = !XBagDocument.m_ChestRange.TryGetValue(XBagDocument.m_ChestTable.Table[i].ItemID, out list); + if (flag) + { + list = new List(); + XBagDocument.m_ChestRange.Add(XBagDocument.m_ChestTable.Table[i].ItemID, list); + } + list.Add(XBagDocument.m_ChestTable.Table[i]); + i++; + } + } + + public static bool TryGetAuctionList(uint auctionID, out List list) + { + return XBagDocument.m_AuctionRange.TryGetValue(auctionID, out list); + } + + public static uint GetItemProf(int itemid) + { + ItemList.RowData byItemID = XBagDocument.m_ItemTable.GetByItemID(itemid); + bool flag = byItemID == null; + uint result; + if (flag) + { + result = 0u; + } + else + { + result = (uint)byItemID.Profession; + } + return result; + } + + public static int ConvertTemplate(ItemList.RowData rowData) + { + bool flag = rowData == null; + int result; + if (flag) + { + result = 0; + } + else + { + bool flag2 = rowData.ItemType == 12; + if (flag2) + { + result = rowData.ItemID + (int)(XItemDrawerParam.DefaultProfession * XBagDocument.ITEM_PROFESSION_MASK); + } + else + { + result = rowData.ItemID; + } + } + return result; + } + + public static int ConvertTemplate(int itemid) + { + ItemList.RowData byItemID = XBagDocument.m_ItemTable.GetByItemID(itemid); + bool flag = byItemID == null; + int result; + if (flag) + { + result = itemid; + } + else + { + result = XBagDocument.ConvertTemplate(byItemID); + } + return result; + } + + public static bool IsProfMatched(uint prof) + { + return prof == 0u || prof % 10u == XItemDrawerParam.DefaultProfession; + } + + public static bool IsProfMatchedFeable(uint prof, uint profecssion, bool feable = false) + { + return prof == 0u || (feable ? (prof % 10u == profecssion % 10u) : (prof == profecssion)); + } + + public static bool IsProfMatchedWithFeable(uint prof) + { + return prof == 0u || prof == XItemDrawerParam.DefaultProfession; + } + + public static bool IsProfEqual(uint prof) + { + return prof % 10u == XItemDrawerParam.DefaultProfession; + } + + public static string GetItemSmallIcon(int itemid, uint profession = 0u) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf(itemid); + bool flag = itemConf == null; + string result; + if (flag) + { + result = string.Empty; + } + else + { + result = XSingleton.singleton.ChooseProfString(itemConf.ItemIcon1, profession); + } + return result; + } + + public static void GetItemBigIconAndAtlas(int itemid, out string icon, out string atlas, uint profession = 0u) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf(itemid); + bool flag = itemConf == null; + if (flag) + { + icon = string.Empty; + atlas = string.Empty; + } + else + { + icon = XSingleton.singleton.ChooseProfString(itemConf.ItemIcon, profession); + atlas = XSingleton.singleton.ChooseProfString(itemConf.ItemAtlas, profession); + } + } + + public static void GetItemSmallIconAndAtlas(int itemid, out string icon, out string atlas, uint profession = 0u) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf(itemid); + bool flag = itemConf == null; + if (flag) + { + icon = string.Empty; + atlas = string.Empty; + } + else + { + icon = XSingleton.singleton.ChooseProfString(itemConf.ItemIcon1, profession); + atlas = XSingleton.singleton.ChooseProfString(itemConf.ItemAtlas1, profession); + } + } + + public static uint GetAuctionRecommendPrice(int itemID) + { + return XBagDocument.m_ItemTable.GetByItemID(itemID).AuctPriceRecommend; + } + + public static FashionList.RowData GetFashionConf(int itemID) + { + return XBagDocument.m_FashionTable.GetByItemID(itemID); + } + + public static ItemList.RowData GetItemConf(int itemID) + { + return XBagDocument.m_ItemTable.GetByItemID(itemID); + } + + public static EquipList.RowData GetEquipConf(int itemID) + { + return XBagDocument.m_EquipTable.GetByItemID(itemID); + } + + public static BagExpandItemListTable.RowData GetExpandItemConf(uint itemId) + { + return XBagDocument.m_BagExpandItemListTable.GetByItemId(itemId); + } + + public static BagExpandItemListTable.RowData GetExpandItemConfByType(uint itemId) + { + return XBagDocument.m_BagExpandItemListTable.GetByType(itemId); + } + + public static PandoraHeart.RowData GetPandoraHeartConf(int itemID, uint profID) + { + for (int i = 0; i < XBagDocument.m_PandoraHeartTable.Table.Length; i++) + { + bool flag = ((long)itemID == (long)((ulong)XBagDocument.m_PandoraHeartTable.Table[i].PandoraID) || (long)itemID == (long)((ulong)XBagDocument.m_PandoraHeartTable.Table[i].FireID)) && (profID == XBagDocument.m_PandoraHeartTable.Table[i].ProfID || XBagDocument.m_PandoraHeartTable.Table[i].ProfID == 0u); + if (flag) + { + return XBagDocument.m_PandoraHeartTable.Table[i]; + } + } + return null; + } + + public static EmblemBasic.RowData GetEmblemConf(int emblemID) + { + return XBagDocument.m_EmblemTable.GetByEmblemID((uint)emblemID); + } + + public static ChestList.RowData GetChestConf(int itemID) + { + for (int i = 0; i < XBagDocument.m_ChestTable.Table.Length; i++) + { + bool flag = XBagDocument.m_ChestTable.Table[i].ItemID == itemID; + if (flag) + { + return XBagDocument.m_ChestTable.Table[i]; + } + } + return null; + } + + public static bool TryGetChestListConf(int itemID, out List chestList) + { + return XBagDocument.m_ChestRange.TryGetValue(itemID, out chestList); + } + + private static int DropDataCompare(DropList.RowData rowData, int dropID) + { + return dropID.CompareTo(rowData.DropID); + } + + public static bool TryGetDropConf(uint[] dropIDs, ref List dropList) + { + bool flag = dropIDs != null; + if (flag) + { + for (int i = 0; i < dropIDs.Length; i++) + { + int num; + int num2; + CVSReader.GetRowDataListByField(XBagDocument.DropTable.Table, (int)dropIDs[i], out num, out num2, XBagDocument.comp); + bool flag2 = num < 0; + if (!flag2) + { + for (int j = num; j <= num2; j++) + { + dropList.Add(XBagDocument.DropTable.Table[j]); + } + } + } + } + return dropList.Count > 0; + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + this.ItemBag = new XBag(); + } + + protected override void EventSubscribe() + { + base.EventSubscribe(); + base.RegisterEvent(XEventDefine.XEvent_RemoveItem, new XComponent.XEventHandler(this.OnRemoveItem)); + base.RegisterEvent(XEventDefine.XEvent_UpdateItem, new XComponent.XEventHandler(this.OnUpdateItem)); + } + + protected bool OnRemoveItem(XEventArgs args) + { + XRemoveItemEventArgs xremoveItemEventArgs = args as XRemoveItemEventArgs; + foreach (ulong uid in xremoveItemEventArgs.uids) + { + this._RemoveCompareAttrsFromPool(uid); + } + return true; + } + + protected bool OnUpdateItem(XEventArgs args) + { + XUpdateItemEventArgs xupdateItemEventArgs = args as XUpdateItemEventArgs; + this._RemoveCompareAttrsFromPool(xupdateItemEventArgs.item.uid); + return true; + } + + public override void OnLeaveScene() + { + base.OnLeaveScene(); + this.basicAttrPool.Clear(); + this.equipAdditionalAttrPool.Clear(); + this.getallEquip = false; + } + + public BagExpandData GetBagExpandData(BagType type) + { + for (int i = 0; i < this.BagExpandDataList.Count; i++) + { + bool flag = this.BagExpandDataList[i].Type == type; + if (flag) + { + return this.BagExpandDataList[i]; + } + } + return null; + } + + public void SwapItem(ulong uid1, ulong uid2) + { + int num = 0; + XItem xitem = null; + XItem xitem2 = null; + bool flag = uid1 != 0UL && this.ItemBag.FindItem(uid1, out num); + if (flag) + { + xitem = this.ItemBag[num]; + } + int num2 = 0; + XBodyBag xbodyBag = null; + bool flag2 = false; + bool flag3 = uid2 != 0UL && this.GetBodyPosByUID(uid2, out num2, out xbodyBag, out flag2); + if (flag3) + { + xitem2 = xbodyBag[num2]; + } + bool flag4 = xitem != null && xitem2 != null; + if (flag4) + { + bool flag5 = xitem.type != xitem2.type; + if (!flag5) + { + this.ItemBag[num] = xitem2; + xbodyBag[num2] = xitem; + this.ItemBag.SortItem(); + XSwapItemEventArgs @event = XEventPool.GetEvent(); + @event.itemNowOnBody = xitem; + @event.itemNowInBag = xitem2; + @event.slot = num2; + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + } + } + else + { + bool flag6 = xitem != null; + if (flag6) + { + xbodyBag = xitem.Description.BodyBag; + bool flag7 = xbodyBag == null; + if (!flag7) + { + ItemType type = xitem.Type; + if (type != ItemType.EQUIP) + { + if (type != ItemType.EMBLEM) + { + if (type == ItemType.ARTIFACT) + { + ArtifactListTable.RowData artifactListRowData = ArtifactDocument.GetArtifactListRowData((uint)xitem.itemID); + num2 = (int)artifactListRowData.ArtifactPos; + flag2 = true; + } + } + else + { + EmblemBasic.RowData emblemConf = XBagDocument.GetEmblemConf(xitem.itemID); + bool flag8 = !XEmblemDocument.GetFirstEmptyEmblemSlot(this.EmblemBag, emblemConf.EmblemType, out num2); + if (flag8) + { + XSingleton.singleton.AddErrorLog("Failed to equip emblem cause it's full.", null, null, null, null, null); + return; + } + } + } + else + { + EquipList.RowData equipConf = XBagDocument.GetEquipConf(xitem.itemID); + num2 = (int)equipConf.EquipPos; + flag2 = true; + } + xbodyBag[num2] = xitem; + this.ItemBag.RemoveIndex(num); + XRemoveItemEventArgs event2 = XEventPool.GetEvent(); + event2.uids.Add(uid1); + event2.types.Add(xitem.Type); + event2.ids.Add(xitem.itemID); + event2.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(event2); + XLoadEquipEventArgs event3 = XEventPool.GetEvent(); + event3.item = xitem; + event3.slot = num2; + event3.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(event3); + } + } + else + { + bool flag9 = xitem2 != null; + if (flag9) + { + xbodyBag[num2] = null; + this.ItemBag.AddItem(xitem2, true); + XAddItemEventArgs event4 = XEventPool.GetEvent(); + event4.items.Add(xitem2); + event4.Firer = XSingleton.singleton.Doc; + event4.bNew = false; + XSingleton.singleton.FireEvent(event4); + XUnloadEquipEventArgs event5 = XEventPool.GetEvent(); + event5.slot = num2; + event5.item = xitem2; + event5.type = xitem2.Type; + event5.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(event5); + } + } + } + } + + public void UseItem(XItem item, uint opType = 0u) + { + RpcC2G_UseItem rpcC2G_UseItem = new RpcC2G_UseItem(); + rpcC2G_UseItem.oArg.uid = item.uid; + rpcC2G_UseItem.oArg.count = 1u; + rpcC2G_UseItem.oArg.OpType = opType; + rpcC2G_UseItem.oArg.itemID = (uint)item.itemID; + XSingleton.singleton.Send(rpcC2G_UseItem); + } + + public void UseItem(XItem item, uint opType, uint count) + { + RpcC2G_UseItem rpcC2G_UseItem = new RpcC2G_UseItem(); + rpcC2G_UseItem.oArg.uid = item.uid; + rpcC2G_UseItem.oArg.count = count; + rpcC2G_UseItem.oArg.OpType = opType; + XSingleton.singleton.Send(rpcC2G_UseItem); + } + + private static void MakeXEquipItem(ref XItem item, Item KKSGItem) + { + bool flag = item == null; + if (flag) + { + item = XDataPool.GetData(); + } + XEquipItem xequipItem = item as XEquipItem; + bool flag2 = xequipItem == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("Cant create XEquipItem", null, null, null, null, null); + } + else + { + xequipItem.smeltDegreeNum = KKSGItem.smeltCount; + xequipItem.enhanceInfo.EnhanceLevel = KKSGItem.EnhanceLevel; + xequipItem.enhanceInfo.EnhanceTimes = KKSGItem.EnhanceCount; + bool flag3 = KKSGItem.AttrID.Count != KKSGItem.AttrValue.Count; + if (flag3) + { + XSingleton.singleton.AddLog("KKSGItem.EnhanceInfo.AttrID.Count != KKSGItem.EnhanceInfo.AttrValue.Count", null, null, null, null, null, XDebugColor.XDebug_None); + } + else + { + for (int i = 0; i < KKSGItem.EnhanceAttrId.Count; i++) + { + XItemChangeAttr item2; + item2.AttrID = KKSGItem.EnhanceAttrId[i]; + item2.AttrValue = KKSGItem.EnhanceAttrValue[i]; + xequipItem.enhanceInfo.EnhanceAttr.Add(item2); + } + xequipItem.changeAttr.Clear(); + EquipList.RowData equipConf = XBagDocument.GetEquipConf((int)KKSGItem.ItemID); + bool flag4 = equipConf != null; + if (flag4) + { + for (int j = 0; j < (int)equipConf.Attributes.count; j++) + { + XItemChangeAttr item3; + item3.AttrID = (uint)equipConf.Attributes[j, 0]; + item3.AttrValue = (uint)equipConf.Attributes[j, 1]; + xequipItem.changeAttr.Add(item3); + } + } + bool flag5 = KKSGItem.ItemJade != null; + if (flag5) + { + for (int k = 0; k < KKSGItem.ItemJade.ItemJadeSingle.Count; k++) + { + ItemJadeSingle itemJadeSingle = KKSGItem.ItemJade.ItemJadeSingle[k]; + XJadeItem data = XDataPool.GetData(); + data.itemID = (int)itemJadeSingle.ItemId; + data.type = (uint)XFastEnumIntEqualityComparer.ToInt(ItemType.JADE); + data.uid = 0UL; + data.itemCount = 1; + data.bBinding = true; + for (int l = 0; l < itemJadeSingle.AttrId.Count; l++) + { + uint attrID = itemJadeSingle.AttrId[l]; + XItemChangeAttr item4; + item4.AttrID = attrID; + item4.AttrValue = itemJadeSingle.AttrValue[l]; + data.changeAttr.Add(item4); + } + xequipItem.jadeInfo.jades[(int)itemJadeSingle.SlotPos] = data; + } + } + xequipItem.attrType = AttrType.None; + bool flag6 = KKSGItem.randAttr != null; + if (flag6) + { + for (int m = 0; m < KKSGItem.randAttr.attrs.Count; m++) + { + XItemChangeAttr xitemChangeAttr; + xitemChangeAttr.AttrID = KKSGItem.randAttr.attrs[m].id; + xitemChangeAttr.AttrValue = KKSGItem.randAttr.attrs[m].value; + xequipItem.randAttrInfo.RandAttr.Add(xitemChangeAttr); + bool flag7 = xequipItem.attrType > AttrType.None; + if (!flag7) + { + bool flag8 = xitemChangeAttr.AttrID == 11u; + if (flag8) + { + xequipItem.attrType = AttrType.Physics; + } + else + { + bool flag9 = xitemChangeAttr.AttrID == 21u; + if (flag9) + { + xequipItem.attrType = AttrType.Magic; + } + } + } + } + } + bool flag10 = KKSGItem.forge != null; + if (flag10) + { + for (int n = 0; n < KKSGItem.forge.attrs.Count; n++) + { + XItemChangeAttr item5; + item5.AttrID = KKSGItem.forge.attrs[n].id; + item5.AttrValue = KKSGItem.forge.attrs[n].value; + xequipItem.forgeAttrInfo.ForgeAttr.Add(item5); + } + bool flag11 = KKSGItem.forge.unReplacedAttr != null; + if (flag11) + { + xequipItem.forgeAttrInfo.UnSavedAttrid = KKSGItem.forge.unReplacedAttr.id; + xequipItem.forgeAttrInfo.UnSavedAttrValue = KKSGItem.forge.unReplacedAttr.value; + } + else + { + xequipItem.forgeAttrInfo.UnSavedAttrid = 0u; + xequipItem.forgeAttrInfo.UnSavedAttrValue = 0u; + } + } + bool flag12 = KKSGItem.enchant != null; + if (flag12) + { + xequipItem.enchantInfo.ChooseAttr = KKSGItem.enchant.chooseAttrid; + bool flag13 = KKSGItem.enchant.chooseAttrid > 0u; + if (flag13) + { + for (int num = 0; num < KKSGItem.enchant.allAttrs.Count; num++) + { + XItemChangeAttr item6; + item6.AttrID = KKSGItem.enchant.allAttrs[num].id; + item6.AttrValue = KKSGItem.enchant.allAttrs[num].value; + xequipItem.enchantInfo.AttrList.Add(item6); + } + bool flag14 = KKSGItem.enchant.enchantids.Count > 0; + if (flag14) + { + xequipItem.enchantInfo.EnchantIDList = new List(KKSGItem.enchant.enchantids); + } + } + xequipItem.enchantInfo.EnchantItemID = (int)KKSGItem.enchant.enchantid; + } + bool flag15 = KKSGItem.fuse != null; + if (flag15) + { + xequipItem.fuseInfo.BreakNum = KKSGItem.fuse.fuseLevel; + xequipItem.fuseInfo.FuseExp = KKSGItem.fuse.fuseExpCount; + } + } + } + } + + private static void MakeXArtifactItem(ref XItem item, Item KKSGItem) + { + bool flag = item == null; + if (flag) + { + item = XDataPool.GetData(); + } + XArtifactItem xartifactItem = item as XArtifactItem; + bool flag2 = xartifactItem == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("Can not create artifactItem", null, null, null, null, null); + } + else + { + xartifactItem.RandAttrInfo.RandAttr.Clear(); + for (int i = 0; i < KKSGItem.AttrID.Count; i++) + { + XItemChangeAttr item2; + item2.AttrID = KKSGItem.AttrID[i]; + item2.AttrValue = KKSGItem.AttrValue[i]; + xartifactItem.RandAttrInfo.RandAttr.Add(item2); + } + bool flag3 = KKSGItem.artifact != null; + if (flag3) + { + for (int j = 0; j < KKSGItem.artifact.unReplacedAttr.Count; j++) + { + XItemChangeAttr item3 = default(XItemChangeAttr); + item3.AttrID = KKSGItem.artifact.unReplacedAttr[j].id; + item3.AttrValue = KKSGItem.artifact.unReplacedAttr[j].value; + xartifactItem.UnSavedAttr.Add(item3); + } + } + xartifactItem.EffectInfoList.Clear(); + for (int k = 0; k < KKSGItem.effects.Count; k++) + { + EffectData effectData = KKSGItem.effects[k]; + XArtifactEffectInfo item4 = default(XArtifactEffectInfo); + item4.Init(); + item4.EffectId = effectData.effectID; + item4.SetBaseProf(effectData.effectID); + item4.IsValid = effectData.isWork; + xartifactItem.EffectInfoList.Add(item4); + for (int l = 0; l < effectData.multiParams.Count; l++) + { + EffectMultiParams effectMultiParams = effectData.multiParams[l]; + bool flag4 = effectMultiParams == null; + if (!flag4) + { + XArtifactBuffInfo item5 = default(XArtifactBuffInfo); + item5.Init(); + item5.SetData(effectData.effectID, effectMultiParams.IDType, effectMultiParams.ID, effectMultiParams.effectParams); + bool flag5 = item4.BuffInfoList.Count == 0; + if (flag5) + { + item4.BuffInfoList.Add(item5); + } + else + { + for (int m = 0; m < item4.BuffInfoList.Count; m++) + { + bool flag6 = item5.SortId > item4.BuffInfoList[item4.BuffInfoList.Count - 1].SortId; + if (flag6) + { + item4.BuffInfoList.Add(item5); + break; + } + bool flag7 = item5.SortId < item4.BuffInfoList[m].SortId; + if (flag7) + { + item4.BuffInfoList.Insert(m, item5); + break; + } + } + } + } + } + } + } + } + + private static void MakeXEmblemItem(ref XItem item, Item KKSGItem) + { + bool flag = item == null; + if (flag) + { + item = XDataPool.GetData(); + } + XBagDocument.MakeXAttrItem(ref item, KKSGItem); + XEmblemItem xemblemItem = item as XEmblemItem; + bool flag2 = xemblemItem == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("Cant create XEmblemItem", null, null, null, null, null); + } + else + { + xemblemItem.smeltDegreeNum = KKSGItem.smeltCount; + xemblemItem.emblemInfo.thirdslot = KKSGItem.EmblemThirdSlot; + } + } + + private static void MakeXFashionItem(ref XItem item, Item KKSGItem) + { + bool flag = item == null; + if (flag) + { + item = XDataPool.GetData(); + } + XFashionItem xfashionItem = item as XFashionItem; + xfashionItem.fashionLevel = KKSGItem.FashionLevel; + } + + private static void MakeXJadeItem(ref XItem item, Item KKSGItem) + { + bool flag = item == null; + if (flag) + { + item = XDataPool.GetData(); + } + XBagDocument.MakeXAttrItem(ref item, KKSGItem); + XJadeItem xjadeItem = item as XJadeItem; + bool flag2 = xjadeItem == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("Cant create XJadeItem", null, null, null, null, null); + } + } + + private static void MakeXAttrItem(ref XItem item, Item KKSGItem) + { + bool flag = item == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("XItem == null", null, null, null, null, null); + } + else + { + XAttrItem xattrItem = item as XAttrItem; + bool flag2 = xattrItem == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("Cant create XAttrItem", null, null, null, null, null); + } + else + { + xattrItem.changeAttr.Clear(); + for (int i = 0; i < KKSGItem.AttrID.Count; i++) + { + uint attrID = KKSGItem.AttrID[i]; + XItemChangeAttr item2; + item2.AttrID = attrID; + item2.AttrValue = KKSGItem.AttrValue[i]; + xattrItem.changeAttr.Add(item2); + } + } + } + } + + private static void MakeXLotteryBoxItem(ref XItem item, Item KKSGItem) + { + bool flag = item == null; + if (flag) + { + item = XDataPool.GetData(); + } + XLotteryBoxItem xlotteryBoxItem = item as XLotteryBoxItem; + int num = 0; + while (num < KKSGItem.circleDrawDatas.Count && num < XLotteryBoxItem.POOL_SIZE) + { + CircleDrawData circleDrawData = KKSGItem.circleDrawDatas[num]; + bool flag2 = (ulong)circleDrawData.index >= (ulong)((long)XLotteryBoxItem.POOL_SIZE); + if (!flag2) + { + XItem xitem = xlotteryBoxItem.itemList[(int)circleDrawData.index]; + xitem.itemID = (int)circleDrawData.itemid; + xitem.itemCount = (int)circleDrawData.itemcount; + } + num++; + } + } + + public static XItem MakeXItem(int itemID, bool bBinding = false) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf(itemID); + XItem xitem = null; + bool flag = itemConf != null; + if (flag) + { + ItemType itemType = (ItemType)itemConf.ItemType; + ItemType itemType2 = itemType; + switch (itemType2) + { + case ItemType.EQUIP: + xitem = XDataPool.GetData(); + goto IL_7F; + case ItemType.PECK: + case ItemType.VIRTUAL_ITEM: + case ItemType.MATERAIL: + break; + case ItemType.FASHION: + xitem = XDataPool.GetData(); + goto IL_7F; + case ItemType.EMBLEM: + xitem = XDataPool.GetData(); + goto IL_7F; + case ItemType.JADE: + xitem = XDataPool.GetData(); + goto IL_7F; + default: + if (itemType2 == ItemType.ARTIFACT) + { + xitem = XDataPool.GetData(); + goto IL_7F; + } + break; + } + xitem = XDataPool.GetData(); + IL_7F: + xitem.itemID = itemID; + xitem.type = (uint)itemConf.ItemType; + xitem.itemCount = (int)XBagDocument.BagDoc.GetItemCount(itemID); + xitem.bBinding = bBinding; + xitem.blocking = 0.0; + xitem.itemConf = itemConf; + ItemType itemType3 = itemType; + switch (itemType3) + { + case ItemType.EQUIP: + { + EquipList.RowData equipConf = XBagDocument.GetEquipConf(itemID); + bool flag2 = equipConf != null; + if (flag2) + { + XEquipItem xequipItem = xitem as XEquipItem; + for (int i = 0; i < equipConf.Attributes.Count; i++) + { + XItemChangeAttr item; + item.AttrID = (uint)equipConf.Attributes[i, 0]; + item.AttrValue = (uint)equipConf.Attributes[i, 1]; + xequipItem.changeAttr.Add(item); + } + xequipItem.randAttrInfo.bPreview = true; + xequipItem.forgeAttrInfo.bPreview = true; + } + break; + } + case ItemType.PECK: + case ItemType.VIRTUAL_ITEM: + case ItemType.MATERAIL: + break; + case ItemType.FASHION: + { + XFashionDocument specificDocument = XDocuments.GetSpecificDocument(XFashionDocument.uuID); + SeqListRef fashionAttr = specificDocument.GetFashionAttr(itemID, 0); + XFashionItem xfashionItem = xitem as XFashionItem; + xfashionItem.itemCount = 1; + for (int j = 0; j < fashionAttr.Count; j++) + { + XItemChangeAttr item2; + item2.AttrID = fashionAttr[j, 0]; + item2.AttrValue = fashionAttr[j, 1]; + xfashionItem.changeAttr.Add(item2); + } + break; + } + case ItemType.EMBLEM: + { + XEmblemItem xemblemItem = xitem as XEmblemItem; + xemblemItem.emblemInfo.thirdslot = 10u; + xemblemItem.emblemInfo.level = (uint)itemConf.ReqLevel; + int num; + int num2; + XEquipCreateDocument.GetEmblemAttrDataByID((uint)xitem.itemID, out num, out num2); + bool flag3 = num >= 0; + if (flag3) + { + for (int k = num; k < num2; k++) + { + AttributeEmblem.RowData attributeEmblem = XEquipCreateDocument.GetAttributeEmblem(k); + bool flag4 = attributeEmblem.Position == 1 || attributeEmblem.Position == 2; + if (flag4) + { + XItemChangeAttr item3; + item3.AttrID = (uint)attributeEmblem.AttrID; + item3.AttrValue = attributeEmblem.Range[0]; + xemblemItem.changeAttr.Add(item3); + } + } + } + break; + } + case ItemType.JADE: + { + XJadeDocument specificDocument2 = XDocuments.GetSpecificDocument(XJadeDocument.uuID); + JadeTable.RowData byJadeID = specificDocument2.jadeTable.GetByJadeID((uint)itemID); + bool flag5 = byJadeID != null; + if (flag5) + { + XJadeItem xjadeItem = xitem as XJadeItem; + for (int l = 0; l < byJadeID.JadeAttributes.Count; l++) + { + XItemChangeAttr item4; + item4.AttrID = byJadeID.JadeAttributes[l, 0]; + item4.AttrValue = byJadeID.JadeAttributes[l, 1]; + xjadeItem.changeAttr.Add(item4); + } + } + break; + } + default: + if (itemType3 == ItemType.ARTIFACT) + { + XArtifactItem xartifactItem = xitem as XArtifactItem; + xartifactItem.RandAttrInfo.bPreview = true; + } + break; + } + } + else + { + XSingleton.singleton.AddErrorLog("Cant find item config for id: " + itemID.ToString(), null, null, null, null, null); + } + return xitem; + } + + public static XItem MakeXItem(Item KKSGItem) + { + XItem xitem = null; + ItemType itemType = (ItemType)KKSGItem.ItemType; + ItemType itemType2 = itemType; + switch (itemType2) + { + case ItemType.EQUIP: + XBagDocument.MakeXEquipItem(ref xitem, KKSGItem); + goto IL_8B; + case ItemType.PECK: + case ItemType.VIRTUAL_ITEM: + case ItemType.MATERAIL: + case ItemType.FRAGMENT: + break; + case ItemType.FASHION: + XBagDocument.MakeXFashionItem(ref xitem, KKSGItem); + goto IL_8B; + case ItemType.EMBLEM: + XBagDocument.MakeXEmblemItem(ref xitem, KKSGItem); + goto IL_8B; + case ItemType.JADE: + XBagDocument.MakeXJadeItem(ref xitem, KKSGItem); + goto IL_8B; + case ItemType.LOTTERY_BOX: + XBagDocument.MakeXLotteryBoxItem(ref xitem, KKSGItem); + goto IL_8B; + default: + if (itemType2 == ItemType.ARTIFACT) + { + XBagDocument.MakeXArtifactItem(ref xitem, KKSGItem); + goto IL_8B; + } + break; + } + xitem = XDataPool.GetData(); + IL_8B: + xitem.uid = KKSGItem.uid; + xitem.type = KKSGItem.ItemType; + xitem.itemID = (int)KKSGItem.ItemID; + xitem.itemCount = (int)KKSGItem.ItemCount; + xitem.bBinding = KKSGItem.isbind; + xitem.itemConf = XBagDocument.GetItemConf(xitem.itemID); + bool flag = xitem.itemConf == null && xitem.uid > 0UL; + if (flag) + { + XSingleton.singleton.AddGreenLog("Cant find item config for id: ", xitem.itemID.ToString(), ", uid = ", xitem.uid.ToString(), null, null); + } + xitem.bexpirationTime = KKSGItem.expirationTime; + double num = 0.0; + bool flag2 = KKSGItem.cooldown > 0u; + if (flag2) + { + num = XSingleton.singleton.TimeFormatLastTime(KKSGItem.cooldown, true); + bool flag3 = num < 0.0; + if (flag3) + { + num = 0.0; + } + } + xitem.blocking = num; + return xitem; + } + + public static XItem MakeFasionItemById(uint id) + { + XItem data = XDataPool.GetData(); + data.uid = 0UL; + data.type = 5u; + data.itemID = (int)id; + data.itemCount = 1; + return data; + } + + public bool GetBodyPosByUID(ulong uid, out int pos, out XBodyBag bag, out bool isEquip) + { + bool itemPos = this.EquipBag.GetItemPos(uid, out pos); + bool result; + if (itemPos) + { + bag = this.EquipBag; + isEquip = true; + result = true; + } + else + { + bool itemPos2 = this.EmblemBag.GetItemPos(uid, out pos); + if (itemPos2) + { + bag = this.EmblemBag; + isEquip = false; + result = true; + } + else + { + bool itemPos3 = this.ArtifactBag.GetItemPos(uid, out pos); + if (itemPos3) + { + bag = this.ArtifactBag; + isEquip = false; + result = true; + } + else + { + bag = null; + pos = -1; + isEquip = false; + result = false; + } + } + } + return result; + } + + public XItem GetBodyItemByUID(ulong uid) + { + XItem itemByUID = this.EquipBag.GetItemByUID(uid); + bool flag = itemByUID != null; + XItem result; + if (flag) + { + result = itemByUID; + } + else + { + itemByUID = this.EmblemBag.GetItemByUID(uid); + bool flag2 = itemByUID != null; + if (flag2) + { + result = itemByUID; + } + else + { + itemByUID = this.ArtifactBag.GetItemByUID(uid); + bool flag3 = itemByUID != null; + if (flag3) + { + result = itemByUID; + } + else + { + result = null; + } + } + } + return result; + } + + public XItem GetBodyItemByID(int id) + { + XItem itemByID = this.EquipBag.GetItemByID(id); + bool flag = itemByID != null; + XItem result; + if (flag) + { + result = itemByID; + } + else + { + itemByID = this.EmblemBag.GetItemByID(id); + bool flag2 = itemByID != null; + if (flag2) + { + result = itemByID; + } + else + { + itemByID = this.ArtifactBag.GetItemByID(id); + bool flag3 = itemByID != null; + if (flag3) + { + result = itemByID; + } + else + { + result = null; + } + } + } + return result; + } + + public int GetBodyItemCountByID(int id) + { + int itemCountByID = this.EquipBag.GetItemCountByID(id); + bool flag = itemCountByID == 0; + if (flag) + { + itemCountByID = this.EmblemBag.GetItemCountByID(id); + } + bool flag2 = itemCountByID == 0; + if (flag2) + { + itemCountByID = this.ArtifactBag.GetItemCountByID(id); + } + return itemCountByID; + } + + public XItem GetBagItemByUID(ulong uid) + { + int key = 0; + bool flag = this.ItemBag.FindItem(uid, out key); + XItem result; + if (flag) + { + result = this.ItemBag[key]; + } + else + { + result = null; + } + return result; + } + + public XItem GetBagItemByUID(string struid) + { + ulong uid = 0UL; + bool flag = ulong.TryParse(struid, out uid); + XItem result; + if (flag) + { + result = this.GetBagItemByUID(uid); + } + else + { + result = null; + } + return result; + } + + public XItem GetItemByUID(ulong uid) + { + int key = 0; + XItem bodyItemByUID = this.GetBodyItemByUID(uid); + bool flag = bodyItemByUID != null; + XItem result; + if (flag) + { + result = bodyItemByUID; + } + else + { + bool flag2 = this.ItemBag.FindItem(uid, out key); + if (flag2) + { + result = this.ItemBag[key]; + } + else + { + result = null; + } + } + return result; + } + + public XItem GetItemByUID(string struid) + { + ulong uid = 0UL; + bool flag = ulong.TryParse(struid, out uid); + XItem result; + if (flag) + { + result = this.GetItemByUID(uid); + } + else + { + result = null; + } + return result; + } + + public bool GetItemByItemId(int itemId, out List lst) + { + return this.ItemBag.FindItemByID(itemId, out lst); + } + + private static int ItemType2Int(ItemType type) + { + return XFastEnumIntEqualityComparer.ToInt(type); + } + + public static int BodyPosition(T type) where T : struct + { + return XFastEnumIntEqualityComparer.ToInt(type); + } + + internal static void InitAddEquiptItem(ref XBodyBag bag, List list, int bagSize) + { + bool flag = bag == null; + if (flag) + { + bag = new XBodyBag(bagSize); + } + for (int i = 0; i < bag.Length; i++) + { + bool flag2 = bag[i] != null; + if (flag2) + { + bag[i].Recycle(); + bag[i] = null; + } + } + int num = Math.Min(list.Count, bag.Length); + for (int j = 0; j < num; j++) + { + XItem xitem = XBagDocument.MakeXItem(list[j]); + bool flag3 = xitem.itemID == 0; + if (flag3) + { + xitem.Recycle(); + xitem = null; + } + bag[j] = xitem; + } + } + + internal void Init(BagContent Bag) + { + XEmblemDocument.HadSlottingNum = (int)Bag.extraSkillEbSlotNum; + for (int i = 0; i < Bag.expand.Count; i++) + { + this.SetBagExpandData(Bag.expand[i], false); + } + XBagDocument.InitAddEquiptItem(ref this.EquipBag, Bag.Equips, XBagDocument.EquipMax); + XBagDocument.InitAddEquiptItem(ref this.EmblemBag, Bag.Emblems, XBagDocument.EmblemMax); + XBagDocument.InitAddEquiptItem(ref this.ArtifactBag, Bag.Artifacts, XBagDocument.ArtifactMax); + int count = this.ItemBag.Count; + for (int j = 0; j < count; j++) + { + this.ItemBag[j].Recycle(); + } + this.ItemBag.Clear(); + for (int k = 0; k < Bag.Items.Count; k++) + { + XItem item = XBagDocument.MakeXItem(Bag.Items[k]); + this.ItemBag.AddItem(item, false); + } + int l; + for (l = 0; l < Bag.virtualitems.Count; l++) + { + this.VirtualItems[l] = Bag.virtualitems[l]; + } + while (l < this.VirtualItems.Length) + { + this.VirtualItems[l] = 0UL; + l++; + } + this.ItemBag.SortItem(); + XJadeDocument specificDocument = XDocuments.GetSpecificDocument(XJadeDocument.uuID); + specificDocument.UpdateRedPoints(); + XEnhanceDocument specificDocument2 = XDocuments.GetSpecificDocument(XEnhanceDocument.uuID); + specificDocument2.UpdateRedPoints(); + XEnchantDocument specificDocument3 = XDocuments.GetSpecificDocument(XEnchantDocument.uuID); + specificDocument3.UpdateRedPoints(); + XSingleton.singleton.XPlayerData.Outlook.enhanceMasterLevel = Bag.enhanceSuit; + XSingleton.singleton.XPlayerData.EmblemBag = this.EmblemBag; + this.TearsCount = (ulong)((long)this.ItemBag.GetItemCount(88)); + } + + public void SetBagExpandData(KKSG.BagExpandData data, bool isShowTip) + { + for (int i = 0; i < this.BagExpandDataList.Count; i++) + { + bool flag = this.BagExpandDataList[i].Type == data.type; + if (flag) + { + this.BagExpandDataList[i].ExpandNum = data.num; + this.BagExpandDataList[i].ExpandTimes = data.count; + if (isShowTip) + { + switch (data.type) + { + case BagType.EquipBag: + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("ExpandEquipBagSuc"), "fece00"); + XCharacterEquipDocument specificDocument = XDocuments.GetSpecificDocument(XCharacterEquipDocument.uuID); + specificDocument.RefreshBag(); + break; + } + case BagType.EmblemBag: + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("ExpandEmblemBagSuc"), "fece00"); + XEmblemDocument specificDocument2 = XDocuments.GetSpecificDocument(XEmblemDocument.uuID); + specificDocument2.RefreshBag(); + break; + } + case BagType.ArtifactBag: + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("ExpandArtifactBagSuc"), "fece00"); + ArtifactBagDocument.Doc.RefreshBag(); + break; + case BagType.ItemBag: + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("ExpandItemBagSuc"), "fece00"); + XCharacterItemDocument specificDocument3 = XDocuments.GetSpecificDocument(XCharacterItemDocument.uuID); + specificDocument3.RefreshBag(); + break; + } + } + } + break; + } + } + } + + public void UseBagExpandTicket(BagType type) + { + BagExpandItemListTable.RowData expandItemConfByType = XBagDocument.GetExpandItemConfByType((uint)XFastEnumIntEqualityComparer.ToInt(type)); + bool flag = expandItemConfByType == null; + if (!flag) + { + this.m_usedBagExpandRow = expandItemConfByType; + int itemId = (int)expandItemConfByType.ItemId; + BagExpandData bagExpandData = XBagDocument.BagDoc.GetBagExpandData((BagType)expandItemConfByType.Type); + bool flag2 = bagExpandData != null; + if (flag2) + { + bool flag3 = (uint)expandItemConfByType.NeedAndOpen.count > bagExpandData.ExpandTimes; + if (flag3) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf(itemId); + XSingleton.singleton.ShowModalDialog(string.Format(XSingleton.singleton.GetString("BagExpandSureTips"), expandItemConfByType.NeedAndOpen[(int)bagExpandData.ExpandTimes, 0], itemConf.ItemName[0], expandItemConfByType.NeedAndOpen[(int)bagExpandData.ExpandTimes, 1]), XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.ReqUseBagExpandTicket)); + } + else + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetBagExpandFullTips((BagType)expandItemConfByType.Type), "fece00"); + } + } + } + } + + private bool ReqUseBagExpandTicket(IXUIButton btn) + { + BagExpandItemListTable.RowData usedBagExpandRow = this.m_usedBagExpandRow; + bool flag = usedBagExpandRow == null; + bool result; + if (flag) + { + result = false; + } + else + { + int itemId = (int)usedBagExpandRow.ItemId; + BagExpandData bagExpandData = XBagDocument.BagDoc.GetBagExpandData((BagType)usedBagExpandRow.Type); + bool flag2 = bagExpandData != null; + if (flag2) + { + ulong itemCount = XBagDocument.BagDoc.GetItemCount(itemId); + bool flag3 = itemCount >= (ulong)usedBagExpandRow.NeedAndOpen[(int)bagExpandData.ExpandTimes, 0] && itemCount > 0UL; + if (flag3) + { + List list; + bool itemByItemId = this.GetItemByItemId(itemId, out list); + if (itemByItemId) + { + XSingleton.singleton.Doc.XBagDoc.UseItem(list[0], 0u); + } + } + else + { + XSingleton.singleton.ShowItemAccess(itemId, null); + } + } + XSingleton.singleton.CloseModalDlg(); + result = true; + } + return result; + } + + internal ulong GetItemCount(int itemid) + { + bool flag = itemid < XFastEnumIntEqualityComparer.ToInt(ItemEnum.VIRTUAL_ITEM_MAX); + ulong result; + if (flag) + { + result = this.GetVirtualItemCount((ItemEnum)itemid); + } + else + { + result = (ulong)((long)this.ItemBag.GetItemCount(itemid)); + } + return result; + } + + internal ulong GetItemCount(int itemid, bool isBind) + { + bool flag = itemid < XFastEnumIntEqualityComparer.ToInt(ItemEnum.VIRTUAL_ITEM_MAX); + ulong result; + if (flag) + { + result = this.GetVirtualItemCount((ItemEnum)itemid); + } + else + { + result = (ulong)((long)this.ItemBag.GetItemCount(itemid, isBind)); + } + return result; + } + + internal ulong GetVirtualItemCount(ItemEnum t) + { + return this.VirtualItems[XFastEnumIntEqualityComparer.ToInt(t)]; + } + + internal ulong GetSkillPointCount(bool isAwakeSkillPoint = false) + { + bool flag = XSingleton.singleton.XPlayerData.SkillPageIndex == 0u; + ulong result; + if (flag) + { + result = this.VirtualItems[XFastEnumIntEqualityComparer.ToInt(isAwakeSkillPoint ? ItemEnum.AWAKE_SKILL_POINT : ItemEnum.SKILL_POINT)]; + } + else + { + result = this.VirtualItems[XFastEnumIntEqualityComparer.ToInt(isAwakeSkillPoint ? ItemEnum.AWAKE_SKILL_POINT_TWO : ItemEnum.SKILL_POINT_TWO)]; + } + return result; + } + + internal void SetVirtualItemCount(int t, ulong Count) + { + ulong oldValue = 0UL; + bool flag = t < XFastEnumIntEqualityComparer.ToInt(ItemEnum.VIRTUAL_ITEM_MAX); + if (flag) + { + oldValue = this.VirtualItems[t]; + this.VirtualItems[t] = Count; + } + else + { + bool flag2 = t == 88; + if (flag2) + { + oldValue = this.TearsCount; + this.TearsCount = Count; + } + } + bool flag3 = t == 6; + if (flag3) + { + XSingleton.singleton.AddLog("Set fatigue = ", Count.ToString(), null, null, null, null, XDebugColor.XDebug_None); + } + XVirtualItemChangedEventArgs @event = XEventPool.GetEvent(); + @event.e = (ItemEnum)t; + @event.newValue = Count; + @event.oldValue = oldValue; + @event.itemID = t; + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + } + + internal void UpdateItem(Item KKSGItem) + { + XItem xitem = XBagDocument.MakeXItem(KKSGItem); + int key; + bool flag = this.ItemBag.FindItem(xitem.uid, out key); + if (flag) + { + this.ItemBag[key].Recycle(); + this.ItemBag[key] = xitem; + } + else + { + bool flag2 = xitem.Type == ItemType.EQUIP; + if (flag2) + { + this.EquipBag.UpdateItem(xitem); + } + else + { + bool flag3 = xitem.Type == ItemType.EMBLEM; + if (flag3) + { + this.EmblemBag.UpdateItem(xitem); + } + else + { + bool flag4 = xitem.Type == ItemType.ARTIFACT; + if (flag4) + { + this.ArtifactBag.UpdateItem(xitem); + } + } + } + } + XUpdateItemEventArgs @event = XEventPool.GetEvent(); + @event.item = xitem; + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + } + + internal void AddNewItem(Item KKSGItem) + { + XItem item = XBagDocument.MakeXItem(KKSGItem); + this.ItemBag.AddItem(item, true); + XAddItemEventArgs @event = XEventPool.GetEvent(); + @event.items.Add(item); + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + } + + internal void AddNewItem(List KKSGItems, bool bIsNew = true) + { + XAddItemEventArgs @event = XEventPool.GetEvent(); + @event.Firer = XSingleton.singleton.Doc; + @event.bNew = bIsNew; + foreach (Item kksgitem in KKSGItems) + { + XItem item = XBagDocument.MakeXItem(kksgitem); + this.ItemBag.AddItem(item, false); + @event.items.Add(item); + } + bool flag = @event.items.Count > 0; + if (flag) + { + this.ItemBag.SortItem(); + XSingleton.singleton.FireEvent(@event); + } + else + { + @event.Recycle(); + } + } + + internal void RemoveItem(ulong uid) + { + int num; + bool flag = this.ItemBag.FindItem(uid, out num); + if (flag) + { + XRemoveItemEventArgs @event = XEventPool.GetEvent(); + @event.uids.Add(uid); + @event.types.Add(this.ItemBag[num].Type); + @event.ids.Add(this.ItemBag[num].itemID); + this.ItemBag.RemoveIndex(num); + @event.Firer = XSingleton.singleton.Doc; + } + } + + internal void RemoveItem(List uids) + { + XRemoveItemEventArgs @event = XEventPool.GetEvent(); + @event.Firer = XSingleton.singleton.Doc; + foreach (ulong num in uids) + { + int num2; + bool flag = this.ItemBag.FindItem(num, out num2); + if (flag) + { + XItem xitem = this.ItemBag[num2]; + @event.uids.Add(num); + @event.types.Add(xitem.Type); + @event.ids.Add(xitem.itemID); + xitem.Recycle(); + this.ItemBag.RemoveIndex(num2); + } + } + bool flag2 = @event.uids.Count > 0; + if (flag2) + { + XSingleton.singleton.FireEvent(@event); + } + else + { + @event.Recycle(); + } + } + + internal void ChangeItemCount(ulong uid, int count, bool bIsNew = true) + { + int key; + bool flag = this.ItemBag.FindItem(uid, out key); + if (flag) + { + XItem xitem = this.ItemBag[key]; + int itemCount = xitem.itemCount; + xitem.itemCount = count; + XItemNumChangedEventArgs @event = XEventPool.GetEvent(); + @event.oldCount = itemCount; + @event.item = xitem; + @event.Firer = XSingleton.singleton.Doc; + @event.bNew = bIsNew; + XSingleton.singleton.FireEvent(@event); + } + } + + internal void FinishItemChange() + { + XItemChangeFinishedEventArgs @event = XEventPool.GetEvent(); + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + } + + private void _RemoveCompareAttrsFromPool(ulong uid) + { + this.basicAttrPool.Remove(uid); + this.equipAdditionalAttrPool.Remove(uid); + } + + public uint GetItemPPT(XAttrItem item, ItemAttrCompareType type) + { + bool flag = item == null; + uint result; + if (flag) + { + result = 0u; + } + else + { + Dictionary dictionary = null; + if (type != ItemAttrCompareType.IACT_SELF) + { + if (type == ItemAttrCompareType.IACT_TOTAL) + { + dictionary = this.equipAdditionalAttrPool; + } + } + else + { + dictionary = this.basicAttrPool; + } + uint num = 0u; + ulong num2 = item.uid; + bool flag2 = num2 == 0UL; + if (flag2) + { + num2 = (ulong)((long)item.itemID); + } + bool flag3 = !dictionary.TryGetValue(num2, out num); + if (flag3) + { + XEquipItem xequipItem = item as XEquipItem; + double num3 = 0.0; + bool flag4 = (type & ItemAttrCompareType.IACT_BASIC) > (ItemAttrCompareType)0; + if (flag4) + { + for (int i = 0; i < item.changeAttr.Count; i++) + { + num3 += XSingleton.singleton.GetPPT(item.changeAttr[i], null, -1); + } + } + bool flag5 = xequipItem != null && (type & ItemAttrCompareType.IACT_RANDOM) > (ItemAttrCompareType)0; + if (flag5) + { + for (int j = 0; j < xequipItem.randAttrInfo.RandAttr.Count; j++) + { + num3 += XSingleton.singleton.GetPPT(xequipItem.randAttrInfo.RandAttr[j], null, -1); + } + } + bool flag6 = xequipItem != null && (type & ItemAttrCompareType.IACT_FORGE) > (ItemAttrCompareType)0; + if (flag6) + { + for (int k = 0; k < xequipItem.forgeAttrInfo.ForgeAttr.Count; k++) + { + num3 += XSingleton.singleton.GetPPT(xequipItem.forgeAttrInfo.ForgeAttr[k], null, -1); + } + } + bool flag7 = xequipItem != null && (type & ItemAttrCompareType.IACT_ENHANCE) > (ItemAttrCompareType)0; + if (flag7) + { + for (int l = 0; l < xequipItem.enhanceInfo.EnhanceAttr.Count; l++) + { + num3 += XSingleton.singleton.GetPPT(xequipItem.enhanceInfo.EnhanceAttr[l], null, -1); + } + } + bool flag8 = xequipItem != null && (type & ItemAttrCompareType.IACT_JADE) > (ItemAttrCompareType)0; + if (flag8) + { + for (int m = 0; m < xequipItem.jadeInfo.jades.Length; m++) + { + num3 += this.GetItemPPT(xequipItem.jadeInfo.jades[m], ItemAttrCompareType.IACT_SELF); + } + } + num = (uint)num3; + dictionary.Add(num2, num); + } + result = num; + } + return result; + } + + public override void Update(float fDeltaT) + { + bool flag = this.ItemBag == null; + if (!flag) + { + int i = 0; + int count = this.ItemBag.Count; + while (i < count) + { + bool flag2 = !this.ItemBag[i].bBinding && this.ItemBag[i].blocking > 0.0; + if (flag2) + { + this.ItemBag[i].blocking -= (double)fDeltaT; + } + i++; + } + bool flag3 = this.getallEquip; + if (flag3) + { + this.fashionTime += fDeltaT; + bool flag4 = this.fashionTime > 0.3f; + if (flag4) + { + this.fashionTime = 0f; + bool flag5 = this.fashionIndex < XBagDocument.m_FashionTable.Table.Length; + if (flag5) + { + FashionList.RowData[] table = XBagDocument.m_FashionTable.Table; + int num = this.fashionIndex; + this.fashionIndex = num + 1; + FashionList.RowData rowData = table[num]; + string command = string.Format("item {0} 1", rowData.ItemID); + XSingleton.singleton.ProcessCommand(command); + } + else + { + this.getallEquip = false; + } + } + } + } + } + + public ItemAttrCompareResult IsAttrMorePowerful(XAttrItem left, XAttrItem right, ItemAttrCompareType type = ItemAttrCompareType.IACT_SELF) + { + uint itemPPT = this.GetItemPPT(left, type); + uint itemPPT2 = this.GetItemPPT(right, type); + bool flag = itemPPT < itemPPT2; + ItemAttrCompareResult result; + if (flag) + { + result = ItemAttrCompareResult.IACR_SMALLER; + } + else + { + bool flag2 = itemPPT > itemPPT2; + if (flag2) + { + result = ItemAttrCompareResult.IACR_LARGER; + } + else + { + result = ItemAttrCompareResult.IACR_EQUAL; + } + } + return result; + } + + public uint GetArtifactPPT(XAttrItem item) + { + bool flag = item == null; + uint result; + if (flag) + { + result = 0u; + } + else + { + XArtifactItem xartifactItem = item as XArtifactItem; + bool flag2 = xartifactItem == null; + if (flag2) + { + result = 0u; + } + else + { + double num = 0.0; + for (int i = 0; i < xartifactItem.RandAttrInfo.RandAttr.Count; i++) + { + bool flag3 = xartifactItem.RandAttrInfo.RandAttr[i].AttrID == 0u; + if (!flag3) + { + num += XSingleton.singleton.GetPPT(xartifactItem.RandAttrInfo.RandAttr[i], null, -1); + } + } + result = (uint)num; + } + } + return result; + } + + public void ReqItemSell(ulong uid) + { + RpcC2G_ItemSell rpcC2G_ItemSell = new RpcC2G_ItemSell(); + rpcC2G_ItemSell.oArg.uid = uid; + XSingleton.singleton.Send(rpcC2G_ItemSell); + } + + public void ReqItemCompose(ulong uid) + { + RpcC2G_ItemCompose rpcC2G_ItemCompose = new RpcC2G_ItemCompose(); + rpcC2G_ItemCompose.oArg.uid = uid.ToString(); + XSingleton.singleton.Send(rpcC2G_ItemCompose); + } + + public static bool ItemCanShowTips(uint itemID) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)itemID); + bool flag = itemConf == null; + bool result; + if (flag) + { + result = false; + } + else + { + bool flag2 = itemConf.ShowTips == 0; + result = !flag2; + } + return result; + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + this.Init(arg.PlayerInfo.Bag); + bool flag = XSingleton.singleton.Player == null; + if (!flag) + { + XEquipComponent xequipComponent = XSingleton.singleton.Player.GetXComponent(XEquipComponent.uuID) as XEquipComponent; + bool flag2 = xequipComponent != null; + if (flag2) + { + xequipComponent.EquipFromAttr(); + } + } + } + + public void GetAllEquip() + { + this.getallEquip = true; + this.fashionIndex = 0; + this.fashionTime = 0.4f; + } + } +} -- cgit v1.1-26-g67d0