private void UnserializeMode2D(P2PNetworkReader reader, bool initialState) { if (this.m_ClientMoveCallback2D != null) { Vector2 v = reader.ReadVector2(); Vector2 v2 = reader.ReadVector2(); float targetSyncRotation2D = 0f; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { targetSyncRotation2D = ReplicatedTransform.UnserializeRotation2D(reader, this.rotationSyncCompression); } if (!this.m_ClientMoveCallback2D(ref v, ref v2, ref targetSyncRotation2D)) { return; } this.m_TargetSyncPosition = v; this.m_TargetSyncVelocity = v2; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_TargetSyncRotation2D = targetSyncRotation2D; } } else { this.m_TargetSyncPosition = reader.ReadVector2(); this.m_TargetSyncVelocity = reader.ReadVector2(); if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_TargetSyncRotation2D = ReplicatedTransform.UnserializeRotation2D(reader, this.rotationSyncCompression); } } if (this.syncSpin) { this.m_TargetSyncAngularVelocity2D = ReplicatedTransform.UnserializeSpin2D(reader, this.rotationSyncCompression); } if (this.m_RigidBody2D != null) { if (this.ReplGetReplicationInterval() <= 0f) { base.transform.position = this.m_TargetSyncPosition; this.m_RigidBody2D.velocity = this.m_TargetSyncVelocity; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D); } if (this.syncSpin) { this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D; } return; } if ((this.m_RigidBody2D.position - this.m_TargetSyncPosition).magnitude > this.snapThreshold) { this.m_RigidBody2D.position = this.m_TargetSyncPosition; this.m_RigidBody2D.velocity = this.m_TargetSyncVelocity; } if (this.interpolateRotation == 0f && this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_RigidBody2D.rotation = this.m_TargetSyncRotation2D; if (this.syncSpin) { this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D; } } if (this.m_InterpolateMovement == 0f) { this.m_RigidBody2D.position = this.m_TargetSyncPosition; } if (initialState) { this.m_RigidBody2D.rotation = this.m_TargetSyncRotation2D; } } }
public static Vector3 UnserializeVelocity2D(P2PNetworkReader reader, ReplicatedTransform.CompressionSyncMode compression) { return(reader.ReadVector2()); }