本文整理汇总了C#中VRage.Library.Collections.BitStream.WriteUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BitStream.WriteUInt32方法的具体用法?C# BitStream.WriteUInt32怎么用?C# BitStream.WriteUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRage.Library.Collections.BitStream
的用法示例。
在下文中一共展示了BitStream.WriteUInt32方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: WriteShared
/// <summary>
/// Shared area for SE and ME. So far it writes whether you have a controlled entity or not. In the latter case you get the spectator position
/// </summary>
/// <param name="stream"></param>
/// <param name="validControlledEntity"></param>
private void WriteShared(BitStream stream, MyEntity controlledEntity)
{
stream.WriteUInt32(ClientTimeStamp);
stream.WriteBool(controlledEntity != null);
if (controlledEntity == null)
{
Vector3D pos = MySpectatorCameraController.Static.Position;
stream.Serialize(ref pos);
}
else
{
stream.WriteInt64(controlledEntity.EntityId);
}
}
示例3: PrepareSendData
private InventoryDeltaInformation PrepareSendData(ref InventoryDeltaInformation packetInfo, BitStream stream, int maxBitPosition,out bool needsSplit)
{
needsSplit = false;
int startStreamPosition = stream.BitPosition;
InventoryDeltaInformation sentData = new InventoryDeltaInformation();
sentData.HasChanges = false;
stream.WriteBool(false);
stream.WriteUInt32(packetInfo.MessageId);
stream.WriteBool(packetInfo.ChangedItems != null);
if (packetInfo.ChangedItems != null)
{
stream.WriteInt32(packetInfo.ChangedItems.Count);
if (stream.BitPosition > maxBitPosition)
{
needsSplit = true;
}
else
{
sentData.ChangedItems = new Dictionary<uint, MyFixedPoint>();
foreach (var item in packetInfo.ChangedItems)
{
stream.WriteUInt32(item.Key);
stream.WriteInt64(item.Value.RawValue);
if (stream.BitPosition <= maxBitPosition)
{
sentData.ChangedItems[item.Key] = item.Value;
sentData.HasChanges = true;
}
else
{
needsSplit = true;
}
}
}
}
stream.WriteBool(packetInfo.RemovedItems != null);
if (packetInfo.RemovedItems != null)
{
stream.WriteInt32(packetInfo.RemovedItems.Count);
if (stream.BitPosition > maxBitPosition)
{
needsSplit = true;
}
else
{
sentData.RemovedItems = new List<uint>();
foreach (var item in packetInfo.RemovedItems)
{
stream.WriteUInt32(item);
if (stream.BitPosition <= maxBitPosition)
{
sentData.RemovedItems.Add(item);
sentData.HasChanges = true;
}
else
{
needsSplit = true;
}
}
}
}
stream.WriteBool(packetInfo.NewItems != null);
if (packetInfo.NewItems != null)
{
stream.WriteInt32(packetInfo.NewItems.Count);
if (stream.BitPosition > maxBitPosition)
{
needsSplit = true;
}
else
{
sentData.NewItems = new SortedDictionary<int, MyPhysicalInventoryItem>();
foreach (var item in packetInfo.NewItems)
{
MyPhysicalInventoryItem inventoryItem = item.Value;
VRage.Serialization.MySerializer.Write(stream, ref inventoryItem, MyObjectBuilderSerializer.Dynamic);
if (stream.BitPosition <= maxBitPosition)
{
sentData.NewItems[item.Key] = inventoryItem;
sentData.HasChanges = true;
}
else
{
needsSplit = true;
}
}
}
}
stream.WriteBool(packetInfo.SwappedItems != null);
if (packetInfo.SwappedItems != null)
//.........这里部分代码省略.........
示例4: WriteInventory
private InventoryDeltaInformation WriteInventory(ref InventoryDeltaInformation packetInfo, BitStream stream, byte packetId, int maxBitPosition, out bool needsSplit)
{
InventoryDeltaInformation sendPacketInfo = PrepareSendData(ref packetInfo, stream, maxBitPosition, out needsSplit);
if (sendPacketInfo.HasChanges == false)
{
stream.WriteBool(false);
return sendPacketInfo;
}
sendPacketInfo.MessageId = packetInfo.MessageId;
stream.WriteBool(true);
stream.WriteUInt32(sendPacketInfo.MessageId);
stream.WriteBool(sendPacketInfo.ChangedItems != null);
if (sendPacketInfo.ChangedItems != null)
{
stream.WriteInt32(sendPacketInfo.ChangedItems.Count);
foreach (var item in sendPacketInfo.ChangedItems)
{
stream.WriteUInt32(item.Key);
stream.WriteInt64(item.Value.RawValue);
}
}
stream.WriteBool(sendPacketInfo.RemovedItems != null);
if (sendPacketInfo.RemovedItems != null)
{
stream.WriteInt32(sendPacketInfo.RemovedItems.Count);
foreach (var item in sendPacketInfo.RemovedItems)
{
stream.WriteUInt32(item);
}
}
stream.WriteBool(sendPacketInfo.NewItems != null);
if (sendPacketInfo.NewItems != null)
{
stream.WriteInt32(sendPacketInfo.NewItems.Count);
foreach (var item in sendPacketInfo.NewItems)
{
stream.WriteInt32(item.Key);
MyPhysicalInventoryItem itemTosend = item.Value;
VRage.Serialization.MySerializer.Write(stream, ref itemTosend, MyObjectBuilderSerializer.Dynamic);
}
}
stream.WriteBool(sendPacketInfo.SwappedItems != null);
if (sendPacketInfo.SwappedItems != null)
{
stream.WriteInt32(sendPacketInfo.SwappedItems.Count);
foreach (var item in sendPacketInfo.SwappedItems)
{
stream.WriteInt32(item.Key);
stream.WriteInt32(item.Value);
}
}
return sendPacketInfo;
}
示例5: Write
//.........这里部分代码省略.........
float largest_value = abs_x;
if (abs_y > largest_value)
{
largest = 1;
largest_value = abs_y;
}
if (abs_z > largest_value)
{
largest = 2;
largest_value = abs_z;
}
if (abs_w > largest_value)
{
largest = 3;
largest_value = abs_w;
}
float a = 0;
float b = 0;
float c = 0;
switch (largest)
{
case 0:
if (x >= 0)
{
a = y;
b = z;
c = w;
}
else
{
a = -y;
b = -z;
c = -w;
}
break;
case 1:
if (y >= 0)
{
a = x;
b = z;
c = w;
}
else
{
a = -x;
b = -z;
c = -w;
}
break;
case 2:
if (z >= 0)
{
a = x;
b = y;
c = w;
}
else
{
a = -x;
b = -y;
c = -w;
}
break;
case 3:
if (w >= 0)
{
a = x;
b = y;
c = z;
}
else
{
a = -x;
b = -y;
c = -z;
}
break;
default:
Debug.Fail("Error");
break;
}
float normal_a = (a - minimum) / (maximum - minimum);
float normal_b = (b - minimum) / (maximum - minimum);
float normal_c = (c - minimum) / (maximum - minimum);
stream.WriteUInt32(largest, 2);
stream.WriteUInt32((uint)Math.Floor(normal_a * scale + 0.5f), bits);
stream.WriteUInt32((uint)Math.Floor(normal_b * scale + 0.5f), bits);
stream.WriteUInt32((uint)Math.Floor(normal_c * scale + 0.5f), bits);
}