using System; using System.Text; namespace UnityEngine.Networking { // Token: 0x02000064 RID: 100 public class NetworkWriter { // Token: 0x060004F0 RID: 1264 RVA: 0x0001CDA7 File Offset: 0x0001AFA7 public NetworkWriter() { this.m_Buffer = new NetBuffer(); if (NetworkWriter.s_Encoding == null) { NetworkWriter.s_Encoding = new UTF8Encoding(); NetworkWriter.s_StringWriteBuffer = new byte[32768]; } } // Token: 0x060004F1 RID: 1265 RVA: 0x0001CDE0 File Offset: 0x0001AFE0 public NetworkWriter(byte[] buffer) { this.m_Buffer = new NetBuffer(buffer); if (NetworkWriter.s_Encoding == null) { NetworkWriter.s_Encoding = new UTF8Encoding(); NetworkWriter.s_StringWriteBuffer = new byte[32768]; } } // Token: 0x170000DA RID: 218 // (get) Token: 0x060004F2 RID: 1266 RVA: 0x0001CE1C File Offset: 0x0001B01C public short Position { get { return (short)this.m_Buffer.Position; } } // Token: 0x060004F3 RID: 1267 RVA: 0x0001CE40 File Offset: 0x0001B040 public byte[] ToArray() { byte[] array = new byte[this.m_Buffer.AsArraySegment().Count]; Array.Copy(this.m_Buffer.AsArraySegment().Array, array, this.m_Buffer.AsArraySegment().Count); return array; } // Token: 0x060004F4 RID: 1268 RVA: 0x0001CEA0 File Offset: 0x0001B0A0 public byte[] AsArray() { return this.AsArraySegment().Array; } // Token: 0x060004F5 RID: 1269 RVA: 0x0001CEC4 File Offset: 0x0001B0C4 internal ArraySegment AsArraySegment() { return this.m_Buffer.AsArraySegment(); } // Token: 0x060004F6 RID: 1270 RVA: 0x0001CEE4 File Offset: 0x0001B0E4 public void WritePackedUInt32(uint value) { if (value <= 240U) { this.Write((byte)value); } else if (value <= 2287U) { this.Write((byte)((value - 240U) / 256U + 241U)); this.Write((byte)((value - 240U) % 256U)); } else if (value <= 67823U) { this.Write(249); this.Write((byte)((value - 2288U) / 256U)); this.Write((byte)((value - 2288U) % 256U)); } else if (value <= 16777215U) { this.Write(250); this.Write((byte)(value & 255U)); this.Write((byte)((value >> 8) & 255U)); this.Write((byte)((value >> 16) & 255U)); } else { this.Write(251); this.Write((byte)(value & 255U)); this.Write((byte)((value >> 8) & 255U)); this.Write((byte)((value >> 16) & 255U)); this.Write((byte)((value >> 24) & 255U)); } } // Token: 0x060004F7 RID: 1271 RVA: 0x0001D024 File Offset: 0x0001B224 public void WritePackedUInt64(ulong value) { if (value <= 240UL) { this.Write((byte)value); } else if (value <= 2287UL) { this.Write((byte)((value - 240UL) / 256UL + 241UL)); this.Write((byte)((value - 240UL) % 256UL)); } else if (value <= 67823UL) { this.Write(249); this.Write((byte)((value - 2288UL) / 256UL)); this.Write((byte)((value - 2288UL) % 256UL)); } else if (value <= 16777215UL) { this.Write(250); this.Write((byte)(value & 255UL)); this.Write((byte)((value >> 8) & 255UL)); this.Write((byte)((value >> 16) & 255UL)); } else if (value <= (ulong)(-1)) { this.Write(251); this.Write((byte)(value & 255UL)); this.Write((byte)((value >> 8) & 255UL)); this.Write((byte)((value >> 16) & 255UL)); this.Write((byte)((value >> 24) & 255UL)); } else if (value <= 1099511627775UL) { this.Write(252); this.Write((byte)(value & 255UL)); this.Write((byte)((value >> 8) & 255UL)); this.Write((byte)((value >> 16) & 255UL)); this.Write((byte)((value >> 24) & 255UL)); this.Write((byte)((value >> 32) & 255UL)); } else if (value <= 281474976710655UL) { this.Write(253); this.Write((byte)(value & 255UL)); this.Write((byte)((value >> 8) & 255UL)); this.Write((byte)((value >> 16) & 255UL)); this.Write((byte)((value >> 24) & 255UL)); this.Write((byte)((value >> 32) & 255UL)); this.Write((byte)((value >> 40) & 255UL)); } else if (value <= 72057594037927935UL) { this.Write(254); this.Write((byte)(value & 255UL)); this.Write((byte)((value >> 8) & 255UL)); this.Write((byte)((value >> 16) & 255UL)); this.Write((byte)((value >> 24) & 255UL)); this.Write((byte)((value >> 32) & 255UL)); this.Write((byte)((value >> 40) & 255UL)); this.Write((byte)((value >> 48) & 255UL)); } else { this.Write(byte.MaxValue); this.Write((byte)(value & 255UL)); this.Write((byte)((value >> 8) & 255UL)); this.Write((byte)((value >> 16) & 255UL)); this.Write((byte)((value >> 24) & 255UL)); this.Write((byte)((value >> 32) & 255UL)); this.Write((byte)((value >> 40) & 255UL)); this.Write((byte)((value >> 48) & 255UL)); this.Write((byte)((value >> 56) & 255UL)); } } // Token: 0x060004F8 RID: 1272 RVA: 0x0001D3B7 File Offset: 0x0001B5B7 public void Write(NetworkInstanceId value) { this.WritePackedUInt32(value.Value); } // Token: 0x060004F9 RID: 1273 RVA: 0x0001D3C7 File Offset: 0x0001B5C7 public void Write(NetworkSceneId value) { this.WritePackedUInt32(value.Value); } // Token: 0x060004FA RID: 1274 RVA: 0x0001D3D7 File Offset: 0x0001B5D7 public void Write(char value) { this.m_Buffer.WriteByte((byte)value); } // Token: 0x060004FB RID: 1275 RVA: 0x0001D3E7 File Offset: 0x0001B5E7 public void Write(byte value) { this.m_Buffer.WriteByte(value); } // Token: 0x060004FC RID: 1276 RVA: 0x0001D3F6 File Offset: 0x0001B5F6 public void Write(sbyte value) { this.m_Buffer.WriteByte((byte)value); } // Token: 0x060004FD RID: 1277 RVA: 0x0001D406 File Offset: 0x0001B606 public void Write(short value) { this.m_Buffer.WriteByte2((byte)(value & 255), (byte)((value >> 8) & 255)); } // Token: 0x060004FE RID: 1278 RVA: 0x0001D426 File Offset: 0x0001B626 public void Write(ushort value) { this.m_Buffer.WriteByte2((byte)(value & 255), (byte)((value >> 8) & 255)); } // Token: 0x060004FF RID: 1279 RVA: 0x0001D446 File Offset: 0x0001B646 public void Write(int value) { this.m_Buffer.WriteByte4((byte)(value & 255), (byte)((value >> 8) & 255), (byte)((value >> 16) & 255), (byte)((value >> 24) & 255)); } // Token: 0x06000500 RID: 1280 RVA: 0x0001D47C File Offset: 0x0001B67C public void Write(uint value) { this.m_Buffer.WriteByte4((byte)(value & 255U), (byte)((value >> 8) & 255U), (byte)((value >> 16) & 255U), (byte)((value >> 24) & 255U)); } // Token: 0x06000501 RID: 1281 RVA: 0x0001D4B4 File Offset: 0x0001B6B4 public void Write(long value) { this.m_Buffer.WriteByte8((byte)(value & 255L), (byte)((value >> 8) & 255L), (byte)((value >> 16) & 255L), (byte)((value >> 24) & 255L), (byte)((value >> 32) & 255L), (byte)((value >> 40) & 255L), (byte)((value >> 48) & 255L), (byte)((value >> 56) & 255L)); } // Token: 0x06000502 RID: 1282 RVA: 0x0001D52C File Offset: 0x0001B72C public void Write(ulong value) { this.m_Buffer.WriteByte8((byte)(value & 255UL), (byte)((value >> 8) & 255UL), (byte)((value >> 16) & 255UL), (byte)((value >> 24) & 255UL), (byte)((value >> 32) & 255UL), (byte)((value >> 40) & 255UL), (byte)((value >> 48) & 255UL), (byte)((value >> 56) & 255UL)); } // Token: 0x06000503 RID: 1283 RVA: 0x0001D5A1 File Offset: 0x0001B7A1 public void Write(float value) { NetworkWriter.s_FloatConverter.floatValue = value; this.Write(NetworkWriter.s_FloatConverter.intValue); } // Token: 0x06000504 RID: 1284 RVA: 0x0001D5BF File Offset: 0x0001B7BF public void Write(double value) { NetworkWriter.s_FloatConverter.doubleValue = value; this.Write(NetworkWriter.s_FloatConverter.longValue); } // Token: 0x06000505 RID: 1285 RVA: 0x0001D5E0 File Offset: 0x0001B7E0 public void Write(decimal value) { int[] bits = decimal.GetBits(value); this.Write(bits[0]); this.Write(bits[1]); this.Write(bits[2]); this.Write(bits[3]); } // Token: 0x06000506 RID: 1286 RVA: 0x0001D61C File Offset: 0x0001B81C public void Write(string value) { if (value == null) { this.m_Buffer.WriteByte2(0, 0); } else { int byteCount = NetworkWriter.s_Encoding.GetByteCount(value); if (byteCount >= 32768) { throw new IndexOutOfRangeException("Serialize(string) too long: " + value.Length); } this.Write((ushort)byteCount); int bytes = NetworkWriter.s_Encoding.GetBytes(value, 0, value.Length, NetworkWriter.s_StringWriteBuffer, 0); this.m_Buffer.WriteBytes(NetworkWriter.s_StringWriteBuffer, (ushort)bytes); } } // Token: 0x06000507 RID: 1287 RVA: 0x0001D6A9 File Offset: 0x0001B8A9 public void Write(bool value) { if (value) { this.m_Buffer.WriteByte(1); } else { this.m_Buffer.WriteByte(0); } } // Token: 0x06000508 RID: 1288 RVA: 0x0001D6D0 File Offset: 0x0001B8D0 public void Write(byte[] buffer, int count) { if (count > 65535) { if (LogFilter.logError) { Debug.LogError("NetworkWriter Write: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes."); } } else { this.m_Buffer.WriteBytes(buffer, (ushort)count); } } // Token: 0x06000509 RID: 1289 RVA: 0x0001D724 File Offset: 0x0001B924 public void Write(byte[] buffer, int offset, int count) { if (count > 65535) { if (LogFilter.logError) { Debug.LogError("NetworkWriter Write: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes."); } } else { this.m_Buffer.WriteBytesAtOffset(buffer, (ushort)offset, (ushort)count); } } // Token: 0x0600050A RID: 1290 RVA: 0x0001D77C File Offset: 0x0001B97C public void WriteBytesAndSize(byte[] buffer, int count) { if (buffer == null || count == 0) { this.Write(0); } else if (count > 65535) { if (LogFilter.logError) { Debug.LogError("NetworkWriter WriteBytesAndSize: buffer is too large (" + count + ") bytes. The maximum buffer size is 64K bytes."); } } else { this.Write((ushort)count); this.m_Buffer.WriteBytes(buffer, (ushort)count); } } // Token: 0x0600050B RID: 1291 RVA: 0x0001D7F0 File Offset: 0x0001B9F0 public void WriteBytesFull(byte[] buffer) { if (buffer == null) { this.Write(0); } else if (buffer.Length > 65535) { if (LogFilter.logError) { Debug.LogError("NetworkWriter WriteBytes: buffer is too large (" + buffer.Length + ") bytes. The maximum buffer size is 64K bytes."); } } else { this.Write((ushort)buffer.Length); this.m_Buffer.WriteBytes(buffer, (ushort)buffer.Length); } } // Token: 0x0600050C RID: 1292 RVA: 0x0001D866 File Offset: 0x0001BA66 public void Write(Vector2 value) { this.Write(value.x); this.Write(value.y); } // Token: 0x0600050D RID: 1293 RVA: 0x0001D883 File Offset: 0x0001BA83 public void Write(Vector3 value) { this.Write(value.x); this.Write(value.y); this.Write(value.z); } // Token: 0x0600050E RID: 1294 RVA: 0x0001D8AD File Offset: 0x0001BAAD public void Write(Vector4 value) { this.Write(value.x); this.Write(value.y); this.Write(value.z); this.Write(value.w); } // Token: 0x0600050F RID: 1295 RVA: 0x0001D8E4 File Offset: 0x0001BAE4 public void Write(Color value) { this.Write(value.r); this.Write(value.g); this.Write(value.b); this.Write(value.a); } // Token: 0x06000510 RID: 1296 RVA: 0x0001D91B File Offset: 0x0001BB1B public void Write(Color32 value) { this.Write(value.r); this.Write(value.g); this.Write(value.b); this.Write(value.a); } // Token: 0x06000511 RID: 1297 RVA: 0x0001D952 File Offset: 0x0001BB52 public void Write(Quaternion value) { this.Write(value.x); this.Write(value.y); this.Write(value.z); this.Write(value.w); } // Token: 0x06000512 RID: 1298 RVA: 0x0001D989 File Offset: 0x0001BB89 public void Write(Rect value) { this.Write(value.xMin); this.Write(value.yMin); this.Write(value.width); this.Write(value.height); } // Token: 0x06000513 RID: 1299 RVA: 0x0001D9C0 File Offset: 0x0001BBC0 public void Write(Plane value) { this.Write(value.normal); this.Write(value.distance); } // Token: 0x06000514 RID: 1300 RVA: 0x0001D9DD File Offset: 0x0001BBDD public void Write(Ray value) { this.Write(value.direction); this.Write(value.origin); } // Token: 0x06000515 RID: 1301 RVA: 0x0001D9FC File Offset: 0x0001BBFC public void Write(Matrix4x4 value) { this.Write(value.m00); this.Write(value.m01); this.Write(value.m02); this.Write(value.m03); this.Write(value.m10); this.Write(value.m11); this.Write(value.m12); this.Write(value.m13); this.Write(value.m20); this.Write(value.m21); this.Write(value.m22); this.Write(value.m23); this.Write(value.m30); this.Write(value.m31); this.Write(value.m32); this.Write(value.m33); } // Token: 0x06000516 RID: 1302 RVA: 0x0001DADC File Offset: 0x0001BCDC public void Write(NetworkHash128 value) { this.Write(value.i0); this.Write(value.i1); this.Write(value.i2); this.Write(value.i3); this.Write(value.i4); this.Write(value.i5); this.Write(value.i6); this.Write(value.i7); this.Write(value.i8); this.Write(value.i9); this.Write(value.i10); this.Write(value.i11); this.Write(value.i12); this.Write(value.i13); this.Write(value.i14); this.Write(value.i15); } // Token: 0x06000517 RID: 1303 RVA: 0x0001DBBA File Offset: 0x0001BDBA public void Write(NetworkIdentity value) { if (value == null) { this.WritePackedUInt32(0U); } else { this.Write(value.netId); } } // Token: 0x06000518 RID: 1304 RVA: 0x0001DBE4 File Offset: 0x0001BDE4 public void Write(Transform value) { if (value == null || value.gameObject == null) { this.WritePackedUInt32(0U); } else { NetworkIdentity component = value.gameObject.GetComponent(); if (component != null) { this.Write(component.netId); } else { if (LogFilter.logWarn) { Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity"); } this.WritePackedUInt32(0U); } } } // Token: 0x06000519 RID: 1305 RVA: 0x0001DC74 File Offset: 0x0001BE74 public void Write(GameObject value) { if (value == null) { this.WritePackedUInt32(0U); } else { NetworkIdentity component = value.GetComponent(); if (component != null) { this.Write(component.netId); } else { if (LogFilter.logWarn) { Debug.LogWarning("NetworkWriter " + value + " has no NetworkIdentity"); } this.WritePackedUInt32(0U); } } } // Token: 0x0600051A RID: 1306 RVA: 0x0001DCEB File Offset: 0x0001BEEB public void Write(MessageBase msg) { msg.Serialize(this); } // Token: 0x0600051B RID: 1307 RVA: 0x0001DCF5 File Offset: 0x0001BEF5 public void SeekZero() { this.m_Buffer.SeekZero(); } // Token: 0x0600051C RID: 1308 RVA: 0x0001DD03 File Offset: 0x0001BF03 public void StartMessage(short msgType) { this.SeekZero(); this.m_Buffer.WriteByte2(0, 0); this.Write(msgType); } // Token: 0x0600051D RID: 1309 RVA: 0x0001DD20 File Offset: 0x0001BF20 public void FinishMessage() { this.m_Buffer.FinishMessage(); } // Token: 0x0400022A RID: 554 private const int k_MaxStringLength = 32768; // Token: 0x0400022B RID: 555 private NetBuffer m_Buffer; // Token: 0x0400022C RID: 556 private static Encoding s_Encoding; // Token: 0x0400022D RID: 557 private static byte[] s_StringWriteBuffer; // Token: 0x0400022E RID: 558 private static UIntFloat s_FloatConverter; } }