当前位置: 首页>>代码示例>>C#>>正文


C# BitStream.ReadInt32方法代码示例

本文整理汇总了C#中VRage.Library.Collections.BitStream.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BitStream.ReadInt32方法的具体用法?C# BitStream.ReadInt32怎么用?C# BitStream.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VRage.Library.Collections.BitStream的用法示例。


在下文中一共展示了BitStream.ReadInt32方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadInternal

 protected override void ReadInternal(BitStream stream, MyNetworkClient sender, MyEntity controlledEntity)
 {
     Context = (MyContextKind)stream.ReadInt32(2);
     if (Context != MyContextKind.None)
     {
         long entityId = stream.ReadInt64();
         ContextEntity = MyEntities.GetEntityByIdOrDefault(entityId);
     }
     else
     {
         ContextEntity = null;
     }
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:13,代码来源:MySpaceClientState.cs

示例2: Serialize

 public bool Serialize(BitStream stream, bool validate)
 {
     if (stream.Reading)
     {
         SenderUserId = stream.ReadInt64();
         NumElements = stream.ReadInt32();
         stream.ReadBytes(CompressedVoiceBuffer, 0,NumElements);
     }
     else
     {
         stream.WriteInt64(SenderUserId);
         stream.WriteInt32(NumElements);
         stream.WriteBytes(CompressedVoiceBuffer, 0, NumElements);
     }
     return true;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:16,代码来源:MyVoiceChatSessionComponent.cs

示例3: Read

        void Read(BitStream stream)
        {
            // TODO: Read additional client data, context

            MyNetworkClient sender;
            if (!Sync.Clients.TryGetClient(EndpointId.Value, out sender))
            {
                Debug.Fail("Unknown sender");
                return;
            }

            var hasControlledEntity = stream.ReadBool();
            if (hasControlledEntity == false)
            {
                Vector3D pos = Vector3D.Zero;
                stream.Serialize(ref pos); // 24B
                Position = pos;
            }
            else
            {
                int numEntity = 0;
                if (stream.BytePosition < stream.ByteLength)
                {
                    var entityId = stream.ReadInt64();
                    MyEntity entity;
                    if (!MyEntities.TryGetEntityById(entityId, out entity))
                        return;

                    MySyncEntity syncEntity = entity.SyncObject as MySyncEntity;
                    if (syncEntity == null)
                        return;

                    Context = (MyContextKind)stream.ReadInt32(2);

                    switch (Context)
                    {
                        case MyContextKind.Inventory:
                            entityId = stream.ReadInt64();
                            break;
                        case MyContextKind.Terminal:
                            entityId = stream.ReadInt64();
                            break;
                        case MyContextKind.Production:
                            entityId = stream.ReadInt64();
                            break;
                        default:
                            entityId = stream.ReadInt64();
                            break;
                    }

                    MyEntities.TryGetEntityById(entityId, out entity);
                    ContextEntity = entity;

                    if (!syncEntity.ResponsibleForUpdate(sender))
                    {
                        // Also happens when entering cockpit due to order of operations and responsibility update change
                        //Debug.Fail("Server sending entity update for entity controlled by client, should happen only very rarely (packets out-of-order)");
                        return;
                    }
                    syncEntity.SerializePhysics(stream, sender);

                    if (numEntity == 0)
                    {
                        Position = syncEntity.Entity.WorldMatrix.Translation;
                    }
                    numEntity++;
                }
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:69,代码来源:MyClientState.cs

示例4: ReadPlanetSectors

        protected void ReadPlanetSectors(BitStream stream)
        {
            KnownSectors.Clear();

            if (stream.ReadInt32() != PlanetMagic)
            {
                throw new BitStreamException("Wrong magic when reading planet sectors from client state.");
            }

            int count = stream.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                long p = stream.ReadInt64();
                Debug.Assert(p != ~0);

                HashSet<long> sectids = new HashSet<long>();

                KnownSectors.Add(p, sectids);

                while (true)
                {
                    long sectorid = stream.ReadInt64();
                    if (sectorid == ~0) break;

                    sectids.Add(sectorid);
                }
            }
        }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:29,代码来源:MyClientState.cs

示例5: ReadInventory

        private void ReadInventory(BitStream stream)
        {
            if(stream.ReadBool() == false)       
            {
                return;
            }

            if(m_recievedPacketIds == null)
            {
                m_recievedPacketIds = new MyQueue<uint>(RECIEVED_PACKET_HISTORY);
            }

            uint packetId = stream.ReadUInt32();

            bool apply = true;
            if (m_recievedPacketIds.Count == RECIEVED_PACKET_HISTORY)
            {
                m_recievedPacketIds.Dequeue();
            }

            if (m_recievedPacketIds.InternalArray.Contains(packetId) == false)
            {
                m_recievedPacketIds.Enqueue(packetId);
            }
            else
            {
                apply = false;
            }

            bool hasItems = stream.ReadBool();
            if(hasItems)
            {
                int numItems = stream.ReadInt32();

                for (int i = 0; i < numItems; ++i)
                {
                    uint itemId = stream.ReadUInt32();
                    MyFixedPoint amout = new MyFixedPoint();
                    amout.RawValue = stream.ReadInt64();

                    if (apply)
                    {
                        Inventory.UpdateItemAmoutClient(itemId, amout);
                    }
                }
            }

            hasItems = stream.ReadBool();
            if (hasItems)
            {
                int numItems = stream.ReadInt32();
                for (int i = 0; i < numItems; ++i)
                {
                    uint itemId = stream.ReadUInt32();
                    if (apply)
                    {
                        Inventory.RemoveItemClient(itemId);
                    }
                }
            }

            hasItems = stream.ReadBool();
            if (hasItems)
            {
                int numItems = stream.ReadInt32();

                for (int i = 0; i < numItems; ++i)
                {
                    int position = stream.ReadInt32();
                    MyPhysicalInventoryItem item;
                    VRage.Serialization.MySerializer.CreateAndRead(stream, out item, MyObjectBuilderSerializer.Dynamic);
                    if (apply)
                    {
                        Inventory.AddItemClient(position, item);
                    }
                }
            }

            hasItems = stream.ReadBool();
            if (hasItems)
            {
                int numItems = stream.ReadInt32();

                for (int i = 0; i < numItems; ++i)
                {
                    int position = stream.ReadInt32();
                    int newPosition = stream.ReadInt32();
                    if (apply)
                    {
                        Inventory.SwapItemClient(position, newPosition);
                    }
                }
            }

            Inventory.Refresh();
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:96,代码来源:MyEntityInventoryStateGroup.cs

示例6: Serialize

        /// <summary>
        /// Serializes id to hash list.
        /// Server sends the hashlist to client, client reorders type table to same order as server.
        /// </summary>
        public void Serialize(BitStream stream)
        {
            if (stream.Writing)
            {
                stream.WriteVariant((uint)m_idToType.Count);
                for (int i = 0; i < m_idToType.Count; i++)
                {
                    stream.WriteInt32(m_idToType[i].TypeHash);
                }
            }
            else
            {
                int count = (int)stream.ReadUInt32Variant();

                Debug.Assert(m_idToType.Count == count, "Number of received types does not match number of registered types");

                m_staticEventTable = new MyEventTable(null);
                for (int i = 0; i < count; i++)
                {
                    int typeHash = stream.ReadInt32();
                    Debug.Assert(m_hashLookup.ContainsKey(typeHash), "Type hash not found!");
                    var type = m_hashLookup[typeHash];
                    m_idToType[i] = type;
                    m_staticEventTable.AddStaticEvents(type.Type);
                }
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:31,代码来源:MyTypeTable.cs

示例7: ReadPlanetSectors

        private void ReadPlanetSectors(BitStream stream)
        {
            if (stream.ReadInt32() != 0x42424242)
            {
                throw new BitStreamException("Wrong magic when reading planet sectors from client state.");
            }

            int count = stream.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                long p = stream.ReadInt64();

                long sectorid;

                HashSet<MyPlanetSectorId> sectids = new HashSet<MyPlanetSectorId>();

                KnownSectors.Add(p, sectids);

                while(true)
                {
                    sectorid = stream.ReadInt64();
                    if (sectorid == -1) break;

                    MyPlanetSectorId id;
                    MyPlanetSectorId.Unpack64(sectorid, out id);
                    sectids.Add(id);
                }

            }
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:31,代码来源:MySpaceClientState.cs


注:本文中的VRage.Library.Collections.BitStream.ReadInt32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。