Пример #1
0
		private void RegisterBody(HumanSegment segment, HumanSegment relativeTo, bool pos, bool rot, int precision = 0)
		{
			NetIdentity netIdentity = segment.rigidbody.gameObject.AddComponent<NetIdentity>();
			netIdentity.sceneId = (uint)nextIdentityId++;
			NetBody netBody = segment.rigidbody.gameObject.AddComponent<NetBody>();
			netBody.despawnHeight = float.NegativeInfinity;
			netBody.disableSleep = true;
			netBody.syncPosition = (pos ? ((relativeTo == null) ? NetBodySyncPosition.Absolute : NetBodySyncPosition.Relative) : NetBodySyncPosition.None);
			netBody.syncRotation = (rot ? ((relativeTo == null) ? NetBodySyncRotation.Absolute : NetBodySyncRotation.Relative) : NetBodySyncRotation.None);
			netBody.relativeTo = relativeTo?.transform;
			netBody.rotPrecision = precision;
			netBody.posPrecision = precision;
			if (netBody.syncPosition == NetBodySyncPosition.Absolute)
			{
				netBody.posRangeOverride = 4000f;
				netBody.posPrecision += 2;
			}
			if (relativeTo != null)
			{
				netBody.posRangeOverride = 2f;
				netBody.posPrecision -= 2;
			}
			AddIdentity(netIdentity);
			netBody.Start();
			if (NetGame.isClient && pos)
			{
				segment.rigidbody.gameObject.SetActive(value: false);
			}
		}