Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public static void WriteDouble(this NetworkWriter writer, double value)
        {
            UIntDouble converter = new UIntDouble
            {
                doubleValue = value
            };

            writer.WriteUInt64(converter.longValue);
        }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 public static void WriteInt64(this NetworkWriter writer, long value) => writer.WriteUInt64((ulong)value);