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


C# BitStream.ReadInt64方法代码示例

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


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

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

            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:stanhebben,项目名称:SpaceEngineers,代码行数:27,代码来源:MyClientState.cs

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

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

示例7: SerializePhysicsWithSupport

        /// <summary>
        /// Serializes physics and takes into account support (what's entity standing on)
        /// </summary>
        private void SerializePhysicsWithSupport(BitStream stream, EndpointId forClient,uint timestamp, byte packetId, int maxBitPosition)
        {
            if (stream.Writing)
            {
                // TODO: only prototype implementation
                SetSupport(FindSupportDelegate());

                stream.WriteBool(m_supportPhysics != null);
                if (m_supportPhysics != null)
                {
                    stream.WriteInt64(m_supportPhysics.Entity.EntityId);
                    var localToParent = Entity.WorldMatrix * MatrixD.Invert(m_supportPhysics.Entity.PositionComp.WorldMatrix);
                    stream.Write(localToParent.Translation);
                    stream.Write(Quaternion.CreateFromForwardUp(localToParent.Forward, localToParent.Up).ToVector4());
                    bool moving = IsMoving(Entity);
                    stream.WriteBool(moving);

                    SerializeVelocities(stream, Entity, EffectiveSimulationRatio, !IsControlledLocally, moving);
                }
                else
                {
                    base.Serialize(stream, forClient,timestamp, packetId, maxBitPosition);
                }
            }
            else
            {
                if (stream.ReadBool())
                {
                    MyEntity support;
                    bool apply = MyEntities.TryGetEntityById(stream.ReadInt64(), out support) && !IsControlledLocally;

                    var pos = stream.ReadVector3D();
                    var orient = Quaternion.FromVector4(stream.ReadVector4());

                    if (apply)
                    {
                        var old = Entity.PositionComp.WorldMatrix;

                        MatrixD localToParent = MatrixD.CreateFromQuaternion(orient);
                        localToParent.Translation = pos;
                        MatrixD matrix = localToParent * support.WorldMatrix;
                        Entity.PositionComp.SetWorldMatrix(matrix, null, true);

                        SetSupport(MySupportHelper.FindPhysics(support));

                        var handler = MoveHandler;
                        if (handler != null)
                        {
                            handler(ref old, ref matrix);
                        }
                    }
                    else
                    {
                        SetSupport(null);
                    }
                    bool moving = stream.ReadBool();
                    SerializeVelocities(stream, Entity, EffectiveSimulationRatio, apply, moving);

                }
                else
                {
                    SetSupport(null);
                    base.Serialize(stream, forClient, timestamp, packetId, maxBitPosition);
                }
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:69,代码来源:MyEntityPhysicsStateGroupWithSupport.cs

示例8: ReadPhysics

        private void ReadPhysics(BitStream stream, MyNetworkClient sender, MyEntity controlledEntity,uint serverTimeStamp)
        {
            
            bool hasPhysics = stream.ReadBool();

            m_currentServerTimeStamp = serverTimeStamp;

            if (hasPhysics && MyEntityPhysicsStateGroup.ResponsibleForUpdate(controlledEntity, new EndpointId(sender.SteamUserId)))
            {
                IMyStateGroup stateGroup = null;
                SupportId = null;
                bool enableControlOnServer = stream.ReadBool();
                bool stateGroupFound = stream.ReadBool();
                if (stateGroupFound == false)
                {
                    return;
                }

              
                if (stream.ReadBool())
                {
                    SupportId = stream.ReadInt64();
                }
        
                if (enableControlOnServer)
                {
                    stateGroup = MyExternalReplicable.FindByObject(controlledEntity).FindStateGroup<MyEntityPositionVerificationStateGroup>();
                }
                else
                {
                    stateGroup = MyExternalReplicable.FindByObject(controlledEntity).FindStateGroup<MyEntityPhysicsStateGroup>();
                }

                if (stream.ReadBool())
                {
                    stateGroup.Serialize(stream, new EndpointId(sender.SteamUserId), ClientTimeStamp, 0, 65535);
                }
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:39,代码来源:MyClientState.cs

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