本文整理汇总了C#中Network.WriteUShort方法的典型用法代码示例。如果您正苦于以下问题:C# Network.WriteUShort方法的具体用法?C# Network.WriteUShort怎么用?C# Network.WriteUShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network.WriteUShort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PackSyncData
internal void PackSyncData(uint indexes, Network.ByteOutStream stream)
{
if (indexes == 0 || !IsActive)
{
return;
}
log.Debug("Sending data for {0}", Actor);
stream.WriteByte(HeaderBytes.Synchronizable);
stream.WriteActor(Actor);
stream.WriteUShort((ushort)DataSize);
stream.WriteUInt(indexes);
for (int i = 0; i < Values.Length; ++i)
{
if ((indexes & ((uint)1 << i)) != 0)
{
Values[i].Pack(stream);
}
}
return;
}
示例2: Pack
public void Pack(Network.ByteOutStream stream)
{
Vector3 p;
Quaternion r;
byte angle = 0;
if (Actor.Context.IsServer)
{
p = position;
r = rotation;
if (yawOnly)
{
angle = (byte)(yaw * 0.71111f);
}
}
else
{
p = Actor.Transform.Position;
r = Actor.Transform.Rotation;
if (yawOnly)
{
angle = (byte)(Vector3.SignedAngle(Vector3.Forward, Actor.Transform.Forward, Vector3.Up) * 0.71111f);
}
}
if (compressPosition)
{
stream.WriteUShort(HalfUtilities.Pack(p.X));
stream.WriteUShort(HalfUtilities.Pack(p.Y));
stream.WriteUShort(HalfUtilities.Pack(p.Z));
}
else
{
stream.WriteVector3(p);
}
if (yawOnly)
{
stream.WriteByte(angle);
}
else
{
p = r.Axis;
stream.WriteUShort(HalfUtilities.Pack(p.X));
stream.WriteUShort(HalfUtilities.Pack(p.Y));
stream.WriteUShort(HalfUtilities.Pack(p.Z));
stream.WriteByte((byte)(r.Angle * SlimMath.Single.Rad2Deg * 0.71111f));
}
}