Esempio n. 1
0
    // Token: 0x0600594E RID: 22862 RVA: 0x001F027C File Offset: 0x001EE67C
    private bool IsMovingTowards(VRCPlayer playerObject)
    {
        SyncPhysics component        = playerObject.GetComponent <SyncPhysics>();
        Vector3     observedVelocity = component.ObservedVelocity;
        Vector3     rhs = base.transform.position - playerObject.transform.position;

        return(Vector3.Dot(observedVelocity, rhs) > 0f);
    }
Esempio n. 2
0
    // Token: 0x0600592A RID: 22826 RVA: 0x001EEC58 File Offset: 0x001ED058
    private void DoMomentumTransfer(Collision collision)
    {
        if (this.physicsSync == null || collision == null || collision.collider == null || collision.contacts == null || collision.contacts.Length == 0)
        {
            return;
        }
        SyncPhysics component = collision.collider.GetComponent <SyncPhysics>();

        if (component != null && (!(this.isHeld ^ component.isHeld) || (!base.isMine && !component.isMine)))
        {
            return;
        }
        Rigidbody component2 = base.GetComponent <Rigidbody>();
        Rigidbody component3 = collision.collider.GetComponent <Rigidbody>();

        if (component2 == null || component3 == null)
        {
            return;
        }
        float   num = (!(component2 != null)) ? 1f : component2.mass;
        Vector3 observedVelocity = this.physicsSync.ObservedVelocity;
        float   num2             = (!(component3 != null)) ? 1f : component2.mass;
        Vector3 vector           = (!(component != null)) ? component3.velocity : component.ObservedVelocity;

        if (this.isHeld)
        {
            Vector3 inNormal = (!observedVelocity.AlmostEquals(Vector3.zero, 0.001f)) ? observedVelocity.normalized : (vector * -1f).normalized;
            Vector3 a        = Vector3.Reflect(vector, inNormal) + observedVelocity;
            component3.velocity        = Vector3.zero;
            component3.angularVelocity = Vector3.zero;
            component3.AddForceAtPosition(a * (num + num2), collision.contacts[0].point, ForceMode.Force);
        }
        if (component != null && component.isHeld)
        {
            Vector3 inNormal2 = (!vector.AlmostEquals(Vector3.zero, 0.001f)) ? vector.normalized : (observedVelocity * -1f).normalized;
            component2.velocity        = Vector3.zero;
            component2.angularVelocity = Vector3.zero;
            Vector3 a2 = Vector3.Reflect(observedVelocity, inNormal2) + vector;
            component2.AddForceAtPosition(a2 * (num + num2), collision.contacts[0].point, ForceMode.Force);
        }
    }
