Exemplo n.º 1
0
        public void WriteStream(NetStream stream)
        {
            if (stream == null)
            {
                EnsureFitsBits(5);
                Write(0, 4, 14, 22);
                return;
            }
            uint num = (uint)stream.UseBuffedSize();

            if (num < 16)
            {
                EnsureFitsBits((int)(5 + num * 8));
                Write(num, 4, 14, 22);
                for (int i = 0; i < num; i++)
                {
                    Write(stream.buffer[i]);
                }
            }
            else
            {
                Write(num, 4, 14, 22);
                EnsureFitsBytes(stream.UseBuffedSize(), pad: true);
                PadToByte();
                Array.Copy(stream.GetOriginalBuffer(), 0L, buffer, currentByte, num);
                currentByte += (int)num;
            }
        }
Exemplo n.º 2
0
 public bool CanBuffer(NetStream stream, int expectedContainerId)
 {
     if (unreliableStream.position == 0)
     {
         return(true);
     }
     if (currentBufferTag != NetGame.currentLevelInstanceID)
     {
         return(false);
     }
     if (expectedContainerId != -1 && expectedContainerId != writeFrameId)
     {
         return(false);
     }
     return(unreliableStream.UseBuffedSize() + stream.UseBuffedSize() + 2 < NetStream.CalculateSizeForTier(0));
 }