void ReadParameters(NetworkReader reader)
        {
            ulong dirtyBits = reader.ReadPackedUInt64();

            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 = reader.ReadPackedInt32();
                    Animator.SetInteger(par.nameHash, newIntValue);
                }
                else if (par.type == AnimatorControllerParameterType.Float)
                {
                    float newFloatValue = reader.ReadSingle();
                    Animator.SetFloat(par.nameHash, newFloatValue);
                }
                else if (par.type == AnimatorControllerParameterType.Bool)
                {
                    bool newBoolValue = reader.ReadBoolean();
                    Animator.SetBool(par.nameHash, newBoolValue);
                }
            }
        }
Example #2
0
        public static T[] ReadArray <T>(this NetworkReader reader)
        {
            int length = reader.ReadPackedInt32();

            if (length < 0)
            {
                return(null);
            }
            T[] result = new T[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = reader.Read <T>();
            }
            return(result);
        }
Example #3
0
        public static List <T> ReadList <T>(this NetworkReader reader)
        {
            int length = reader.ReadPackedInt32();

            if (length < 0)
            {
                return(null);
            }
            var result = new List <T>(length);

            for (int i = 0; i < length; i++)
            {
                result.Add(reader.Read <T>());
            }
            return(result);
        }
        void ReadParameters(NetworkReader reader)
        {
            ulong dirtyBits = reader.ReadPackedUInt64();

            for (int i = 0; i < namesParameters.Length; i++)
            {
                if ((dirtyBits & (1ul << i)) == 0)
                {
                    continue;
                }

                if (i < lastFloatParameters.Length)
                {
                    float newFloatValue = reader.ReadSingle();
                    m_Motion.motionGraph.SetFloat(Animator.StringToHash(namesParameters[i]), newFloatValue);
                }
                else if (i >= lastFloatParameters.Length &&
                         i < (lastFloatParameters.Length + lastIntParameters.Length))
                {
                    int newIntValue = reader.ReadPackedInt32();
                    m_Motion.motionGraph.SetInt(Animator.StringToHash(namesParameters[i]), newIntValue);
                }
                else if (i >= (lastFloatParameters.Length + lastIntParameters.Length) &&
                         i < (lastFloatParameters.Length + lastIntParameters.Length + lastSwitchParameters.Length))
                {
                    bool newBoolValue = reader.ReadBoolean();
                    m_Motion.motionGraph.SetSwitch(Animator.StringToHash(namesParameters[i]), newBoolValue);
                }
                else if (i >= (lastFloatParameters.Length + lastIntParameters.Length + lastSwitchParameters.Length) &&
                         i < (lastFloatParameters.Length + lastIntParameters.Length + lastSwitchParameters.Length + lastVectorParameters.Length))
                {
                    Vector3 newVectorValue = reader.ReadVector3();
                    m_Motion.motionGraph.SetVector(Animator.StringToHash(namesParameters[i]), newVectorValue);
                }
                else if (i >= (lastFloatParameters.Length + lastIntParameters.Length + lastSwitchParameters.Length + lastVectorParameters.Length) &&
                         i < (lastFloatParameters.Length + lastIntParameters.Length + lastSwitchParameters.Length + lastVectorParameters.Length + lastTransformParameters.Length))
                {
                    Transform newTransformValue = reader.ReadTransform();
                    m_Motion.motionGraph.SetTransform(Animator.StringToHash(namesParameters[i]), newTransformValue);
                }
            }
        }
Example #5
0
        public static T[] ReadArray <T>(this NetworkReader reader)
        {
            int length = reader.ReadPackedInt32();

            if (length < 0)
            {
                return(null);
            }
            if (length > reader.Length - reader.Position)
            {
                throw new EndOfStreamException("Can't read " + length + " elements because it would read past the end of the stream. ");
            }
            var result = new T[length];

            for (int i = 0; i < length; i++)
            {
                result[i] = reader.Read <T>();
            }
            return(result);
        }
Example #6
0
        void ReadParameters(NetworkReader reader)
        {
            // need to read values from NetworkReader even if animator is disabled

            ulong dirtyBits = reader.ReadPackedUInt64();

            for (int i = 0; i < parameters.Length; i++)
            {
                if ((dirtyBits & (1ul << i)) == 0)
                {
                    continue;
                }

                AnimatorControllerParameter par = parameters[i];
                switch (par.type)
                {
                case AnimatorControllerParameterType.Int:
                {
                    int newIntValue = reader.ReadPackedInt32();
                    SetInteger(par, newIntValue);
                    break;
                }

                case AnimatorControllerParameterType.Float:
                {
                    float newFloatValue = reader.ReadSingle();
                    SetFloat(par, newFloatValue);
                    break;
                }

                case AnimatorControllerParameterType.Bool:
                {
                    bool newBoolValue = reader.ReadBoolean();
                    SetBool(par, newBoolValue);
                    break;
                }
                }
            }
        }
Example #7
0
        void ReadParameters(NetworkReader reader)
        {
            ulong dirtyBits = reader.ReadPackedUInt64();

            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 = reader.ReadPackedInt32();
                    animator.SetInteger(par.nameHash, newIntValue);
                }
                else if (par.type == AnimatorControllerParameterType.Float)
                {
                    float newFloatValue = reader.ReadSingle();
                    // If interpolating, set the target. Otherwise, set the value immediately.
                    if (interpolateFloatParameters)
                    {
                        floatParametersTargets[i] = newFloatValue;
                    }
                    else
                    {
                        animator.SetFloat(par.nameHash, newFloatValue);
                    }
                }
                else if (par.type == AnimatorControllerParameterType.Bool)
                {
                    bool newBoolValue = reader.ReadBoolean();
                    animator.SetBool(par.nameHash, newBoolValue);
                }
            }
        }
Example #8
0
 protected override int DeserializeItem(NetworkReader reader) => reader.ReadPackedInt32();
Example #9
0
 public override void Deserialize(NetworkReader reader)
 {
     value = reader.ReadPackedInt32();
 }
Example #10
0
 public static Vector3Int ReadVector3Int(this NetworkReader reader) => new Vector3Int(reader.ReadPackedInt32(), reader.ReadPackedInt32(), reader.ReadPackedInt32());
Example #11
0
 protected override int DeserializeItem(NetworkReader reader)
 {
     return(reader.ReadPackedInt32());
 }
Example #12
0
 public static Vector2Int ReadVector2Int(this NetworkReader reader)
 {
     return(new Vector2Int(reader.ReadPackedInt32(), reader.ReadPackedInt32()));
 }