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


C# BitStream.ReadUInt32方法代码示例

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


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

示例1: Serialize

        public void Serialize(BitStream stream, Type baseType, ref Type obj)
        {
            if (stream.Reading)
            {
                var id = new TypeId(stream.ReadUInt32());

                obj = MyMultiplayer.Static.ReplicationLayer.GetType(id);
            }
            else
            {
                var id = MyMultiplayer.Static.ReplicationLayer.GetTypeId(obj);
                stream.WriteUInt32(id);
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:14,代码来源:MyDynamicObjectResolver.cs

示例2: ReadShared

        private void ReadShared(BitStream stream, MyNetworkClient sender, out MyEntity controlledEntity)
        {
            controlledEntity = null;

            ClientTimeStamp = stream.ReadUInt32();
            var hasControlledEntity = stream.ReadBool();
            if (!hasControlledEntity)
            {
                Vector3D pos = Vector3D.Zero;
                stream.Serialize(ref pos); // 24B
                Position = pos;
            }
            else
            {
                var entityId = stream.ReadInt64();
                MyEntity entity;
                if (!MyEntities.TryGetEntityById(entityId, out entity))
                    return;

                Position = entity.WorldMatrix.Translation;

                // TODO: Obsolete check?
                MySyncEntity syncEntity = entity.SyncObject as MySyncEntity;
                if (syncEntity == null)
                    return;
                controlledEntity = entity;
            }
        }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:28,代码来源:MyClientState.cs

示例3: 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

示例4: Read

        public static Quaternion Read(BitStream stream)
        {
            float x, y, z, w;

            // note: you're going to want to normalize the quaternion returned from this function
            uint largest = stream.ReadUInt32(2);
            float a = stream.ReadUInt32(bits) * inverse_scale * (maximum - minimum) + minimum;
            float b = stream.ReadUInt32(bits) * inverse_scale * (maximum - minimum) + minimum;
            float c = stream.ReadUInt32(bits) * inverse_scale * (maximum - minimum) + minimum;

            switch (largest)
            {
                case 0:
                    x = (float)Math.Sqrt(1 - a * a - b * b - c * c);
                    y = a;
                    z = b;
                    w = c;
                    break;

                case 1:
                    x = a;
                    y = (float)Math.Sqrt(1 - a * a - b * b - c * c);
                    z = b;
                    w = c;
                    break;

                case 2:
                    x = a;
                    y = b;
                    z = (float)Math.Sqrt(1 - a * a - b * b - c * c);
                    w = c;
                    break;

                case 3:
                    x = a;
                    y = b;
                    z = c;
                    w = (float)Math.Sqrt(1 - a * a - b * b - c * c);
                    break;

                default:
                    Debug.Fail("Error");
                    x = 0;
                    y = 0;
                    z = 0;
                    w = 1;
                    break;
            }
            return Quaternion.Normalize(new Quaternion(x, y, z, w));
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:50,代码来源:CompressedQuaternion.cs


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