Read() public method

public Read ( int index, int count ) : byte[]
index int
count int
return byte[]
Exemplo n.º 1
0
            public ParameterGroup(NetBuffer buffer)
            {
                this.id = buffer.Read <Id>().Generic <Player>();
                int count = buffer.ReadByte();

                this.values = new List <ValueParameters>(count);
                for (int i = 0; i < count; i++)
                {
                    this.values.Add(buffer.Read <ValueParameters>());
                }
            }
Exemplo n.º 2
0
            public CommandImplementation(GameState game, NetBuffer buffer)
                : base(CommandType.ParticlePlanetCollision, game)
            {
                var parameters = buffer.Read <Parameters>();

                this.body     = game.Bodies[parameters.BodyId];
                this.particle = game.FreeObjects[parameters.ParticleId];
            }
Exemplo n.º 3
0
        public static T Read <T>(this NetBuffer buffer)
            where T : struct
        {
            T s;

            buffer.Read(out s);
            return(s);
        }
Exemplo n.º 4
0
            public RequestImplementation(PlayerConnectionLookup connectionLookup, NetConnection connection,
                                         NetBuffer buffer, GameState game)
                : base(RequestType.ShootDebugParticleFromPlanet, game, connectionLookup, connection)
            {
                var p = buffer.Read <RequestParameters>();

                this.body      = game.Bodies[p.BodyId];
                this.direction = p.Direction;
            }
Exemplo n.º 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>());
                }
            }
Exemplo n.º 6
0
 public Implementation(PlayerConnectionLookup connectionLookup, NetConnection connection, NetBuffer buffer, GameState game)
     : base(RequestType.EconomyValueInvestmentChanged, CommandType.EconomyValueInvestmentChanged, connectionLookup, connection, game)
 {
     this.p = buffer.Read <Parameters>();
 }
    /// <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);
    }
Exemplo n.º 8
0
 public CommandImplementation(NetBuffer buffer, GameState game)
     : base(CommandType.ShootProjectileFromPlanet, game)
 {
     this.ps = buffer.Read <CommandParameters>();
 }