本文整理汇总了C#中BitReader类的典型用法代码示例。如果您正苦于以下问题:C# BitReader类的具体用法?C# BitReader怎么用?C# BitReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BitReader类属于命名空间,在下文中一共展示了BitReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public static ClientLoadoutOnlineThing Deserialize(BitReader br)
{
var clot = new ClientLoadoutOnlineThing(); // ha, "clot"
clot.Unknown1 = br.ReadUInt32();
clot.Unknown2 = br.ReadUInt32Max(MAX_UNKNOWN2);
return clot;
}
示例2: Deserialize
public static Reservation Deserialize(UInt32 versionMajor, UInt32 versionMinor, BitReader br)
{
var r = new Reservation();
r.Unknown1 = br.ReadUInt32FromBits(3);
r.PlayerId = UniqueId.Deserialize(br);
if (r.PlayerId.Type != UniqueId.UniqueIdType.Unknown)
{
r.PlayerName = br.ReadString();
}
if (versionMajor < 868 || versionMinor < 12)
{
r.Unknown2 = br.ReadBitsAsBytes(2)[0];
}
else
{
r.Unknown2 = br.ReadByte();
}
/*
ReservationStatus_None,
ReservationStatus_Reserved,
ReservationStatus_Joining,
ReservationStatus_InGame,
ReservationStatus_MAX
*/
return r;
}
示例3: Deserialize
public static ActiveActor Deserialize(BitReader br)
{
var aa = new ActiveActor();
aa.Active = br.ReadBit();
aa.ActorId = br.ReadUInt32();
return aa;
}
示例4: Deserialize
public static ClientLoadouts Deserialize(BitReader br)
{
var clo = new ClientLoadouts();
clo.Loadout1 = ClientLoadout.Deserialize(br);
clo.Loadout2 = ClientLoadout.Deserialize(br);
return clo;
}
示例5: Load
public static void Load(string fileName)
{
if (MapList.Count > 0) return;
using (Stream s = File.OpenRead(fileName))
{
using (BitReader read = new BitReader(s))
{
int count = read.ReadInt();
for (int i = 0; i < count; i++)
{
read.Seek(4 + i * 672);
MapData map = new MapData();
map.MapID = read.ReadInt();
map.MapNumber = read.ReadInt();
read.Skip(4);
map.Name = read.ReadZString(Encoding.ASCII);
read.Skip(672 - (int)(336 + (read.InnerStream.BaseStream.Position - (672 * i)) - 4));
map.DisplayName = read.ReadZString(Encoding.Unicode);
MapList.Add(map.MapID, map);
}
}
}
Console.WriteLine("[MapDB] Loaded {0} maps.", MapList.Count);
}
示例6: Encode
public static byte[] Encode(byte[] data, int bitsInterval)
{
byte[] reverseBytes = Convert.ReverseBitsInBytes(data);
using (var s = new MemoryStream(reverseBytes))
using (var reader = new BitReader(s))
{
using (var encoded = new MemoryStream())
using (var writer = new BitWriter(encoded))
{
int counter = 0;
while (reader.CanRead)
{
byte bit = reader.ReadBits(1);
writer.WriteBit(bit);
counter = (bit == 1) ? counter + 1 : 0;
if (counter == bitsInterval)
{
writer.WriteBit(0);
counter = 0;
}
}
writer.FlushBits();
return Convert.ReverseBitsInBytes(encoded.ToArray());
}
}
}
示例7: ApplyToFrame
public override object ApplyToFrame( VorbisCodec codec, BitReader reader, object args )
{
step2Flag[0] = true; step2Flag[1] = true;
finalY[0] = yList[0]; finalY[1] = yList[1];
SynthesiseAmplitudeValues();
return SynthesiseCurve( (int)args );
}
示例8: Deserialize
public static ClientLoadoutOnline Deserialize(BitReader br)
{
var clo = new ClientLoadoutOnline();
clo.ThingLists = new List<List<ClientLoadoutOnlineThing>>();
var listCount = br.ReadByte();
for (int i = 0; i < listCount; ++i)
{
var thingList = new List<ClientLoadoutOnlineThing>();
var thingCount = br.ReadByte();
for (int j = 0; j < thingCount; ++j)
{
thingList.Add(ClientLoadoutOnlineThing.Deserialize(br));
if ( i >= 21 )
{
thingList.Add(ClientLoadoutOnlineThing.Deserialize(br));
}
}
clo.ThingLists.Add(thingList);
}
return clo;
}
示例9: PlayerJoinEvent
public PlayerJoinEvent(BitReader bitReader, Replay replay, int playerIndex)
{
this.EventType = GameEventType.Inactive;
// This should probably be a series of {shl; or} on .Read(1)
// to make it version-independent
if (replay.ReplayBuild < 22612)
{
this.JoinFlags = (int)bitReader.Read(4);
}
else
{
this.JoinFlags = (int)bitReader.Read(12); // unknown
}
// Initialize player if not exists (true for observers)
Player player = replay.GetPlayerById(playerIndex);
if (player == null)
{
var p = new Player { PlayerType = PlayerType.Spectator };
replay.ClientList[playerIndex] = player = p;
}
// Initialize wireframe
player.Wireframe = new List<Unit>();
player.WireframeSubgroup = 0;
// Initialize control groups
player.Hotkeys = new List<Unit>[10];
}
示例10: SendResourcesEvent
public SendResourcesEvent(BitReader bitReader, Replay replay)
{
this.EventType = GameEventType.Other;
var playerId = (int)bitReader.Read(4);
Target = replay.GetPlayerById(playerId);
var someFlags = (int)bitReader.Read(3);
if (someFlags-- > 0) // 4
{
MineralsSent = ReadSignedAmount(bitReader.Read(32));
}
if (someFlags-- > 0) // 3
{
VespeneSent = ReadSignedAmount(bitReader.Read(32));
}
if (someFlags-- > 0) // 2
{
TerrazineSent = ReadSignedAmount(bitReader.Read(32));
}
if (someFlags-- > 0) // 1
{
CustomSent = ReadSignedAmount(bitReader.Read(32));
}
}
示例11: ReadSetupData
public override void ReadSetupData( VorbisCodec codec, BitReader reader )
{
int residueBegin = reader.ReadBits( 24 );
int residueEnd = reader.ReadBits( 24 );
int partitionSize = reader.ReadBits( 24 ) + 1;
int classifications = reader.ReadBits( 6 ) + 1;
int classbook = reader.ReadBits( 8 );
byte[] residueCascade = new byte[classifications];
for( int i = 0; i < residueCascade.Length; i++ ) {
int highBits = 0;
int lowBits = reader.ReadBits( 3 );
if( reader.ReadBit() == 1 )
highBits = reader.ReadBits( 5 );
residueCascade[i] = (byte)( lowBits | ( highBits << 3 ) );
}
byte[][] bookNumbers = new byte[classifications][];
for( int i = 0; i < bookNumbers.Length; i++ ) {
byte[] nums = new byte[8];
int cascade = residueCascade[i];
for( int j = 0; j < nums.Length; j++ ) {
if( ( cascade & ( 1 << j ) ) != 0 ) {
nums[j] = (byte)reader.ReadBits( 8 );
}
}
bookNumbers[i] = nums;
}
}
示例12: CameraEvent
public CameraEvent(BitReader bitReader, Replay replay)
{
TargetX = CFixedToDouble(bitReader.Read(16));
TargetY = CFixedToDouble(bitReader.Read(16));
HasDistance = bitReader.Read(1) != 0;
if (HasDistance)
{
Distance = CFixedToDouble(bitReader.Read(16));
}
HasPitch = bitReader.Read(1) != 0;
if (HasPitch)
{
Pitch = RotationAmountToDegrees(bitReader.Read(16));
}
HasYaw = bitReader.Read(1) != 0;
if (HasYaw)
{
Yaw = RotationAmountToDegrees(bitReader.Read(16));
}
HasHeightOffset = bitReader.Read(1) != 0;
if (HasHeightOffset)
{
// Debug since we're unsure
HeightOffset = CFixedToDouble(bitReader.Read(16));
}
this.EventType = GameEventType.Other;
}
示例13: Load
public static void Load(string fName)
{
using (Stream s = File.OpenRead(fName))
{
using (BitReader read = new BitReader(s))
{
int c = read.ReadInt();
for (int i = 0; i < c; i++)
{
TDBTactic t = new TDBTactic();
t.ItemId = read.ReadInt();
t.Species = read.ReadInt();
t.uInt1 = read.ReadInt();
t.Data = read.ReadInt();
t.uInt2 = read.ReadInt();
t.uInt3 = read.ReadInt();
t.uInt4 = read.ReadInt();
Tactics.Add(t.ItemId, t);
}
//More data at the end. Digimon names and descriptions.
}
}
Console.WriteLine("[TacticsDB] Loaded {0} entries.", Tactics.Count);
}
示例14: Decode
public static byte[] Decode(byte[] data, int from, int to, int bitsInterval)
{
var copiedData = new byte[to - from + 1];
Array.Copy(data, from, copiedData, 0, copiedData.Length);
byte[] reverseBytes = Convert.ReverseBitsInBytes(copiedData);
using (var s = new MemoryStream(reverseBytes))
using (var reader = new BitReader(s))
{
using (var decoded = new MemoryStream())
using (var writer = new BitWriter(decoded))
{
int counter = 0;
while (reader.CanRead)
{
byte bit = reader.ReadBits(1);
writer.WriteBit(bit);
counter = (bit == 1) ? counter + 1 : 0;
if (counter == bitsInterval)
{
reader.ReadBits(1); // skip next 0 bit
counter = 0;
}
}
// !! do not flush last bits
return Convert.ReverseBitsInBytes(decoded.ToArray());
}
}
}
示例15: SetData
public void SetData(ref BitReader Src, int CountBits)
{
Num = CountBits;
Pos = 0;
Src.Data = null;
Src.Data = new byte[((CountBits + 7) >> 3)];
Src.SerializeBits(Src.Data, CountBits);
}