Beispiel #1
0
    // Token: 0x06005989 RID: 22921 RVA: 0x001F1BEC File Offset: 0x001EFFEC
    public void DoPositionSync(double now, double delta)
    {
        if (base.isMine || (double)(Time.time - this.LastUnsettledTime) > VRC.Network.SimulationDelay(base.Owner) * 2.0)
        {
            return;
        }
        VRC.Player componentInParent      = base.gameObject.GetComponentInParent <VRC.Player>();
        List <VRC_StationInternal> source = VRC_StationInternal.FindActiveStations(componentInParent);

        if (this.isPlayer)
        {
            if ((from s in source
                 where s.isImmobilized
                 select s).FirstOrDefault <VRC_StationInternal>() != null)
            {
                return;
            }
        }
        VRC_StationInternal componentInParent2  = base.gameObject.GetComponentInParent <VRC_StationInternal>();
        VRC_StationInternal componentInChildren = base.gameObject.GetComponentInChildren <VRC_StationInternal>();

        if (this.hasCamera || base.gameObject.IsVisible() || (componentInParent2 != null && componentInParent2.Occupant != null && componentInParent2.Occupant.isLocal) || (componentInChildren != null && componentInChildren.Occupant != null && componentInChildren.Occupant.isLocal))
        {
            if (SyncPhysics.f__mg2 == null)
            {
                SyncPhysics.f__mg2 = new TweenFunctions.TweenFunction <SyncPhysics.PositionEvent>(TweenFunctions.CatMullRomTween <SyncPhysics.PositionEvent>);
            }
            this.InterpolateFunction = SyncPhysics.f__mg2;
        }
        else
        {
            if (SyncPhysics.f__mg3 == null)
            {
                SyncPhysics.f__mg3 = new TweenFunctions.TweenFunction <SyncPhysics.PositionEvent>(TweenFunctions.NoTween <SyncPhysics.PositionEvent>);
            }
            this.InterpolateFunction = SyncPhysics.f__mg3;
        }
        double num = now - VRC.Network.SimulationDelay(base.Owner);

        SyncPhysics.PositionEvent positionEvent = TweenFunctions.Tween <SyncPhysics.PositionEvent>(this.positionHistory, this.InterpolateFunction, num, VRC.Network.ExpectedInterval, (!this.isPlayer) ? -1 : base.photonView.viewID);
        if (positionEvent == null && this.positionHistory.Full && this.positionHistory[0].Time > num)
        {
            this.positionHistory.Capacity *= 2;
        }
        if (positionEvent != null)
        {
            this.DoAdjustment(positionEvent);
        }
    }
Beispiel #2
0
    // Token: 0x06005962 RID: 22882 RVA: 0x001F0CC0 File Offset: 0x001EF0C0
    public void OnDrawGizmos()
    {
        if (this.positionHistory.Count < 3)
        {
            return;
        }
        Vector3 zero  = Vector3.zero;
        int     index = this.positionHistory.Count - 1;

        SyncPhysics.PositionEvent positionEvent = this.positionHistory[0];
        for (double num = this.positionHistory[0].Time; num < this.positionHistory[index].Time; num += (double)Time.smoothDeltaTime)
        {
            SyncPhysics.PositionEvent positionEvent2 = TweenFunctions.Tween <SyncPhysics.PositionEvent>(this.positionHistory, this.InterpolateFunction, num, VRC.Network.ExpectedInterval, -1);
            if (positionEvent2 != null)
            {
                Color color = Color.white;
                if (positionEvent2.Discontinuity)
                {
                    color = Color.magenta;
                }
                if (positionEvent != null)
                {
                    Gizmos.color = color;
                    Gizmos.DrawLine(positionEvent.Position, positionEvent2.Position + zero);
                }
                positionEvent = positionEvent2;
            }
        }
        double time              = this.positionHistory[0].Time;
        double time2             = this.positionHistory[index].Time;
        double num2              = double.MinValue;
        int    localInstigatorID = VRC.Network.LocalInstigatorID;

        foreach (SyncPhysics.PositionEvent positionEvent3 in this.positionHistory)
        {
            Color color2 = Color.yellow;
            if (positionEvent3.isCollision)
            {
                color2 = Color.white;
            }
            else if (positionEvent3.RecentOwnershipChange)
            {
                color2 = Color.green;
            }
            else if (positionEvent3.HeldInHand != VRC_Pickup.PickupHand.None)
            {
                color2 = Color.black;
            }
            else if (positionEvent3.isSleeping)
            {
                color2 = Color.blue;
            }
            else if (positionEvent3.Time == num2)
            {
                color2 = Color.magenta;
            }
            num2         = positionEvent3.Time;
            Gizmos.color = color2;
            if (positionEvent3.OwnerID == localInstigatorID)
            {
                Gizmos.DrawWireSphere(positionEvent3.Position, 0.05f);
            }
            else
            {
                Gizmos.DrawWireCube(positionEvent3.Position, new Vector3(0.05f, 0.05f, 0.05f));
            }
        }
    }
