private static void MoveMoon(QuantumMoon __instance, Vector3 targetPosition, OWRigidbody bodyToOrbit, int stateIndex, Vector3 onUnitSphere, ref bool foundNewPosition) { __instance._moonBody.transform.position = targetPosition; if (!Physics.autoSyncTransforms) { Physics.SyncTransforms(); } __instance._visibilityTracker.transform.localPosition = Vector3.zero; __instance._constantForceDetector.AddConstantVolume(bodyToOrbit.GetAttachedGravityVolume(), true, true); var bodyVelocity = bodyToOrbit.GetVelocity(); if (__instance._useInitialMotion) { var component = bodyToOrbit.GetComponent <InitialMotion>(); bodyVelocity = (component != null) ? component.GetInitVelocity() : Vector3.zero; __instance._useInitialMotion = false; } var orbitAngle = Random.Range(0, 360); __instance._moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(bodyToOrbit, __instance._moonBody, orbitAngle) + bodyVelocity); __instance._useInitialMotion = false; __instance._lastStateIndex = __instance._stateIndex; __instance._stateIndex = stateIndex; __instance._collapseToIndex = -1; foundNewPosition = true; for (var k = 0; k < __instance._stateSkipCounts.Length; k++) { __instance._stateSkipCounts[k] = (k == __instance._stateIndex) ? 0 : (__instance._stateSkipCounts[k] + 1); } new MoonStateChangeMessage(stateIndex, onUnitSphere, orbitAngle).Send(); }