yyl
2025-08-05 06da72770c641fabf980816ed466a2280dac2be7
Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs
@@ -1,8 +1,6 @@
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
//using ILCrossBinding;
public class PackageRegedit
{
@@ -29,7 +27,7 @@
    public static void Init()
    {
        // 登记相应的数据体及对应的数据转逻辑类
        // 登记相应的数据体及对应的数据转逻辑类(去重后)
        Register(typeof(H0102_tagCDBPlayer), typeof(DTC0102_tagCDBPlayer));
        Register(typeof(HA004_tagServerDateTime), typeof(DTCA004_tagServerDateTime));
        Register(typeof(HA005_tagOpenServerDay), typeof(DTCA005_tagOpenServerDay));
@@ -59,10 +57,54 @@
        Register(typeof(HA110_tagMCCoinToGoldCountInfo), typeof(DTCA110_tagMCCoinToGoldCountInfo));
        Register(typeof(HA008_tagGCPlayerRecInfo), typeof(DTCA008_tagGCPlayerRecInfo));
        Register(typeof(HAA02_tagMCFirstGoldInfo), typeof(DTCAA02_tagMCFirstGoldInfo));
        Register(typeof(HAA03_tagMCDailyPackBuyGiftInfo), typeof(DTCAA03_tagMCDailyPackBuyGiftInfo));
        Register(typeof(HA302_tagMCFuncOpenStateList), typeof(DTCA302_tagMCFuncOpenStateList));
        Register(typeof(HA320_tagMCPlayerFBInfoData), typeof(DTCA320_tagMCPlayerFBInfoData));
        Register(typeof(H0F03_tagRoleFamilyInfo), typeof(DTC0F03_tagRoleFamilyInfo));
        Register(typeof(H0F05_tagFamilyChange), typeof(DTC0F05_tagFamilyChange));
        Register(typeof(H0F07_tagFamilyRenameResult), typeof(DTC0F07_tagFamilyRenameResult));
        Register(typeof(H0212_tagNotifyCode), typeof(DTC0212_tagNotifyCode));
        Register(typeof(H0316_tagPackResetOK), typeof(DTC0316_tagPackResetOK));
        Register(typeof(H0430_tagPlayerInFamilyInfoRefresh), typeof(DTC0430_tagPlayerInFamilyInfoRefresh));
        Register(typeof(HA3BD_tagMCBuyEnterInfo), typeof(DTCA3BD_tagMCBuyEnterInfo));
        Register(typeof(HA315_tagMCDailyActionCnt), typeof(DTCA315_tagMCDailyActionCnt));
        Register(typeof(HA333_tagMCDailyActivityInfoList), typeof(DTCA333_tagMCDailyActivityInfoList));
        Register(typeof(HA350_tagMCTreasureResult), typeof(DTCA350_tagMCTreasureResult));
        Register(typeof(HA351_tagMCTreasureInfo), typeof(DTCA351_tagMCTreasureInfo));
        Register(typeof(HA362_tagMCMailList), typeof(DTCA362_tagMCMailList));
        Register(typeof(HA363_tagMCMailStateChange), typeof(DTCA363_tagMCMailStateChange));
        Register(typeof(HA40D_tagGCServerCreatFamilyTimes), typeof(DTCA40D_tagGCServerCreatFamilyTimes));
        Register(typeof(HA401_tagGCViewFamilyRequestInfo), typeof(DTCA401_tagGCViewFamilyRequestInfo));
        Register(typeof(HA403_tagGCFamilyActionInfo), typeof(DTCA403_tagGCFamilyActionInfo));
        Register(typeof(HA408_tagGCPyAllFamilyView), typeof(DTCA408_tagGCPyAllFamilyView));
        Register(typeof(HA501_tagMCNotifyRequestJoinFamilyInfo), typeof(DTCA501_tagMCNotifyRequestJoinFamilyInfo));
        Register(typeof(HA705_tagSCQueryPlayerCacheResult), typeof(DTCA705_tagSCQueryPlayerCacheResult));
        Register(typeof(HA801_tagMCGiveAwardInfo), typeof(DTCA801_tagMCGiveAwardInfo));
        Register(typeof(HA802_tagMCShopItemDayBuyCntInfo), typeof(DTCA802_tagMCShopItemDayBuyCntInfo));
        Register(typeof(HA809_tagMCItemDayUseCntInfo), typeof(DTCA809_tagMCItemDayUseCntInfo));
        Register(typeof(HA811_tagMCShoppingResult), typeof(DTCA811_tagMCShoppingResult));
        Register(typeof(HA721_tagMCEmojiPackInfo), typeof(DTCA721_tagMCEmojiPackInfo));
        Register(typeof(HB117_tagMCFaceInfo), typeof(DTCB117_tagMCFaceInfo));
        Register(typeof(HB118_tagMCFacePicInfo), typeof(DTCB118_tagMCFacePicInfo));
        Register(typeof(HB120_tagMCZhanlingInfo), typeof(DTCB120_tagMCZhanlingInfo));
        Register(typeof(HA311_tagMCSyncRealmInfo), typeof(DTCA311_tagMCSyncRealmInfo));
        Register(typeof(HB110_tagMCTaskInfo), typeof(DTCB110_tagMCTaskInfo));
        Register(typeof(HA921_tagUpdatePlayerNameResult), typeof(DTCA921_tagUpdatePlayerNameResult));
        Register(typeof(H3202_tagServerResponse), typeof(DTC3202_tagServerResponse));
        Register(typeof(HA130_tagMCViewBillboardRet), typeof(DTCA130_tagMCViewBillboardRet));
        Register(typeof(HB420_tagMCTurnFightState), typeof(DTCB420_tagMCTurnFightState));
        Register(typeof(HB421_tagMCTurnFightObjAction), typeof(DTCB421_tagMCTurnFightObjAction));
        Register(typeof(HB422_tagMCTurnFightObjDead), typeof(DTCB422_tagMCTurnFightObjDead));
        Register(typeof(HB423_tagMCTurnFightObjReborn), typeof(DTCB423_tagMCTurnFightObjReborn));
        Register(typeof(HB424_tagSCTurnFightInit), typeof(DTCB424_tagSCTurnFightInit));
        Register(typeof(HB425_tagSCTurnFightReportSign), typeof(DTCB425_tagSCTurnFightReportSign));
        Register(typeof(HB430_tagSCTurnFightReport), typeof(DTCB430_tagSCTurnFightReport));
        Register(typeof(H0407_tagNPCDisappear), typeof(DTC0407_tagNPCDisappear));
        Register(typeof(H0423_tagObjPropertyRefreshView), typeof(DTC0423_tagObjPropertyRefreshView));
        Register(typeof(H0604_tagUseSkillAttack), typeof(DTC0604_tagUseSkillAttack));
        Register(typeof(HB124_tagSCLineupInfo), typeof(DTCB124_tagSCLineupInfo));
        Register(typeof(HA207_tagSCPackBuyInfo), typeof(DTCA207_tagSCPackBuyInfo));
    }
    //主工程注册封包
    public static void Register(Type _pack, Type _business)
@@ -80,8 +122,6 @@
        }
    }
    public static bool Contain(ushort _cmd)
    {
        return packToBusinessTable.ContainsKey(_cmd);
@@ -91,8 +131,9 @@
        try
        {
            //执行主工程的封包
            if (packToBusinessTable.ContainsKey(_package.cmd))
            if (packToBusinessTable.ContainsKey(_package.cmd) && BattleManager.Instance.IsCanDistributePackage(_package))
                packToBusinessTable[_package.cmd].Done(_package);
        }
        catch (Exception ex)
        {
@@ -127,12 +168,6 @@
            // 实例化并强转为协议包基类
            var packageInstance = packageType.Assembly.CreateInstance(packageType.Name) as GameNetPackBasic;
            packageInstance.ReadFromBytes(vBytes);// 解析内容
            if (packageInstance.cmd == (ushort)0x03F0 || packageInstance.cmd == (ushort)0x1801)
            {
                byte[] vPyBody = new byte[vBytes.Length - 4];
                Array.Copy(vBytes, 4, vPyBody, 0, vPyBody.Length);
                packageInstance = TransForPyPack(vPyBody);
            }
            packageInstance.socketType = socketType;
#if UNITY_EDITOR
@@ -148,29 +183,4 @@
        }
        return null;
    }
    /// <summary>
    /// 解析PY的模拟包
    /// </summary>
    /// <param name="vBytes"></param>
    /// <returns></returns>
    private static GameNetPackBasic TransForPyPack(byte[] vBytes)
    {
        GameNetPackBasic vNetPackInst = null;
        ushort vPackCmd = (ushort)((ushort)(vBytes[0] << 8) + vBytes[1]);
        // 主工程封包
        if (packageTable.ContainsKey(vPackCmd))
        {
            Type vNetPackType = packageTable[vPackCmd];
            vNetPackInst = vNetPackType.Assembly.CreateInstance(vNetPackType.Name) as GameNetPackBasic;
            vNetPackInst.ReadFromBytes(vBytes);// 解析内容
        }
        else
        {
            Debug.Log("收到未定义的解包协议:" + vBytes[0].ToString("x2").ToUpper() + "," + vBytes[1].ToString("x2").ToUpper());
        }
        return vNetPackInst;
    }
}
}