// Token: 0x06001F00 RID: 7936 RVA: 0x0009235C File Offset: 0x0009055C public void PushSnapshot(CharacterNetworkTransform.Snapshot newSnapshot) { if (this.debugSnapshotReceived) { Debug.LogFormat("{0} CharacterNetworkTransform snapshot received.", new object[] { base.gameObject }); } if (this.snapshots.Count > 0 && newSnapshot.serverTime == this.snapshots[this.snapshots.Count - 1].serverTime) { Debug.Log("Received duplicate time!"); } if (this.debugDuplicatePositions && this.snapshots.Count > 0 && newSnapshot.position == this.snapshots[this.snapshots.Count - 1].position) { Debug.Log("Received duplicate position!"); } if (((this.snapshots.Count > 0) ? this.snapshots[this.snapshots.Count - 1].serverTime : float.NegativeInfinity) < newSnapshot.serverTime) { this.snapshots.Add(newSnapshot); this.newestNetSnapshot = newSnapshot; Debug.DrawLine(newSnapshot.position + Vector3.up, newSnapshot.position + Vector3.down, Color.white, 0.25f); } float num = ((GameNetworkManager)NetworkManager.singleton).serverFixedTime - this.interpolationDelay * 3f; while (this.snapshots.Count > 2 && this.snapshots[1].serverTime < num) { this.snapshots.RemoveAt(0); } }
// Token: 0x06001F11 RID: 7953 RVA: 0x000927A0 File Offset: 0x000909A0 public static CharacterNetworkTransform.Snapshot Lerp(CharacterNetworkTransform.Snapshot a, CharacterNetworkTransform.Snapshot b, float t) { return(new CharacterNetworkTransform.Snapshot { position = Vector3.Lerp(a.position, b.position, t), moveVector = Vector3.Lerp(a.moveVector, b.moveVector, t), aimDirection = Vector3.Slerp(a.aimDirection, b.moveVector, t), rotation = Quaternion.Lerp(a.rotation, b.rotation, t), isGrounded = ((t > 0.5f) ? b.isGrounded : a.isGrounded) }); }
// Token: 0x06001F12 RID: 7954 RVA: 0x00092838 File Offset: 0x00090A38 public static CharacterNetworkTransform.Snapshot Interpolate(CharacterNetworkTransform.Snapshot a, CharacterNetworkTransform.Snapshot b, float serverTime) { float num = (serverTime - a.serverTime) / (b.serverTime - a.serverTime); return(new CharacterNetworkTransform.Snapshot { serverTime = serverTime, position = Vector3.LerpUnclamped(a.position, b.position, num), moveVector = Vector3.Lerp(a.moveVector, b.moveVector, num), aimDirection = Vector3.Slerp(a.aimDirection, b.aimDirection, num), rotation = Quaternion.Lerp(a.rotation, b.rotation, num), isGrounded = ((num > 0.5f) ? b.isGrounded : a.isGrounded) }); }
// Token: 0x06001F9F RID: 8095 RVA: 0x00089374 File Offset: 0x00087574 public static CharacterNetworkTransform.Snapshot Lerp(CharacterNetworkTransform.Snapshot a, CharacterNetworkTransform.Snapshot b, float t) { Vector3 vector; bool flag = CharacterNetworkTransform.Snapshot.LerpGroundNormal(ref a, ref b, t, out vector); return(new CharacterNetworkTransform.Snapshot { position = Vector3.Lerp(a.position, b.position, t), moveVector = Vector3.Lerp(a.moveVector, b.moveVector, t), aimDirection = Vector3.Slerp(a.aimDirection, b.moveVector, t), rotation = Quaternion.Lerp(a.rotation, b.rotation, t), isGrounded = flag, groundNormal = vector }); }
// Token: 0x06001FA0 RID: 8096 RVA: 0x0008940C File Offset: 0x0008760C public static CharacterNetworkTransform.Snapshot Interpolate(CharacterNetworkTransform.Snapshot a, CharacterNetworkTransform.Snapshot b, float serverTime) { float t = (serverTime - a.serverTime) / (b.serverTime - a.serverTime); Vector3 vector; bool flag = CharacterNetworkTransform.Snapshot.LerpGroundNormal(ref a, ref b, t, out vector); return(new CharacterNetworkTransform.Snapshot { serverTime = serverTime, position = Vector3.LerpUnclamped(a.position, b.position, t), moveVector = Vector3.Lerp(a.moveVector, b.moveVector, t), aimDirection = Vector3.Slerp(a.aimDirection, b.aimDirection, t), rotation = Quaternion.Lerp(a.rotation, b.rotation, t), isGrounded = flag, groundNormal = vector }); }
// Token: 0x06001F0B RID: 7947 RVA: 0x00092604 File Offset: 0x00090804 private void FixedUpdate() { if (this.hasEffectiveAuthority) { this.newestNetSnapshot = this.BuildSnapshot(); return; } CharacterNetworkTransform.Snapshot snapshot = this.CalcCurrentSnapshot(GameNetworkManager.singleton.serverFixedTime, this.interpolationDelay); if (!this.characterMotor) { if (this.rigidbodyStartedKinematic) { this.transform.position = snapshot.position; } else { this.rigidbody.MovePosition(snapshot.position); } } if (this.inputBank) { this.inputBank.moveVector = snapshot.moveVector; this.inputBank.aimDirection = snapshot.aimDirection; } if (this.characterMotor) { this.characterMotor.netIsGrounded = snapshot.isGrounded; KinematicCharacterMotor motor = this.characterMotor.Motor; if (motor != null) { motor.MoveCharacter(snapshot.position); } } if (this.characterDirection) { this.characterDirection.yaw = snapshot.rotation.eulerAngles.y; return; } if (this.rigidbodyStartedKinematic) { this.transform.rotation = snapshot.rotation; return; } this.rigidbody.MoveRotation(snapshot.rotation); }
// Token: 0x06001EFE RID: 7934 RVA: 0x000921C4 File Offset: 0x000903C4 private CharacterNetworkTransform.Snapshot CalcCurrentSnapshot(float time, float interpolationDelay) { float num = time - interpolationDelay; if (this.snapshots.Count < 2) { CharacterNetworkTransform.Snapshot result = (this.snapshots.Count == 0) ? this.BuildSnapshot() : this.snapshots[0]; result.serverTime = num; return(result); } int num2 = 0; while (num2 < this.snapshots.Count - 2 && (this.snapshots[num2].serverTime > num || this.snapshots[num2 + 1].serverTime < num)) { num2++; } return(CharacterNetworkTransform.Snapshot.Interpolate(this.snapshots[num2], this.snapshots[num2 + 1], num)); }
// Token: 0x06001F97 RID: 8087 RVA: 0x00089128 File Offset: 0x00087328 private void ApplyCurrentSnapshot(float currentTime) { CharacterNetworkTransform.Snapshot snapshot = this.CalcCurrentSnapshot(currentTime, this.interpolationDelay); if (!this.characterMotor) { if (this.rigidbodyStartedKinematic) { this.transform.position = snapshot.position; } else { this.rigidbody.MovePosition(snapshot.position); } } if (this.inputBank) { this.inputBank.moveVector = snapshot.moveVector; this.inputBank.aimDirection = snapshot.aimDirection; } if (this.characterMotor) { this.characterMotor.netIsGrounded = snapshot.isGrounded; this.characterMotor.netGroundNormal = snapshot.groundNormal; if (this.characterMotor.Motor.enabled) { this.characterMotor.Motor.MoveCharacter(snapshot.position); } else { this.characterMotor.Motor.SetPosition(snapshot.position, true); } } if (this.characterDirection) { this.characterDirection.yaw = snapshot.rotation.eulerAngles.y; return; } if (this.rigidbodyStartedKinematic) { this.transform.rotation = snapshot.rotation; return; } this.rigidbody.MoveRotation(snapshot.rotation); }
// Token: 0x06001FA3 RID: 8099 RVA: 0x000894E4 File Offset: 0x000876E4 private void HandleTransformUpdatesInternal(NetworkMessage netMsg) { uint num = (uint)netMsg.reader.ReadByte(); float filteredClientRttFixed = GameNetworkManager.singleton.filteredClientRttFixed; int num2 = 0; while ((long)num2 < (long)((ulong)num)) { netMsg.ReadMessage <CharacterNetworkTransformManager.CharacterUpdateMessage>(this.currentInMessage); GameObject gameObject = this.currentInMessage.gameObject; if (gameObject && (!NetworkServer.active || gameObject.GetComponent <NetworkIdentity>().clientAuthorityOwner == netMsg.conn)) { CharacterNetworkTransform component = gameObject.GetComponent <CharacterNetworkTransform>(); if (component && !component.hasEffectiveAuthority) { CharacterNetworkTransform.Snapshot snapshot = new CharacterNetworkTransform.Snapshot { serverTime = this.currentInMessage.timestamp, position = this.currentInMessage.newPosition, moveVector = this.currentInMessage.moveVector, aimDirection = this.currentInMessage.aimDirection, rotation = this.currentInMessage.rotation, isGrounded = this.currentInMessage.isGrounded, groundNormal = this.currentInMessage.groundNormal }; if (NetworkClient.active) { snapshot.serverTime += filteredClientRttFixed; } component.PushSnapshot(snapshot); if (NetworkServer.active) { this.snapshotQueue.Enqueue(new CharacterNetworkTransformManager.NetSnapshot { gameObject = component.gameObject, snapshot = snapshot }); } } } num2++; } }
// Token: 0x06001F9E RID: 8094 RVA: 0x00089300 File Offset: 0x00087500 private static bool LerpGroundNormal(ref CharacterNetworkTransform.Snapshot a, ref CharacterNetworkTransform.Snapshot b, float t, out Vector3 groundNormal) { groundNormal = Vector3.zero; bool flag = (t > 0f) ? b.isGrounded : a.isGrounded; if (flag) { if (b.isGrounded) { if (a.isGrounded) { groundNormal = Vector3.Slerp(a.groundNormal, b.groundNormal, t); return(flag); } groundNormal = b.groundNormal; return(flag); } else { groundNormal = a.groundNormal; } } return(flag); }