Exemplo n.º 1
0
    public static void RPC_S2C_RequestUGCData(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int[] objIDs = stream.Read <int[]>();
        foreach (int id in objIDs)
        {
            CreationData data = CreationMgr.GetCreation(id);
            if (null == data)
            {
                CreationOriginData cData = CreationList.Find(iter => iter.ObjectID == id);
                if (cData != null)
                {
                    CreationMgr.NewCreation(cData.ObjectID, cData.HashCode, (float)cData.Seed);
                }
                else
                {
                    MessageBox_N.ShowOkBox(PELocalization.GetString(8000500));
                    LogManager.Error("Creation item create failed. ID:" + id);
                    GameClientNetwork.Disconnect();
                }

                return;
            }

            ItemProto item = ItemProto.GetItemData(id);
            if (null != item)
            {
                byte[] itemData = ItemProto.GetBuffer(item);
                NetworkManager.SyncServer(EPacketType.PT_Common_UGCItem, id, itemData);

                var components = from component in data.m_IsoData.m_Components
                                 where VCUtils.IsSeat(component.m_Type)
                                 select(int) component.m_Type;

                float hp     = data.m_Attribute.m_Durability;
                float energy = data.m_Attribute.m_MaxFuel;

                if (components.Count() >= 1)
                {
                    NetworkManager.SyncServer(EPacketType.PT_Common_UGCData, id, hp, energy,
                                              data.m_Attribute.m_Cost.Keys.ToArray(), data.m_Attribute.m_Cost.Values.ToArray(), true,
                                              components.ToArray());
                }
                else
                {
                    NetworkManager.SyncServer(EPacketType.PT_Common_UGCData, id, hp, energy,
                                              data.m_Attribute.m_Cost.Keys.ToArray(), data.m_Attribute.m_Cost.Values.ToArray(), false);
                }
            }
        }
    }