ReadDouble() public method

8字节读出
public ReadDouble ( ) : double
return double
 public void Deserialize(NetBuffer networkReader)
 {
     SenderTimestamp      = networkReader.ReadDouble();
     SenderFixedTimestamp = networkReader.ReadDouble();
     Timestamp            = networkReader.ReadDouble();
     FixedTimestamp       = networkReader.ReadDouble();
 }
 public void Deserialize(NetBuffer pPacketReader)
 {
     name     = pPacketReader.ReadString();
     subspace = pPacketReader.ReadInt32();
     clock    = pPacketReader.ReadDouble();
     unk      = pPacketReader.ReadBool();
 }
Example #3
0
        public static PlayerInput Deserialize(NetBuffer reader)
        {
            var input = new PlayerInput {
                Timestamp = reader.ReadDouble(),
                Thrust    = reader.ReadSingle(),
                Pitch     = reader.ReadSingle(),
                Roll      = reader.ReadSingle(),
                Yaw       = reader.ReadSingle(),
                Boost     = reader.ReadBoolean(),
            };

            reader.SkipPadBits(7);
            return(input);
        }
Example #4
0
            public CommandImplementation(GameState game, NetBuffer buffer)
            {
                this.game = game;
                var time = new Instant(buffer.ReadDouble());

                int count = buffer.ReadByte();

                this.parameters = new List <ParameterGroup>(count);

                for (int i = 0; i < count; i++)
                {
                    this.parameters.Add(new ParameterGroup(buffer));
                }
            }
Example #5
0
            public CommandImplementation(GameState game, NetBuffer buffer)
            {
                this.game = game;
                var time = new Instant(buffer.ReadDouble());

                this.game.SetTime(time);

                int count = buffer.ReadByte();

                this.parameters = new List <SingleParameters>(count);

                for (int i = 0; i < count; i++)
                {
                    this.parameters.Add(buffer.Read <SingleParameters>());
                }
            }
Example #6
0
        static object ReadPrimitive(NetBuffer buffer, SnapshotPrimitiveType type)
        {
            switch (type)
            {
            case SnapshotPrimitiveType.Byte:
                return(buffer.ReadByte());

            case SnapshotPrimitiveType.Char:
                return(buffer.ReadChar());

            case SnapshotPrimitiveType.Boolean:
                return(buffer.ReadBool());

            case SnapshotPrimitiveType.Int16:
            case SnapshotPrimitiveType.SByte:     // SByte is written as a short
                return(buffer.ReadInt16());

            case SnapshotPrimitiveType.UInt16:
                return(buffer.ReadUInt16());

            case SnapshotPrimitiveType.Int32:
                return(buffer.ReadInt32());

            case SnapshotPrimitiveType.UInt32:
                return(buffer.ReadUInt32());

            case SnapshotPrimitiveType.Int64:
                return(buffer.ReadInt64());

            case SnapshotPrimitiveType.UInt64:
                return(buffer.ReadUInt64());

            case SnapshotPrimitiveType.Single:
                return(buffer.ReadFloat());

            case SnapshotPrimitiveType.Double:
                return(buffer.ReadDouble());

            case SnapshotPrimitiveType.ByteFlag:
                return(buffer.ReadByteFlag());

            default:
                throw new Exception("Snapshot primitive type '" + type + "' is not supported!");
            }
        }
Example #7
0
        internal void Deserialize(NetBuffer buffer)
        {
            try
            {
                _fields = new Dictionary <string, Pair <DataType, object> >();

                while (true)
                {
                    string key = buffer.ReadString();
                    if (string.IsNullOrEmpty(key))
                    {
                        break;
                    }

                    DataType type = (DataType)buffer.ReadByte();
                    if (type == DataType.Unknown)
                    {
                        throw new Exception();
                    }

                    switch (type)
                    {
                    case DataType.Byte:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadByte()));
                        break;

                    case DataType.Ushort:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadUInt16()));
                        break;

                    case DataType.Uint:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadUInt32()));
                        break;

                    case DataType.Ulong:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadUInt64()));
                        break;

                    case DataType.Sbyte:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadSByte()));
                        break;

                    case DataType.Short:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadInt16()));
                        break;

                    case DataType.Int:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadInt32()));
                        break;

                    case DataType.Long:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadInt64()));
                        break;

                    case DataType.String:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadString()));
                        break;

                    case DataType.Double:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadDouble()));
                        break;

                    case DataType.Float:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadFloat()));
                        break;

                    case DataType.Bool:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadBoolean()));
                        break;

                    case DataType.IPEndPoint:
                        _fields.Add(key, new Pair <DataType, object>(type, buffer.ReadIPEndPoint()));
                        break;
                    }
                }

                Count = _fields.Count;
                Keys  = new string[_fields.Count];
                _fields.Keys.CopyTo(Keys, 0);
            }
            catch
            {
                _Empty();
            }
        }
 public override void ReadFromBuffer(NetBuffer buffer)
 {
     value = buffer.ReadDouble();
 }
 public double ReadDouble()
 {
     return(_buffer.ReadDouble());
 }
    /// <summary>
    /// 패킷에서 데이터 읽기 (RPC)
    /// </summary>
    /// <param name="type">파라미터 타입</param>
    public static object ReadObjectPacked(this NetBuffer buff, Type type)
    {
        if (type.IsNullable())
        {
            bool isNull = buff.ReadBoolean();

            if (isNull)
            {
                return(null);
            }
        }

        if (type == typeof(byte))
        {
            return(buff.ReadByte());
        }
        if (type == typeof(sbyte))
        {
            return(buff.ReadSByte());
        }
        if (type == typeof(ushort))
        {
            return(buff.ReadUInt16());
        }
        if (type == typeof(short))
        {
            return(buff.ReadInt16());
        }
        if (type == typeof(int))
        {
            return(buff.ReadInt32());
        }
        if (type == typeof(uint))
        {
            return(buff.ReadUInt32());
        }
        if (type == typeof(long))
        {
            return(buff.ReadInt64());
        }
        if (type == typeof(ulong))
        {
            return(buff.ReadUInt64());
        }
        if (type == typeof(float))
        {
            return(buff.ReadFloat());
        }
        if (type == typeof(double))
        {
            return(buff.ReadDouble());
        }
        if (type == typeof(string))
        {
            return(buff.ReadString());
        }
        if (type == typeof(bool))
        {
            return(buff.ReadBoolean());
        }
        if (type == typeof(Vector3))
        {
            Vector3 v = default(Vector3);
            buff.Read(ref v);
            return(v);
        }
        if (type == typeof(char))
        {
            return(buff.ReadByte());
        }
        if (type.IsEnum)
        {
            return(buff.ReadInt32());
        }
        if (type == typeof(List <int>))
        {
            List <int> v        = new List <int>();
            byte       listSize = buff.ReadByte();
            for (byte i = 0; i < listSize; ++i)
            {
                v.Add(buff.ReadInt32());
            }
            return(v);
        }
        if (type == typeof(List <short>))
        {
            List <short> v        = new List <short>();
            byte         listSize = buff.ReadByte();
            for (byte i = 0; i < listSize; ++i)
            {
                v.Add(buff.ReadInt16());
            }
            return(v);
        }
        if (type == typeof(List <float>))
        {
            List <float> v        = new List <float>();
            byte         listSize = buff.ReadByte();
            for (byte i = 0; i < listSize; ++i)
            {
                v.Add(buff.ReadFloat());
            }
            return(v);
        }


        throw new ArgumentException("BitReader cannot read type " + type.Name);
    }
