Exemple #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.WriteULong(converter.longValue1);
            writer.WriteULong(converter.longValue2);
        }
        bool WriteParameters(NetworkWriter writer, bool forceAll = false)
        {
            ulong dirtyBits = forceAll ? (~0ul) : NextDirtyBits();

            writer.WriteULong(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.WriteInt(newIntValue);
                }
                else if (par.type == AnimatorControllerParameterType.Float)
                {
                    float newFloatValue = animator.GetFloat(par.nameHash);
                    writer.WriteFloat(newFloatValue);
                }
                else if (par.type == AnimatorControllerParameterType.Bool)
                {
                    bool newBoolValue = animator.GetBool(par.nameHash);
                    writer.WriteBool(newBoolValue);
                }
            }
            return(dirtyBits != 0);
        }
Exemple #3
0
 public static void WriteULongNullable(this NetworkWriter writer, ulong?value)
 {
     writer.WriteBool(value.HasValue);
     if (value.HasValue)
     {
         writer.WriteULong(value.Value);
     }
 }
Exemple #4
0
        public static void WriteDouble(this NetworkWriter writer, double value)
        {
            UIntDouble converter = new UIntDouble
            {
                doubleValue = value
            };

            writer.WriteULong(converter.longValue);
        }
        public bool SerializeObjectsDelta(NetworkWriter writer)
        {
            bool dirty = false;

            // write the mask
            writer.WriteULong(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);
        }
Exemple #6
0
        public bool SerializeObjectsDelta(NetworkWriter writer)
        {
            bool dirty = false;

            // write the mask
            writer.WriteULong(syncObjectDirtyBits);
            // serializable objects, such as synclists
            for (int i = 0; i < syncObjects.Count; i++)
            {
                // check dirty mask at nth bit
                SyncObject syncObject = syncObjects[i];
                if ((syncObjectDirtyBits & (1UL << i)) != 0)
                {
                    syncObject.OnSerializeDelta(writer);
                    dirty = true;
                }
            }
            return(dirty);
        }
Exemple #7
0
 public static void WriteLong(this NetworkWriter writer, long value) => writer.WriteULong((ulong)value);
Exemple #8
0
 public static void WriteUInt64(this NetworkWriter writer, ulong value) => writer.WriteULong(value);