Beispiel #3
0
    // Token: 0x06004F57 RID: 20311 RVA: 0x001AD0AC File Offset: 0x001AB4AC
    public void DoAdjustment(float now)
    {
        if (base.isMine || this.animator == null)
        {
            return;
        }
        IList <PoseRecorder.PoseEvent> eventList = this.eventHistory;

        if (PoseRecorder.f__mg0 == null)
        {
            PoseRecorder.f__mg0 = new TweenFunctions.TweenFunction <PoseRecorder.PoseEvent>(PoseRecorder.LinearTweenFunction);
        }
        PoseRecorder.PoseEvent poseEvent = TweenFunctions.Tween <PoseRecorder.PoseEvent>(eventList, PoseRecorder.f__mg0, (double)now - VRC.Network.SimulationDelay(base.Owner), this.ExpectedInterval, -1);
        if (poseEvent == null || poseEvent.Contains(PoseRecorder.PoseContents.Nothing))
        {
            return;
        }
        if (poseEvent.Contains(PoseRecorder.PoseContents.BaseSkeleton))
        {
            this.animator.enabled = false;
            for (int i = 0; i < 19; i++)
            {
                Quaternion localRotation = this.bones[i].localRotation;
                PoseRecorder.MaybeSetRotation(this.bones[i].localRotation, poseEvent.boneRotations[i], ref localRotation);
                this.bones[i].localRotation = localRotation;
            }
        }
        if (this.ik != null)
        {
            if (poseEvent.Contains(PoseRecorder.PoseContents.HandEffectorPositionOrientationL))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetHandEffectorLeft), new PoseRecorder.SetEffector(this.ik.SetRemoteHandEffectorLeft), poseEvent.leftHandPosition, poseEvent.leftHandRotation);
            }
            else
            {
                this.ik.ClearRemoteHandEffectorLeft();
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.HandEffectorPositionOrientationR))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetHandEffectorRight), new PoseRecorder.SetEffector(this.ik.SetRemoteHandEffectorRight), poseEvent.rightHandPosition, poseEvent.rightHandRotation);
            }
            else
            {
                this.ik.ClearRemoteHandEffectorRight();
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.HeadEffectorPositionOrientation))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetHeadEffector), new PoseRecorder.SetEffector(this.ik.SetRemoteHeadEffector), poseEvent.headPosition, poseEvent.headRotation);
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.HipEffectorPositionOrientation))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetHipEffector), new PoseRecorder.SetEffector(this.ik.SetRemoteHipEffector), poseEvent.hipPosition, poseEvent.hipRotation);
            }
            else
            {
                this.ik.ClearRemoteHipEffector();
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.FootEffectorPositionOrientationL))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetFootEffectorLeft), new PoseRecorder.SetEffector(this.ik.SetRemoteFootEffectorLeft), poseEvent.leftFootPosition, poseEvent.leftFootRotation);
            }
            else
            {
                this.ik.ClearRemoteFootEffectorLeft();
            }
            if (poseEvent.Contains(PoseRecorder.PoseContents.FootEffectorPositionOrientationR))
            {
                this.MaybeSetEffector(new PoseRecorder.GetEffector(this.ik.GetFootEffectorRight), new PoseRecorder.SetEffector(this.ik.SetRemoteFootEffectorRight), poseEvent.rightFootPosition, poseEvent.rightFootRotation);
            }
            else
            {
                this.ik.ClearRemoteFootEffectorRight();
            }
        }
        if (poseEvent.Contains(PoseRecorder.PoseContents.HandGesture))
        {
            if (this.handgest != null)
            {
                this.handgest.SetRemoteHandGestures((int)poseEvent.handGestureLeft, (int)poseEvent.handGestureRight);
            }
        }
        else if (this.handgest != null)
        {
            this.handgest.ClearRemoteHandGestures();
        }
        if (this.offset != null && poseEvent.Contains(PoseRecorder.PoseContents.RootOffset))
        {
            this.offset.localPosition = Vector3.zero;
        }
        if (this.animator != null && poseEvent.Contains(PoseRecorder.PoseContents.BaseSkeleton))
        {
            this.animator.enabled = true;
        }
        if (base.Owner.playerNet.WasRecentlyDiscontinuous)
        {
            this.ik.Reset(true);
        }
    }