Example #11
0
        public StateUpdateEventArgs(NetBuffer msg) : base(msg)
        {
            EntitiesUpdatedState = new List <StateUpdateData>();
            RemarkableEvents     = new List <RemarkableEventData>();

            LastAcknowledgedActionID = msg.ReadUInt64();
            Time = msg.ReadDouble();
            Vec2 velocity  = new Vec2(msg.ReadFloat(), msg.ReadFloat());
            byte nbClients = msg.ReadByte();

            for (byte i = 0; i < nbClients; ++i)
            {
                ulong             id         = msg.ReadUInt64();
                Vec2              pos        = new Vec2(msg.ReadFloat(), msg.ReadFloat());
                ChampionAnimation anim       = (ChampionAnimation)msg.ReadByte();
                bool              facingLeft = msg.ReadBoolean();

                EntitiesUpdatedState.Add(new StateUpdateData(id, pos, velocity, anim, facingLeft));
            }
            while (msg.Position != msg.LengthBits)
            {
                ServerCommand       cmd  = (ServerCommand)msg.ReadByte();
                RemarkableEventData data = null;
                switch (cmd)
                {
                case ServerCommand.SpellCast:
                    data = new SpellCastEventData(
                        msg.ReadUInt64(),
                        msg.ReadUInt64(),
                        (SpellTypes)msg.ReadByte(),
                        msg.ReadFloat(),
                        new Vec2(msg.ReadFloat(), msg.ReadFloat()),
                        new Vec2(msg.ReadFloat(), msg.ReadFloat()),
                        TimeSpan.FromSeconds(msg.ReadFloat()),
                        msg.ReadFloat(),
                        msg.ReadFloat());
                    break;

                case ServerCommand.SpellDisappear:
                    data = new SpellDisappearEventData(msg.ReadUInt64());
                    break;

                case ServerCommand.StatsChanged:
                    data = new StatsChangedEventData(msg.ReadUInt64(), msg.ReadFloat());
                    break;

                case ServerCommand.ChampionDied:
                    data = new ChampionDiedEventData(msg.ReadUInt64(),
                                                     msg.ReadUInt64(),
                                                     msg.ReadUInt32(), msg.ReadUInt32(), msg.ReadUInt32(), msg.ReadUInt32(),
                                                     TimeSpan.FromSeconds(msg.ReadUInt16()));
                    break;

                case ServerCommand.StructureStatsChanged:
                    data = new StructureStatsChangedEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
                                                              (StructureTypes)msg.ReadByte(),
                                                              msg.ReadFloat());
                    break;

                case ServerCommand.StructureDestroyed:
                    data = new StructureDestroyedEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
                                                           (StructureTypes)msg.ReadByte());
                    break;

                case ServerCommand.EndOfGame:
                    data = new EndOfGameEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right);
                    break;

                case ServerCommand.TowerPreparingToShoot:
                    data = new TowerPreparingToShootEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
                                                              (StructureTypes)msg.ReadByte());
                    break;

                default:
                    Debug.Fail("Unknown server command when updating (unknown remarkable event)");
                    break;
                }
                if (data != null)
                {
                    RemarkableEvents.Add(data);
                }
            }
        }
Example #12
0
 public void Deserialize(NetBuffer reader)
 {
     SenderTimestamp = reader.ReadDouble();
     PlayerCount     = reader.ReadUInt16();
 }
Example #13
0
 public void Deserialize(NetBuffer networkReader)
 {
     FrameId        = networkReader.ReadUInt16();
     Timestamp      = networkReader.ReadDouble();
     FixedTimestamp = networkReader.ReadDouble();
 }
Example #14
0
 public void Deserialize(NetBuffer reader)
 {
     Timestamp = reader.ReadDouble();
 }