Esempio n. 3
0
    // Token: 0x06004F00 RID: 20224 RVA: 0x001A8CC8 File Offset: 0x001A70C8
    private void Update()
    {
        PoseRecorder componentInParent = base.GetComponentInParent <PoseRecorder>();

        if (componentInParent != null && componentInParent.enabled && !this._culled)
        {
            componentInParent.DoAdjustment(Time.time);
        }
        SyncPhysics componentInParent2 = base.GetComponentInParent <SyncPhysics>();

        if (componentInParent2 != null && componentInParent2.enabled)
        {
            componentInParent2.DoPositionSync((double)Time.time, (double)Time.deltaTime);
        }
        if (!this._inited)
        {
            return;
        }
        if (this._useVrcTrackedIk)
        {
            this.vrcTrackedIk.isCulled = this._culled;
        }
        if (this._culled)
        {
            return;
        }
        if (!this._reportedUSpeakMoveError && !this._completedUSpeakMove && this._uspeakT != null && Networking.IsObjectReady(this._uspeakT.gameObject))
        {
            USpeakPhotonSender3D component = this._uspeakT.GetComponent <USpeakPhotonSender3D>();
            if (this._cammountT != null && component != null && component.IsInitialized)
            {
                if (this._useLimbIK || this._useVrcTrackedIk)
                {
                    if (this._uspeakT.parent != this.HeadEffector.transform)
                    {
                        this._uspeakT.parent = this.HeadEffector.transform;
                        this._emojiT.parent  = this.HeadEffector.transform;
                        Debug.Log("IK[" + this._player.name + "]: USpeak moved to head effector.");
                    }
                }
                else if (this._uspeakT.parent != this._cammountT)
                {
                    this._uspeakT.parent = this._cammountT;
                    this._emojiT.parent  = this._cammountT;
                    Debug.Log("IK[" + this._player.name + "]: USpeak moved to camera mount.");
                }
                this._uspeakT.localPosition = this._uspeakLocalPos;
                this._uspeakT.localRotation = this._uspeakLocalRot;
                this._emojiT.localPosition  = this._emojiLocalPos;
                this._emojiT.localRotation  = this._emojiLocalRot;
                this._completedUSpeakMove   = true;
            }
            if (VRC.Network.IsNetworkSettled)
            {
                this._elapsedUSpeakTimeToMove += Time.deltaTime;
                if (this._elapsedUSpeakTimeToMove > 10f)
                {
                    Debug.LogError("IK[" + this._player.name + "]: USpeak move took too long. aborting.");
                    this._reportedUSpeakMoveError = true;
                }
            }
        }
        if (this._modelAnimator != null && this._modelAnimator.isHuman)
        {
            float num  = 2f;
            float num2 = 1.5f;
            float num3 = 2f;
            float num4 = 2f;
            float num5 = 2f;
            float num6 = 10f;
            float num7 = 5f;
            bool  flag = false;
            if (this.isLocalPlayer)
            {
                float num8 = VRCTrackingManager.GetPlayerUprightAmount();
                if (this._locoLayer >= 0)
                {
                    if (this._useLimbIK)
                    {
                        num8 = 1f;
                    }
                    if (this.motion.IsImmobilized)
                    {
                        this.SetFloatParameter(this._modelAnimator, "HeightScale", 1f);
                    }
                    else
                    {
                        this.SetFloatParameter(this._modelAnimator, "HeightScale", num8);
                    }
                }
                this.motion.StandingHeight = num8;
                this.UpdateTracking();
                if (this.motion.isLocomoting)
                {
                    if (!this._wasLoco)
                    {
                        this._wasLoco = true;
                        flag          = true;
                    }
                    if (this._player.GetVRMode() && this._useVrcTrackedIk && !this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.headPosWeight = 1f;
                        this.headRotWeight = 1f;
                    }
                    else
                    {
                        this.headRotWeight = 0f;
                        this.headPosWeight = 0f;
                    }
                    this.lowerBodyWeight = 0f;
                    this._locoWeight     = 1f;
                }
                else
                {
                    if (this._wasLoco)
                    {
                        this._wasLoco = false;
                        flag          = true;
                    }
                    this.lowerBodyWeight = 1f;
                    this._locoWeight     = 0f;
                }
                if (this._locoLayer >= 0)
                {
                    float num9 = this.GetLayerWeight(this._modelAnimator, this._locoLayer);
                    if (this.motion.IsImmobilized)
                    {
                        num9 = this._locoWeight;
                    }
                    else
                    {
                        num9 = Mathf.MoveTowards(num9, this._locoWeight, Time.deltaTime * num2);
                    }
                    this.SetLayerWeight(this._modelAnimator, this._locoLayer, num9);
                }
                if (this._useLimbIK)
                {
                    this.limbik.LeftPosWeight  = Mathf.MoveTowards(this.limbik.LeftPosWeight, this.leftWeight, Time.deltaTime * num);
                    this.limbik.RightPosWeight = Mathf.MoveTowards(this.limbik.RightPosWeight, this.rightWeight, Time.deltaTime * num);
                    this.limbik.HeadPosWeight  = Mathf.MoveTowards(this.limbik.HeadPosWeight, this.headPosWeight, Time.deltaTime * num3);
                    this.limbik.LeftRotWeight  = this.limbik.LeftPosWeight;
                    this.limbik.RightRotWeight = this.limbik.RightPosWeight;
                    this.limbik.HeadRotWeight  = this.limbik.HeadPosWeight;
                }
                if (this._useVrcTrackedIk)
                {
                    if (flag)
                    {
                        this.vrcTrackedIk.LocomotionChange(this._wasLoco);
                    }
                    if (this.motion.IsImmobilized)
                    {
                        this.vrcTrackedIk.LeftHandWeight  = this.leftWeight;
                        this.vrcTrackedIk.RightHandWeight = this.rightWeight;
                        this.vrcTrackedIk.HeadPosWeight   = this.headPosWeight;
                        this.vrcTrackedIk.HeadRotWeight   = this.headRotWeight;
                        this.vrcTrackedIk.LowerBodyWeight = this.lowerBodyWeight;
                    }
                    else
                    {
                        this.vrcTrackedIk.LeftHandWeight  = Mathf.MoveTowards(this.vrcTrackedIk.LeftHandWeight, this.leftWeight, Time.deltaTime * num);
                        this.vrcTrackedIk.RightHandWeight = Mathf.MoveTowards(this.vrcTrackedIk.RightHandWeight, this.rightWeight, Time.deltaTime * num);
                        this.vrcTrackedIk.HeadRotWeight   = Mathf.MoveTowards(this.vrcTrackedIk.HeadRotWeight, this.headRotWeight, Time.deltaTime * num3);
                        if (this.vrcTrackedIk.hasLowerBodyTracking)
                        {
                            this.vrcTrackedIk.LowerBodyWeight = this.lowerBodyWeight;
                            this.vrcTrackedIk.HeadPosWeight   = this.headPosWeight;
                        }
                        else
                        {
                            if (this.headPosWeight == 1f)
                            {
                                this.vrcTrackedIk.HeadPosWeight = this.headPosWeight;
                            }
                            else
                            {
                                this.vrcTrackedIk.HeadPosWeight = Mathf.MoveTowards(this.vrcTrackedIk.HeadPosWeight, this.headPosWeight, Time.deltaTime * num3);
                            }
                            this.vrcTrackedIk.LowerBodyWeight = Mathf.MoveTowards(this.vrcTrackedIk.LowerBodyWeight, this.lowerBodyWeight, Time.deltaTime * num4);
                        }
                    }
                }
                if (this._useVrcTrackedIk)
                {
                    if (this.motion.IsImmobilized)
                    {
                        this.vrcTrackedIk.SolverWeight = this.solverWeight;
                    }
                    else if (this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num7);
                    }
                    else
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num5);
                    }
                }
            }
            else
            {
                float standingHeight = this.motion.StandingHeight;
                if (this._locoLayer >= 0)
                {
                    this.SetFloatParameter(this._modelAnimator, "HeightScale", standingHeight);
                }
                if (this.motion.isLocomoting)
                {
                    if (!this._wasLoco)
                    {
                        this._wasLoco    = true;
                        flag             = true;
                        this._locoWeight = 1f;
                    }
                    if (!this._player.GetVRMode() || !this._useVrcTrackedIk || this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.headPosWeight = 0f;
                    }
                    this.lowerBodyWeight = 0f;
                }
                else if (this._wasLoco)
                {
                    this._wasLoco    = false;
                    flag             = true;
                    this._locoWeight = 0f;
                }
                Vector3 position  = this._modelAnimator.GetBoneTransform(HumanBodyBones.Head).position;
                Vector3 position2 = this.LeftEffector.transform.position;
                Vector3 position3 = this.RightEffector.transform.position;
                if (this._locoLayer >= 0)
                {
                    float num10 = this.GetLayerWeight(this._modelAnimator, this._locoLayer);
                    num10 = Mathf.MoveTowards(num10, this._locoWeight, Time.deltaTime * num2);
                    this.SetLayerWeight(this._modelAnimator, this._locoLayer, num10);
                }
                if (this._useLimbIK)
                {
                    this.limbik.LeftPosWeight  = Mathf.Min(this.leftWeight, 1f);
                    this.limbik.LeftRotWeight  = Mathf.Min(this.leftWeight, 1f);
                    this.limbik.RightPosWeight = Mathf.Min(this.rightWeight, 1f);
                    this.limbik.RightRotWeight = Mathf.Min(this.rightWeight, 1f);
                    this.limbik.HeadPosWeight  = Mathf.Min(this.headPosWeight, 1f);
                    this.limbik.HeadRotWeight  = Mathf.Min(this.headRotWeight, 1f);
                }
                if (this._useVrcTrackedIk)
                {
                    if (flag)
                    {
                        this.vrcTrackedIk.LocomotionChange(this._wasLoco);
                    }
                    this.vrcTrackedIk.LeftHandWeight  = Mathf.MoveTowards(this.vrcTrackedIk.LeftHandWeight, this.leftWeight, Time.deltaTime * num);
                    this.vrcTrackedIk.RightHandWeight = Mathf.MoveTowards(this.vrcTrackedIk.RightHandWeight, this.rightWeight, Time.deltaTime * num);
                    this.vrcTrackedIk.HeadRotWeight   = Mathf.MoveTowards(this.vrcTrackedIk.HeadRotWeight, this.headRotWeight, Time.deltaTime * num3);
                    if (this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.vrcTrackedIk.LowerBodyWeight = this.lowerBodyWeight;
                        this.vrcTrackedIk.HeadPosWeight   = this.headPosWeight;
                    }
                    else
                    {
                        this.vrcTrackedIk.LowerBodyWeight = Mathf.MoveTowards(this.vrcTrackedIk.LowerBodyWeight, this.lowerBodyWeight, Time.deltaTime * num4);
                        this.vrcTrackedIk.HeadPosWeight   = Mathf.MoveTowards(this.vrcTrackedIk.HeadPosWeight, this.headPosWeight, Time.deltaTime * num3);
                    }
                    if (this.motion.IsImmobilized)
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num6);
                    }
                    else if (this.vrcTrackedIk.hasLowerBodyTracking)
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num7);
                    }
                    else
                    {
                        this.vrcTrackedIk.SolverWeight = Mathf.MoveTowards(this.vrcTrackedIk.SolverWeight, this.solverWeight, Time.deltaTime * num5);
                    }
                }
                this.leftWeight      = Mathf.Max(this.leftWeight - Time.deltaTime, 0f);
                this.rightWeight     = Mathf.Max(this.rightWeight - Time.deltaTime, 0f);
                this.headPosWeight   = Mathf.Max(this.headPosWeight - Time.deltaTime, 0f);
                this.headRotWeight   = Mathf.Max(this.headRotWeight - Time.deltaTime, 0f);
                this.lowerBodyWeight = Mathf.Max(this.lowerBodyWeight - Time.deltaTime, 0f);
            }
            if (flag)
            {
                this.motion.Reset();
                if (this._useVrcTrackedIk)
                {
                    this.vrcTrackedIk.Reset(false);
                }
            }
        }
    }