// Token: 0x0600598A RID: 22922 RVA: 0x001F1DEC File Offset: 0x001F01EC private void DoAdjustment(SyncPhysics.PositionEvent evt) { if (evt == null || base.isMine) { return; } this.replicateFlags = evt.flags; if (this.hasRigidbody) { this.rigidbody.isKinematic = evt.isKinematic; this.rigidbody.useGravity = evt.useGravity; } this.HeldInHand = (VRC_Pickup.PickupHand)((evt.flags & 192) >> 6); if (evt.Discontinuity) { this.SetVelocity(Vector3.zero); } else if (!this.hasAnimatedParts || (this.GetVelocity() - evt.Velocity).sqrMagnitude > 1E-05f) { this.SetVelocity(evt.Velocity); } this.SetRotation(evt.Rotation); this.SetPosition(evt.Position); this.DiscontinuityHint = evt.Discontinuity; if (this.hasRigidbody && !this.rigidbody.IsSleeping() && this.ShouldSleep()) { this.rigidbody.Sleep(); } }
// Token: 0x06005991 RID: 22929 RVA: 0x001F20B0 File Offset: 0x001F04B0 private SyncPhysics.PositionEvent DeserializePositionEvent(PhotonStream stream, PhotonMessageInfo info) { SyncPhysics.PositionEvent positionEvent = this.LastReplicatedPosition; if (positionEvent == null) { positionEvent = this.MakeCurrentPositionEvent((double)Time.time); } short flags = (short)stream.ReceiveNext(); SyncPhysics.PositionEvent positionEvent2 = new SyncPhysics.PositionEvent { flags = flags, Time = (double)Time.time, Position = positionEvent.Position, Velocity = positionEvent.Velocity, Rotation = positionEvent.Rotation }; if (positionEvent2.isSleeping) { return(positionEvent2); } positionEvent2.Rotation = this.DeserializeQuaternion(stream); if (positionEvent2.ReplicatePosition) { positionEvent2.Position = this.DeserializeVector(stream); } if (positionEvent2.ReplicateVelocity) { positionEvent2.Velocity = this.DeserializeVector(stream); } return(positionEvent2); }
// Token: 0x0600598B RID: 22923 RVA: 0x001F1F1C File Offset: 0x001F031C public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { SyncPhysics.PositionEvent positionEvent = this.MakeCurrentPositionEvent((double)Time.time); positionEvent.OwnerID = info.photonView.ownerId; bool flag = false; this.RecentOwnershipChange = flag; this.RecentCollision = flag; this.SerializePositionEvent(positionEvent, stream, info); this.DiscontinuityHint = false; TweenFunctions.RecordValue <SyncPhysics.PositionEvent>(this.positionHistory, positionEvent); } else { SyncPhysics.PositionEvent positionEvent = this.DeserializePositionEvent(stream, info); positionEvent.OwnerID = info.sender.ID; if (this.positionHistory.Full && this.positionHistory[0].Time > (double)Time.time - 2.0 * VRC.Network.SimulationDelay(base.Owner)) { this.positionHistory.Capacity *= 2; } if (positionEvent.Discontinuity) { this.positionHistory.Clear(); } TweenFunctions.RecordValue <SyncPhysics.PositionEvent>(this.positionHistory, positionEvent); this.LastUnsettledTime = Time.time; } }
// 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); } }
// Token: 0x06005990 RID: 22928 RVA: 0x001F2048 File Offset: 0x001F0448 private void SerializePositionEvent(SyncPhysics.PositionEvent evt, PhotonStream stream, PhotonMessageInfo info) { stream.SendNext(evt.flags); if (evt.isSleeping) { return; } this.SerializeQuaternion(stream, evt.Rotation); if (evt.ReplicatePosition) { this.SerializeVector(stream, evt.Position); } if (evt.ReplicateVelocity) { this.SerializeVector(stream, evt.Velocity); } }
// Token: 0x06005986 RID: 22918 RVA: 0x001F18B0 File Offset: 0x001EFCB0 public bool ShouldSleep() { if (this.isPlayer) { return(false); } if ((double)Time.time < base.OwnershipTransferTime + (double)this.UserJoinedUnsettlingTime) { return(false); } if (this.isHeld || this.WasDiscontinuousRecently) { return(false); } if (!this.hasRigidbody || this.rigidbody.IsSleeping()) { return(true); } Vector3 target = this.GetVelocity(); if (!target.AlmostEquals(Vector3.zero, 1E-05f)) { return(false); } SyncPhysics.PositionEvent penultimatePosition = this.PenultimatePosition; if (penultimatePosition == null || penultimatePosition.Discontinuity) { return(false); } Vector3 target2 = this.GetPosition(); if (!target2.AlmostEquals(penultimatePosition.Position, 1E-05f)) { return(false); } Quaternion target3 = this.GetRotation(); return(target3.AlmostEquals(penultimatePosition.Rotation, 0.1f)); }
// Token: 0x06005988 RID: 22920 RVA: 0x001F19B4 File Offset: 0x001EFDB4 private void UpdateFlags() { if (!base.isMine) { return; } SyncPhysics.PositionEvent lastReplicatedPosition = this.LastReplicatedPosition; this.replicateFlags &= -513; if (lastReplicatedPosition != null && lastReplicatedPosition.OwnerID != base.photonView.ownerId) { this.replicateFlags |= 512; } if (!this.hasRigidbody || this.rigidbody.isKinematic) { this.replicateFlags |= 4; } else if ((this.replicateFlags & 4) != 0) { this.replicateFlags &= -5; this.LastUnsettledTime = Time.time; } if (this.hasRigidbody && this.rigidbody.useGravity) { this.replicateFlags |= 16; } else if ((this.replicateFlags & 16) != 0) { this.replicateFlags &= -17; this.LastUnsettledTime = Time.time; } if (this.isHeld) { this.replicateFlags &= -193; this.replicateFlags |= (short)((int)this.HeldInHand << 6); } else if ((this.replicateFlags & 192) != 0) { this.replicateFlags &= -193; this.LastUnsettledTime = Time.time; } if (this.DiscontinuityHint) { this.replicateFlags |= 32; } else if ((this.replicateFlags & 32) != 0) { this.replicateFlags &= -33; this.LastUnsettledTime = Time.time; } if (base.GetComponentInParent <VRCPlayer>() != null) { this.replicateFlags &= -9; } else { bool flag = this.ShouldSleep(); if (flag && (double)(Time.time - this.LastUnsettledTime) > VRC.Network.SimulationDelay(base.Owner)) { this.replicateFlags |= 8; } else { this.replicateFlags &= -9; } } }
// 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)); } } }
// Token: 0x06005960 RID: 22880 RVA: 0x001F0C0C File Offset: 0x001EF00C public static bool PositionEventIsBad(SyncPhysics.PositionEvent evt) { return(evt.Position.IsBad() || evt.Velocity.IsBad() || evt.Rotation.IsBad() || ((float)evt.Time).IsBad()); }