Asgard.Core.Network.Bitstream.ReadVector2 C# (CSharp) Method

ReadVector2() public method

public ReadVector2 ( ) : System.Vector2
return System.Vector2
        public Vector2 ReadVector2()
        {
            var hasXData = _buffer.ReadBoolean();
            var hasYData = _buffer.ReadBoolean();
            float x = 0f, y=0f;
            if (hasXData)
            {
                x = _buffer.ReadFloat();
            }
            if (hasYData)
            {
                y = _buffer.ReadFloat();
            }
            return new Vector2(x,y);
        }

Usage Example

Exemplo n.º 1
0
        public override void Deserialize(Bitstream msg)
        {
            State = new List<PlayerStateData>();
            int count = msg.ReadUInt16();
            for (int i = 0; i < count; ++i)
            {
                var o = new PlayerStateData();
                o.Forward = msg.ReadBool();
                o.Back = msg.ReadBool();
                o.Left = msg.ReadBool();
                o.Right = msg.ReadBool();

                o.Position = msg.ReadVector2();
                o.SimTick = (uint)msg.ReadInt32();

                State.Add(o);
            }
            SnapId = msg.ReadInt32();
        }