本文整理汇总了C#中VRage.Library.Collections.BitStream.ReadUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BitStream.ReadUInt32方法的具体用法?C# BitStream.ReadUInt32怎么用?C# BitStream.ReadUInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRage.Library.Collections.BitStream
的用法示例。
在下文中一共展示了BitStream.ReadUInt32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public void Serialize(BitStream stream, Type baseType, ref Type obj)
{
if (stream.Reading)
{
var id = new TypeId(stream.ReadUInt32());
obj = MyMultiplayer.Static.ReplicationLayer.GetType(id);
}
else
{
var id = MyMultiplayer.Static.ReplicationLayer.GetTypeId(obj);
stream.WriteUInt32(id);
}
}
示例2: ReadShared
private void ReadShared(BitStream stream, MyNetworkClient sender, out MyEntity controlledEntity)
{
controlledEntity = null;
ClientTimeStamp = stream.ReadUInt32();
var hasControlledEntity = stream.ReadBool();
if (!hasControlledEntity)
{
Vector3D pos = Vector3D.Zero;
stream.Serialize(ref pos); // 24B
Position = pos;
}
else
{
var entityId = stream.ReadInt64();
MyEntity entity;
if (!MyEntities.TryGetEntityById(entityId, out entity))
return;
Position = entity.WorldMatrix.Translation;
// TODO: Obsolete check?
MySyncEntity syncEntity = entity.SyncObject as MySyncEntity;
if (syncEntity == null)
return;
controlledEntity = entity;
}
}
示例3: ReadInventory
private void ReadInventory(BitStream stream)
{
if(stream.ReadBool() == false)
{
return;
}
if(m_recievedPacketIds == null)
{
m_recievedPacketIds = new MyQueue<uint>(RECIEVED_PACKET_HISTORY);
}
uint packetId = stream.ReadUInt32();
bool apply = true;
if (m_recievedPacketIds.Count == RECIEVED_PACKET_HISTORY)
{
m_recievedPacketIds.Dequeue();
}
if (m_recievedPacketIds.InternalArray.Contains(packetId) == false)
{
m_recievedPacketIds.Enqueue(packetId);
}
else
{
apply = false;
}
bool hasItems = stream.ReadBool();
if(hasItems)
{
int numItems = stream.ReadInt32();
for (int i = 0; i < numItems; ++i)
{
uint itemId = stream.ReadUInt32();
MyFixedPoint amout = new MyFixedPoint();
amout.RawValue = stream.ReadInt64();
if (apply)
{
Inventory.UpdateItemAmoutClient(itemId, amout);
}
}
}
hasItems = stream.ReadBool();
if (hasItems)
{
int numItems = stream.ReadInt32();
for (int i = 0; i < numItems; ++i)
{
uint itemId = stream.ReadUInt32();
if (apply)
{
Inventory.RemoveItemClient(itemId);
}
}
}
hasItems = stream.ReadBool();
if (hasItems)
{
int numItems = stream.ReadInt32();
for (int i = 0; i < numItems; ++i)
{
int position = stream.ReadInt32();
MyPhysicalInventoryItem item;
VRage.Serialization.MySerializer.CreateAndRead(stream, out item, MyObjectBuilderSerializer.Dynamic);
if (apply)
{
Inventory.AddItemClient(position, item);
}
}
}
hasItems = stream.ReadBool();
if (hasItems)
{
int numItems = stream.ReadInt32();
for (int i = 0; i < numItems; ++i)
{
int position = stream.ReadInt32();
int newPosition = stream.ReadInt32();
if (apply)
{
Inventory.SwapItemClient(position, newPosition);
}
}
}
Inventory.Refresh();
}
示例4: Read
public static Quaternion Read(BitStream stream)
{
float x, y, z, w;
// note: you're going to want to normalize the quaternion returned from this function
uint largest = stream.ReadUInt32(2);
float a = stream.ReadUInt32(bits) * inverse_scale * (maximum - minimum) + minimum;
float b = stream.ReadUInt32(bits) * inverse_scale * (maximum - minimum) + minimum;
float c = stream.ReadUInt32(bits) * inverse_scale * (maximum - minimum) + minimum;
switch (largest)
{
case 0:
x = (float)Math.Sqrt(1 - a * a - b * b - c * c);
y = a;
z = b;
w = c;
break;
case 1:
x = a;
y = (float)Math.Sqrt(1 - a * a - b * b - c * c);
z = b;
w = c;
break;
case 2:
x = a;
y = b;
z = (float)Math.Sqrt(1 - a * a - b * b - c * c);
w = c;
break;
case 3:
x = a;
y = b;
z = c;
w = (float)Math.Sqrt(1 - a * a - b * b - c * c);
break;
default:
Debug.Fail("Error");
x = 0;
y = 0;
z = 0;
w = 1;
break;
}
return Quaternion.Normalize(new Quaternion(x, y, z, w));
}