public static void WriteDecimal(this NetworkWriter writer, decimal value) { // the only way to read it without allocations is to both read and // write it with the FloatConverter (which is not binary compatible // to writer.Write(decimal), hence why we use it here too) UIntDecimal converter = new UIntDecimal { decimalValue = value }; writer.WriteUInt64(converter.longValue1); writer.WriteUInt64(converter.longValue2); }
bool WriteParameters(NetworkWriter writer, bool forceAll = false) { ulong dirtyBits = forceAll ? (~0ul) : NextDirtyBits(); writer.WriteUInt64(dirtyBits); for (int i = 0; i < parameters.Length; i++) { if ((dirtyBits & (1ul << i)) == 0) { continue; } AnimatorControllerParameter par = parameters[i]; if (par.type == AnimatorControllerParameterType.Int) { int newIntValue = animator.GetInteger(par.nameHash); writer.WriteInt32(newIntValue); } else if (par.type == AnimatorControllerParameterType.Float) { float newFloatValue = animator.GetFloat(par.nameHash); writer.WriteSingle(newFloatValue); } else if (par.type == AnimatorControllerParameterType.Bool) { bool newBoolValue = animator.GetBool(par.nameHash); writer.WriteBoolean(newBoolValue); } } return(dirtyBits != 0); }
public static void WriteDouble(this NetworkWriter writer, double value) { UIntDouble converter = new UIntDouble { doubleValue = value }; writer.WriteUInt64(converter.longValue); }
public void Serialize(NetworkWriter writer) { writer.WritePackedUInt32(netId); writer.WriteBoolean(owner); writer.WriteUInt64(sceneId); writer.WriteVector3(position); writer.WriteQuaternion(rotation); writer.WriteVector3(scale); writer.WriteBytesAndSizeSegment(payload); }
public bool SerializeObjectsDelta(NetworkWriter writer) { bool dirty = false; // write the mask writer.WriteUInt64(DirtyObjectBits()); // serializable objects, such as synclists for (int i = 0; i < syncObjects.Count; i++) { SyncObject syncObject = syncObjects[i]; if (syncObject.IsDirty) { syncObject.OnSerializeDelta(writer); dirty = true; } } return dirty; }
public static void WriteInt64(this NetworkWriter writer, long value) => writer.WriteUInt64((ulong)value);