public static void WriteDynamics(GameClient client) { if (dynamics == null) { if (BaseVobInstance.GetCountDynamics() > 0 && ModelInstance.CountDynamics > 0) { PacketWriter strm = new PacketWriter(); // MODELS if (strm.Write(ModelInstance.CountDynamics > 0)) { strm.Write((ushort)ModelInstance.CountDynamics); ModelInstance.ForEachDynamic(model => { model.WriteStream(strm); }); } // INSTANCES if (strm.Write(BaseVobInstance.GetCountDynamics() > 0)) { strm.Write((ushort)BaseVobInstance.GetCountDynamics()); BaseVobInstance.ForEachDynamic(v => { strm.Write((byte)v.ScriptObject.GetVobType()); v.WriteStream(strm); }); } byte[] arr = strm.CopyData(); int decomp = arr.Length; using (var ms = new System.IO.MemoryStream(decomp)) { using (var ds = new System.IO.Compression.DeflateStream(ms, System.IO.Compression.CompressionMode.Compress)) { ds.Write(arr, 0, decomp); } arr = ms.ToArray(); } strm.Reset(); strm.Write((byte)ServerMessages.DynamicsMessage); strm.Write(decomp); strm.Write(arr, 0, arr.Length); dynamics = strm.CopyData(); } else { return; } } client.Send(dynamics, dynamics.Length, NetPriority.Low, NetReliability.Reliable, '\0'); }
internal static PacketWriter SetupStream(ClientMessages id) { packetWriter.Reset(); packetWriter.Write((byte)id); return(packetWriter); }
internal static PacketWriter SetupStream(ServerMessages ID) { pktWriter.Reset(); pktWriter.Write((byte)ID); return(pktWriter); }