using System; using System.Collections.Generic; using KKSG; using XMainClient.UI; using XMainClient.UI.UICommon; using XUtliPoolLib; namespace XMainClient { internal class XGuildResContentionBuffDocument : XDocComponent { public override uint ID { get { return XGuildResContentionBuffDocument.uuID; } } public static XGuildResContentionBuffDocument Doc { get { return XSingleton.singleton.Doc.GetXComponent(XGuildResContentionBuffDocument.uuID) as XGuildResContentionBuffDocument; } } public static GuildBuffTable GuildBuffData { get { return XGuildResContentionBuffDocument._guildBuffTable; } } public static GuildMineralStorage GuildMineralStorageTable { get { return XGuildResContentionBuffDocument._guildMineralStorageTable; } } public uint GuildBuffCDTime { get { return this._guildBuffCDTime; } set { this._guildBuffCDTime = value; } } public ulong GuildID { get { return this._guildID; } set { this._guildID = value; } } public List MineUsedBuffRecordList { get { return this._guildBuffUsedRecords; } set { this._guildBuffUsedRecords = value; } } public uint GuildMaxResource { get { return this._guildMaxResource; } set { this._guildMaxResource = value; } } public List MyselfOwnedBuffs { get { return this._myselfOwnedBuffs; } set { this._myselfOwnedBuffs = value; } } public List MySelfActingBuffList { get { return this._mySelfActingBuffList; } set { this._mySelfActingBuffList = value; } } public List MyGuildOwnedBuffs { get { return this._myGuildOwnedBuffs; } set { this._myGuildOwnedBuffs = value; } } public new static readonly uint uuID = XSingleton.singleton.XHash("GuildResContentionBuffDocument"); public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); private static GuildBuffTable _guildBuffTable = new GuildBuffTable(); private static GuildMineralStorage _guildMineralStorageTable = new GuildMineralStorage(); private List _myGuildOwnedBuffs = new List(); private List _myselfOwnedBuffs = new List(); private List _mySelfActingBuffList = new List(); private List _guildBuffUsedRecords = new List(); private List _guildInfoList = new List(); private Dictionary> _guildsBuffedInfos = new Dictionary>(); private uint _guildBuffCDTime = 0u; private ulong _guildID = 0UL; private uint _guildCdTimerID = 0u; private uint _guildMaxResource = 1u; public static void Execute(OnLoadedCallback callback = null) { XGuildResContentionBuffDocument.AsyncLoader.AddTask("Table/GuildBuff", XGuildResContentionBuffDocument._guildBuffTable, false); XGuildResContentionBuffDocument.AsyncLoader.AddTask("Table/GuildMineralStorage", XGuildResContentionBuffDocument._guildMineralStorageTable, false); XGuildResContentionBuffDocument.AsyncLoader.Execute(callback); } public override void OnAttachToHost(XObject host) { base.OnAttachToHost(host); } protected override void EventSubscribe() { base.EventSubscribe(); } public override void OnDetachFromHost() { base.OnDetachFromHost(); } protected override void OnReconnected(XReconnectedEventArgs arg) { } public override void OnEnterSceneFinally() { base.OnEnterSceneFinally(); } public GuildBuffTable.RowData GetGuildBuffDataByItemID(uint itemID) { for (int i = 0; i < XGuildResContentionBuffDocument._guildBuffTable.Table.Length; i++) { bool flag = XGuildResContentionBuffDocument._guildBuffTable.Table[i].itemid == itemID; if (flag) { return XGuildResContentionBuffDocument._guildBuffTable.Table[i]; } } return null; } public GuildBuffTable.RowData GetGuildBuffDataByBuffID(uint buffID) { for (int i = 0; i < XGuildResContentionBuffDocument._guildBuffTable.Table.Length; i++) { bool flag = XGuildResContentionBuffDocument._guildBuffTable.Table[i].id == buffID; if (flag) { return XGuildResContentionBuffDocument._guildBuffTable.Table[i]; } } return null; } public GuildMineralStorage.RowData GetMineralStorageByID(uint id) { for (int i = 0; i < XGuildResContentionBuffDocument._guildMineralStorageTable.Table.Length; i++) { bool flag = XGuildResContentionBuffDocument._guildMineralStorageTable.Table[i].itemid == id; if (flag) { return XGuildResContentionBuffDocument._guildMineralStorageTable.Table[i]; } } return null; } public void SendGuildBuffReq(ulong guildID, uint itemID) { RpcC2M_UseGuildBuff rpcC2M_UseGuildBuff = new RpcC2M_UseGuildBuff(); rpcC2M_UseGuildBuff.oArg.guildid = guildID; rpcC2M_UseGuildBuff.oArg.itemid = itemID; XSingleton.singleton.Send(rpcC2M_UseGuildBuff); } public void SendPersonalBuffOpReq(ulong entityID, uint itemID, PersonalBuffOpType opType) { RpcC2G_ItemBuffOp rpcC2G_ItemBuffOp = new RpcC2G_ItemBuffOp(); rpcC2G_ItemBuffOp.oArg.itemcount = 1u; rpcC2G_ItemBuffOp.oArg.itemid = itemID; rpcC2G_ItemBuffOp.oArg.op = (uint)opType; XSingleton.singleton.Send(rpcC2G_ItemBuffOp); } public void OnGetUseGuildBuffResult(UseGuildBuffArg oArg, UseGuildBuffRes oRes) { bool flag = oRes.error == ErrorCode.ERR_SUCCESS; if (flag) { XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("BuffUseSuc"), "fece00"); this._guildBuffCDTime = oRes.cd; DlgBase.singleton.RefreshOwnedBuffItem(oArg.itemid, this._guildBuffCDTime); } else { XSingleton.singleton.ShowSystemTip(oRes.error, "fece00"); } } public void OnGetPersonalBuffOperationResult(ItemBuffOpArg oArg, ItemBuffOpRes oRes) { bool flag = oRes.errorcode == ErrorCode.ERR_SUCCESS; if (flag) { bool flag2 = oArg.op == 0u; if (flag2) { this._myselfOwnedBuffs.Clear(); for (int i = 0; i < oRes.itemid.Count; i++) { this._myselfOwnedBuffs.Add(new GuildBuffInfo { itemID = oRes.itemid[i], count = oRes.itemcount[i] }); } } else { bool flag3 = oArg.op == 1u; if (flag3) { XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("BuffUseSuc"), "fece00"); for (int j = 0; j < this._myselfOwnedBuffs.Count; j++) { bool flag4 = this._myselfOwnedBuffs[j].itemID == oArg.itemid; if (flag4) { bool flag5 = this._myselfOwnedBuffs[j].count <= 1u; if (flag5) { this._myselfOwnedBuffs.RemoveAt(j); } else { this._myselfOwnedBuffs[j].count -= 1u; } break; } } ItemBuffTable.RowData itembuffDataByID = XHomeCookAndPartyDocument.Doc.GetItembuffDataByID(oArg.itemid); bool flag6 = itembuffDataByID != null; if (flag6) { for (int k = 0; k < itembuffDataByID.Buffs.Count; k++) { BuffTable.RowData buffData = XSingleton.singleton.GetBuffData((int)itembuffDataByID.Buffs[k, 0], (int)itembuffDataByID.Buffs[k, 1]); bool flag7 = buffData.BuffDuration > 0f; if (flag7) { bool flag8 = false; for (int l = 0; l < this._mySelfActingBuffList.Count; l++) { bool flag9 = (ulong)this._mySelfActingBuffList[l].buffID == (ulong)((long)buffData.BuffID); if (flag9) { this._mySelfActingBuffList[l].time = (uint)buffData.BuffDuration; flag8 = true; break; } } bool flag10 = !flag8; if (flag10) { this._mySelfActingBuffList.Add(new GuildUsingBuffInfo { buffID = (uint)buffData.BuffID, time = (uint)buffData.BuffDuration }); } } } } bool flag11 = DlgBase.singleton.IsVisible(); if (flag11) { DlgBase.singleton.RefreshOwnedBuffItem(oArg.itemid, 0u); DlgBase.singleton.RefreshMySelfActingBuff(); } } else { bool flag12 = oArg.op == 2u; if (flag12) { this.MySelfActingBuffList.Clear(); for (int m = 0; m < oRes.buffid.Count; m++) { this._mySelfActingBuffList.Add(new GuildUsingBuffInfo { buffID = oRes.buffid[m], time = oRes.lefttime[m] }); } bool flag13 = DlgBase.singleton.IsVisible(); if (flag13) { DlgBase.singleton.RefreshMySelfActingBuff(); } } else { bool flag14 = oArg.op == 3u; if (flag14) { bool flag15 = XSingleton.singleton.SceneType == SceneType.SCENE_HORSE_RACE || XSingleton.singleton.SceneType == SceneType.SCENE_WEEKEND4V4_HORSERACING; if (flag15) { XRaceDocument specificDocument = XDocuments.GetSpecificDocument(XRaceDocument.uuID); specificDocument.UseDoodad(oArg, oRes); } else { bool flag16 = XSingleton.singleton.SceneType == SceneType.SCENE_SURVIVE; if (flag16) { } } } } } } } else { XSingleton.singleton.ShowSystemTip(oRes.errorcode, "fece00"); } } public void OnGetBuffAllInfo(ResWarGuildBrief res) { bool flag = res != null && res.error == ErrorCode.ERR_SUCCESS; if (flag) { this.GuildBuffCDTime = res.cardcd; this.GuildID = res.guildid; this.GuildMaxResource = (uint)XSingleton.singleton.GetInt("GuildResMax"); List item = res.item; bool flag2 = item != null; if (flag2) { this.UpdateOwnedBuffList(item); } this.OnGetGuildInfoList(res.rankinfo); this.OnGetGuildBuffList(res.buffinfo); this.UpdateBuffRecords(res.chatinfo); } } public WarResGuildInfo GetPKGuildInfos(int index) { bool flag = index < this._guildInfoList.Count; WarResGuildInfo result; if (flag) { result = this._guildInfoList[index]; } else { result = null; } return result; } public List GetAllGuildInfos() { return this._guildInfoList; } public List GetGuildUsedBuffList(ulong guildID) { List result = null; foreach (KeyValuePair> keyValuePair in this._guildsBuffedInfos) { bool flag = keyValuePair.Key == guildID; if (flag) { result = this._guildsBuffedInfos[keyValuePair.Key]; return result; } } return result; } public GuildBuffInfo GetGuildOwnedSomeCardInfo(uint itemID) { for (int i = 0; i < this.MyGuildOwnedBuffs.Count; i++) { bool flag = this.MyGuildOwnedBuffs[i].itemID == itemID && this.MyGuildOwnedBuffs[i].count > 0u; if (flag) { return this.MyGuildOwnedBuffs[i]; } } return null; } public GuildBuffInfo GetMyOwnedSomeCardInfo(uint itemID) { for (int i = 0; i < this._myselfOwnedBuffs.Count; i++) { bool flag = this._myselfOwnedBuffs[i].itemID == itemID; if (flag) { return this._myselfOwnedBuffs[i]; } } return null; } public void StartCDTimer() { this.StopCDTimer(); this._guildCdTimerID = XSingleton.singleton.SetTimerAccurate(1f, new XTimerMgr.AccurateElapsedEventHandler(this.RefreshCardCD), null); } public void StopCDTimer() { XSingleton.singleton.KillTimer(this._guildCdTimerID); this._guildCdTimerID = 0u; } private void RefreshCardCD(object param, float delay) { this.MinusGuildBuffCDTime(); this.RefreshUICD(); this.StartCDTimer(); } private void RefreshUICD() { bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.RefreshGuildBuffCD(); DlgBase.singleton.RefreshMySelfActingBuff(); } GuildBuffOperationHandler guildBuffHandler = DlgBase.singleton.GuildBuffHandler; bool flag2 = guildBuffHandler != null && guildBuffHandler.IsVisible(); if (flag2) { guildBuffHandler.RefreshCardCd(); } } private void MinusGuildBuffCDTime() { this._guildBuffCDTime = ((this._guildBuffCDTime > 0u) ? (this._guildBuffCDTime - 1u) : 0u); foreach (List list in this._guildsBuffedInfos.Values) { for (int i = 0; i < list.Count; i++) { list[i].time = ((list[i].time > 0u) ? (list[i].time - 1u) : 0u); } } for (int j = this._mySelfActingBuffList.Count - 1; j >= 0; j--) { bool flag = this._mySelfActingBuffList[j].time == 0u; if (flag) { this._mySelfActingBuffList.RemoveAt(j); } else { this._mySelfActingBuffList[j].time -= 1u; } } } private void UpdateOwnedBuffList(List buffItems) { bool flag = buffItems == null; if (!flag) { this.MyGuildOwnedBuffs.Clear(); for (int i = 0; i < buffItems.Count; i++) { this.MyGuildOwnedBuffs.Add(new GuildBuffInfo { itemID = buffItems[i].itemid, count = buffItems[i].count }); } } } private void UpdateBuffRecords(List usedBuffs) { bool flag = usedBuffs != null; if (flag) { this._guildBuffUsedRecords.Clear(); XChatDocument specificDocument = XDocuments.GetSpecificDocument(XChatDocument.uuID); for (int i = 0; i < usedBuffs.Count; i++) { this._guildBuffUsedRecords.Add(new GuildBuffUsedRecordItem { MainMessage = specificDocument.ProcessText(usedBuffs[i]) }); } } } internal void OnGetGuildBuffList(List buffs) { bool flag = buffs == null; if (!flag) { this._guildsBuffedInfos.Clear(); for (int i = 0; i < buffs.Count; i++) { GuildBuffSimpleInfo guildBuffSimpleInfo = buffs[i]; this._guildsBuffedInfos.Add(guildBuffSimpleInfo.guildid, new List()); for (int j = 0; j < guildBuffSimpleInfo.buff.Count; j++) { this._guildsBuffedInfos[guildBuffSimpleInfo.guildid].Add(new GuildUsingBuffInfo { buffID = guildBuffSimpleInfo.buff[j].id, time = guildBuffSimpleInfo.buff[j].time }); } } bool flag2 = DlgBase.singleton.IsVisible(); if (flag2) { DlgBase.singleton.RefreshTopRightBuffs(); } } } internal void OnGetGuildInfoList(ResWarRankSimpleInfo infos) { bool flag = infos.rank == null; if (!flag) { this._guildInfoList.Clear(); List rank = infos.rank; for (int i = 0; i < rank.Count; i++) { ResWarRank resWarRank = rank[i]; WarResGuildInfo warResGuildInfo = new WarResGuildInfo { guildID = resWarRank.id, guildName = resWarRank.name, resValue = resWarRank.value, guildIcon = resWarRank.icon }; this.GuildMaxResource = Math.Max(this.GuildMaxResource, resWarRank.value); this._guildInfoList.Add(warResGuildInfo); bool flag2 = warResGuildInfo.guildID == this._guildID; if (flag2) { this._guildInfoList[i] = this._guildInfoList[0]; this._guildInfoList[0] = warResGuildInfo; } } } } internal void OnGetOwnedGuildBuffList(PtcM2C_GuildBuffSimpleItemNtf roPtc) { bool flag = roPtc.Data != null; if (flag) { bool flag2 = roPtc.Data.guildid == this._guildID; if (flag2) { this.UpdateOwnedBuffList(roPtc.Data.item); this.UpdateBuffRecords(roPtc.Data.chatinfo); bool flag3 = DlgBase.singleton.IsVisible(); if (flag3) { DlgBase.singleton.RefreshBuffsRecord(); } } } } public void OnGetGuildResUpdate(ResWarMineData data) { bool flag = data != null; if (flag) { for (int i = 0; i < this._guildInfoList.Count; i++) { bool flag2 = this._guildInfoList[i].guildID == data.guildid; if (flag2) { this.GuildMaxResource = Math.Max(this.GuildMaxResource, data.mine); this._guildInfoList[i].resValue = data.mine; bool flag3 = DlgBase.singleton.IsVisible(); if (flag3) { DlgBase.singleton.RefreshTopRightBuffs(); } break; } } } } public void OnGetGuildBuffCD(GuildBuffCDParam data) { this._guildBuffCDTime = data.param; bool flag = this._guildBuffCDTime > 0u; if (flag) { GuildBuffOperationHandler guildBuffHandler = DlgBase.singleton.GuildBuffHandler; bool flag2 = guildBuffHandler != null && guildBuffHandler.IsVisible(); if (flag2) { guildBuffHandler.FoldByHasGuildBuffCd(); guildBuffHandler.RefreshCardCd(); } } } } }