private void UnserializeMode2D(NetworkReader reader, bool initialState)
{
if (base.hasAuthority)
{
reader.ReadVector2();
reader.ReadVector2();
if (this.syncRotationAxis != AxisSyncMode.None)
{
UnserializeRotation2D(reader, this.rotationSyncCompression);
}
if (this.syncSpin)
{
UnserializeSpin2D(reader, this.rotationSyncCompression);
}
}
else if (this.m_RigidBody2D != null)
{
if (base.isServer && (this.m_ClientMoveCallback2D != null))
{
Vector2 position = reader.ReadVector2();
Vector2 velocity = reader.ReadVector2();
float rotation = 0f;
if (this.syncRotationAxis != AxisSyncMode.None)
{
rotation = UnserializeRotation2D(reader, this.rotationSyncCompression);
}
if (!this.m_ClientMoveCallback2D(ref position, ref velocity, ref rotation))
{
return;
}
this.m_TargetSyncPosition = (Vector3) position;
this.m_TargetSyncVelocity = (Vector3) velocity;
if (this.syncRotationAxis != AxisSyncMode.None)
{
this.m_TargetSyncRotation2D = rotation;
}
}
else
{
this.m_TargetSyncPosition = (Vector3) reader.ReadVector2();
this.m_TargetSyncVelocity = (Vector3) reader.ReadVector2();
if (this.syncRotationAxis != AxisSyncMode.None)
{
this.m_TargetSyncRotation2D = UnserializeRotation2D(reader, this.rotationSyncCompression);
}
}
if (this.syncSpin)
{
this.m_TargetSyncAngularVelocity2D = UnserializeSpin2D(reader, this.rotationSyncCompression);
}
if (base.isServer && !base.isClient)
{
base.transform.position = this.m_TargetSyncPosition;
this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D);
this.m_RigidBody2D.velocity = this.m_TargetSyncVelocity;
}
else if (this.GetNetworkSendInterval() == 0f)
{
base.transform.position = this.m_TargetSyncPosition;
this.m_RigidBody2D.velocity = this.m_TargetSyncVelocity;
if (this.syncRotationAxis != AxisSyncMode.None)
{
this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D);
}
if (this.syncSpin)
{
this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D;
}
}
else
{
Vector2 vector3 = this.m_RigidBody2D.position - this.m_TargetSyncPosition;
if (vector3.magnitude > this.snapThreshold)
{
this.m_RigidBody2D.position = this.m_TargetSyncPosition;
this.m_RigidBody2D.velocity = this.m_TargetSyncVelocity;
}
if ((this.interpolateRotation == 0f) && (this.syncRotationAxis != 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;
}
}
}
}