您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
33 行
807 B
33 行
807 B
using System.Runtime.InteropServices;
|
|
|
|
namespace Unity.Netcode
|
|
{
|
|
[StructLayout(LayoutKind.Explicit)]
|
|
internal struct ByteBool
|
|
{
|
|
[FieldOffset(0)]
|
|
public bool BoolValue;
|
|
|
|
[FieldOffset(0)]
|
|
public byte ByteValue;
|
|
|
|
public byte Collapse() =>
|
|
ByteValue = (byte)((
|
|
// Collapse all bits to position 1 and reassign as bit
|
|
(ByteValue >> 7) |
|
|
(ByteValue >> 6) |
|
|
(ByteValue >> 5) |
|
|
(ByteValue >> 4) |
|
|
(ByteValue >> 3) |
|
|
(ByteValue >> 2) |
|
|
(ByteValue >> 1) |
|
|
ByteValue
|
|
) & 1);
|
|
|
|
public byte Collapse(bool b)
|
|
{
|
|
BoolValue = b;
|
|
return Collapse();
|
|
}
|
|
}
|
|
}
|