public void ApplyCubeStateUpdates(int numStateUpdates, ref int[] cubeIds, ref CubeState[] cubeState, int fromClientIndex, int toClientIndex, bool applySmoothing = true)
    {
        Vector3 origin = this.gameObject.transform.position;

        for (int i = 0; i < numStateUpdates; ++i)
        {
            if (AuthoritySystem.ShouldApplyCubeUpdate(this, cubeIds[i], cubeState[i].ownershipSequence, cubeState[i].authoritySequence, cubeState[i].authorityIndex, false, fromClientIndex, toClientIndex))
            {
                GameObject cube = cubes[cubeIds[i]];

                var networkInfo = cube.GetComponent <NetworkInfo>();
                var rigidBody   = cube.GetComponent <Rigidbody>();

                UpdatePendingCommit(networkInfo, cubeState[i].authorityIndex, fromClientIndex, toClientIndex);

                Snapshot.ApplyCubeState(rigidBody, networkInfo, ref cubeState[i], ref origin, applySmoothing);
            }
        }
    }
    public void ApplyAvatarStateUpdates(int numAvatarStates, ref AvatarState[] avatarState, int fromClientIndex, int toClientIndex)
    {
        for (int i = 0; i < numAvatarStates; ++i)
        {
            if (toClientIndex == 0 && avatarState[i].client_index != fromClientIndex)
            {
                continue;
            }

            var remoteAvatar = GetRemoteAvatar(avatarState[i].client_index);

            if (avatarState[i].left_hand_holding_cube && AuthoritySystem.ShouldApplyCubeUpdate(this, avatarState[i].left_hand_cube_id, avatarState[i].left_hand_ownership_sequence, avatarState[i].left_hand_authority_sequence, avatarState[i].client_index + 1, true, fromClientIndex, toClientIndex))
            {
                GameObject cube = cubes[avatarState[i].left_hand_cube_id];

                var networkInfo = cube.GetComponent <NetworkInfo>();

                UpdatePendingCommit(networkInfo, avatarState[i].client_index + 1, fromClientIndex, toClientIndex);

                remoteAvatar.ApplyLeftHandUpdate(ref avatarState[i]);
            }

            if (avatarState[i].right_hand_holding_cube && AuthoritySystem.ShouldApplyCubeUpdate(this, avatarState[i].right_hand_cube_id, avatarState[i].right_hand_ownership_sequence, avatarState[i].right_hand_authority_sequence, avatarState[i].client_index + 1, true, fromClientIndex, toClientIndex))
            {
                GameObject cube = cubes[avatarState[i].right_hand_cube_id];

                var networkInfo = cube.GetComponent <NetworkInfo>();

                UpdatePendingCommit(networkInfo, avatarState[i].client_index + 1, fromClientIndex, toClientIndex);

                remoteAvatar.ApplyRightHandUpdate(ref avatarState[i]);
            }

            remoteAvatar.ApplyAvatarPose(ref avatarState[i]);
        }
    }