You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
C#
55 lines
1.1 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using BitSet;
|
|
using TF2Net.Data;
|
|
|
|
namespace TF2Net.NetMessages
|
|
{
|
|
[DebuggerDisplay("{Description, nq}")]
|
|
public class NetSoundMessage : INetMessage
|
|
{
|
|
const int SOUND_COUNT_BITS = 8;
|
|
const int RELIABLE_SIZE_BITS = 8;
|
|
const int UNRELIABLE_SIZE_BITS = 16;
|
|
|
|
public bool Reliable { get; set; }
|
|
public int SoundCount { get; set; }
|
|
|
|
public BitStream Data { get; set; }
|
|
|
|
public string Description
|
|
{
|
|
get
|
|
{
|
|
return string.Format("svc_Sounds: number {0},{1} bytes {2}",
|
|
SoundCount, Reliable ? " reliable," : "", BitInfo.BitsToBytes(Data.Length));
|
|
}
|
|
}
|
|
|
|
public void ReadMsg(BitStream stream)
|
|
{
|
|
Reliable = stream.ReadBool();
|
|
|
|
ulong bitCount;
|
|
if (Reliable)
|
|
{
|
|
SoundCount = 1;
|
|
bitCount = stream.ReadULong(RELIABLE_SIZE_BITS);
|
|
}
|
|
else
|
|
{
|
|
SoundCount = stream.ReadInt(SOUND_COUNT_BITS);
|
|
bitCount = stream.ReadULong(UNRELIABLE_SIZE_BITS);
|
|
}
|
|
|
|
Data = stream.Subsection(stream.Cursor, stream.Cursor + bitCount);
|
|
stream.Seek(bitCount, System.IO.SeekOrigin.Current);
|
|
}
|
|
|
|
public void ApplyWorldState(WorldState ws)
|
|
{
|
|
//throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|