コード例 #1
0
ファイル: LoadCustomAssets.cs プロジェクト: TAImatem/owml
 private void OnDuckLoaded(GameObject duck)
 {
     ModHelper.Console.WriteLine("Duck loaded!");
     duck.AddComponent <SphereCollider>();
     duck.AddComponent <Rigidbody>();
     _duckBody = duck.AddComponent <OWRigidbody>();
     duck.SetActive(false);
 }
コード例 #2
0
ファイル: LoadCustomAssets.cs プロジェクト: kaikecarlos/owml
 private void OnEvent(MonoBehaviour behaviour, Common.Events ev)
 {
     if (behaviour.GetType() == typeof(Flashlight) && ev == Common.Events.AfterStart)
     {
         _playerTransform = Locator.GetPlayerTransform();
         _playerBody      = _playerTransform.GetAttachedOWRigidbody();
         _isStarted       = true;
     }
 }
コード例 #3
0
        void GoToVessel()
        {
            var spawnPoint = GameObject.Find("Spawn_Vessel").GetComponent <SpawnPoint>();

            OWRigidbody playerBody = Locator.GetPlayerBody();

            playerBody.WarpToPositionRotation(spawnPoint.transform.position, spawnPoint.transform.rotation);
            playerBody.SetVelocity(spawnPoint.GetPointVelocity());
        }
コード例 #4
0
        public override void SetReferenceTransform(Transform referenceTransform)
        {
            if (ReferenceTransform == referenceTransform)
            {
                return;
            }

            base.SetReferenceTransform(referenceTransform);
            ReferenceRigidbody = ReferenceTransform ? ReferenceTransform.GetAttachedOWRigidbody() : null;
        }
コード例 #5
0
ファイル: LoadCustomAssets.cs プロジェクト: TAImatem/owml
 private void OnEvent(MonoBehaviour behaviour, Events ev)
 {
     if (behaviour.GetType() == typeof(PlayerBody) && ev == Events.AfterAwake)
     {
         _playerBody      = (PlayerBody)behaviour;
         _playerTransform = behaviour.transform;
         _isStarted       = true;
         ToggleMusic(ModHelper.Config.GetSettingsValue <bool>("enableMusic"));
     }
 }
コード例 #6
0
        public void MoveTo(SpawnPoint point)
        {
            if (point != null)
            {
                OWRigidbody playerBody = Locator.GetPlayerBody();

                playerBody.WarpToPositionRotation(point.transform.position, point.transform.rotation);
                playerBody.SetVelocity(point.GetPointVelocity());

                point.AddObjectToTriggerVolumes(Locator.GetPlayerDetector().gameObject);
                point.OnSpawnPlayer();
            }
        }
コード例 #7
0
        /// use OWRigidbody version instead of ShipBody override
        private static void SetVelocity(OWRigidbody rigidbody, Vector3 newVelocity)
        {
            if (rigidbody.RunningKinematicSimulation())
            {
                rigidbody._kinematicRigidbody.velocity = newVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameVelocity_Internal();
            }
            else
            {
                rigidbody._rigidbody.velocity = newVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameVelocity_Internal();
            }

            rigidbody._lastVelocity    = rigidbody._currentVelocity;
            rigidbody._currentVelocity = newVelocity;
        }
コード例 #8
0
        public static MTuple Make(GameObject body, AstroObject primaryBody, IPlanetConfig config)
        {
            Rigidbody RB = body.AddComponent <Rigidbody>();

            RB.mass                   = 10000;
            RB.drag                   = 0f;
            RB.angularDrag            = 0f;
            RB.useGravity             = false;
            RB.isKinematic            = true;
            RB.interpolation          = RigidbodyInterpolation.None;
            RB.collisionDetectionMode = CollisionDetectionMode.Discrete;

            OWRigidbody OWRB = body.AddComponent <OWRigidbody>();

            OWRB.SetValue("_kinematicSimulation", true);
            OWRB.SetValue("_autoGenerateCenterOfMass", true);
            OWRB.SetIsTargetable(true);
            OWRB.SetValue("_maintainOriginalCenterOfMass", true);
            OWRB.SetValue("_rigidbody", RB);

            InitialMotion IM = body.AddComponent <InitialMotion>();

            IM.SetPrimaryBody(primaryBody.GetAttachedOWRigidbody());
            IM.SetValue("_orbitAngle", config.OrbitAngle);
            IM.SetValue("_isGlobalAxis", false);
            IM.SetValue("_initAngularSpeed", 0.02f);
            IM.SetValue("_initLinearSpeed", 0f);

            DetectorBuilder.Make(body, primaryBody);

            AstroObject AO = body.AddComponent <AstroObject>();

            AO.SetValue("_type", AstroObject.Type.Planet);
            AO.SetValue("_name", AstroObject.Name.None);
            AO.SetValue("_primaryBody", primaryBody);
            if (config.HasGravity)
            {
                GravityVolume GV = GravityBuilder.Make(body, config.SurfaceAcceleration, config.GroundSize, config.GroundSize);
                AO.SetValue("_gravityVolume", GV);
            }

            if (config.IsTidallyLocked)
            {
                RotateToAstroObject RTAO = body.AddComponent <RotateToAstroObject>();
                RTAO.SetValue("_astroObjectLock", primaryBody);
            }

            Logger.Log("Finished building base", Logger.LogType.Log);
            return(new MTuple(AO, OWRB));
        }
コード例 #9
0
        public static bool ItemTool_DropItem(ItemTool __instance, RaycastHit hit, OWRigidbody targetRigidbody, IItemDropTarget customDropTarget)
        {
            Locator.GetPlayerAudioController().PlayDropItem(__instance._heldItem.GetItemType());
            var    hitGameObject = hit.collider.gameObject;
            var    gameObject2   = hitGameObject;
            var    sectorGroup   = gameObject2.GetComponent <ISectorGroup>();
            Sector sector        = null;

            while (sectorGroup == null && gameObject2.transform.parent != null)
            {
                gameObject2 = gameObject2.transform.parent.gameObject;
                sectorGroup = gameObject2.GetComponent <ISectorGroup>();
            }

            if (sectorGroup != null)
            {
                sector = sectorGroup.GetSector();
                if (sector == null && sectorGroup is SectorCullGroup sectorCullGroup)
                {
                    var controllingProxy = sectorCullGroup.GetControllingProxy();
                    if (controllingProxy != null)
                    {
                        sector = controllingProxy.GetSector();
                    }
                }
            }

            var parent = (customDropTarget == null)
                                ? targetRigidbody.transform
                                : customDropTarget.GetItemDropTargetTransform(hit.collider.gameObject);
            var IQSBItem = __instance._heldItem.GetWorldObject <IQSBItem>();

            __instance._heldItem.DropItem(hit.point, hit.normal, parent, sector, customDropTarget);
            __instance._heldItem = null;
            QSBPlayerManager.LocalPlayer.HeldItem = null;
            Locator.GetToolModeSwapper().UnequipTool();
            var parentSector = parent.GetComponentInChildren <Sector>();

            if (parentSector != null)
            {
                var localPos = parentSector.transform.InverseTransformPoint(hit.point);
                IQSBItem.SendMessage(new DropItemMessage(localPos, hit.normal, parentSector));
                return(false);
            }

            DebugLog.ToConsole($"Error - No sector found for rigidbody {targetRigidbody.name}!.", MessageType.Error);
            return(false);
        }
コード例 #10
0
        public void ResetPlayer()
        {
            // Reset player position.
            OWRigidbody playerBody = Locator.GetPlayerBody();

            playerBody.WarpToPositionRotation(_playerSpawnPoint.transform.position, _playerSpawnPoint.transform.rotation);
            playerBody.SetVelocity(_playerSpawnPoint.GetPointVelocity());
            _playerSpawnPoint.AddObjectToTriggerVolumes(Locator.GetPlayerDetector().gameObject);
            _playerSpawnPoint.AddObjectToTriggerVolumes(_fluidDetector.gameObject);
            _playerSpawnPoint.OnSpawnPlayer();

            // Stop suffocation sound effect.
            _playerResources.SetValue("_isSuffocating", false);

            // Reset player health and resources.
            _playerResources.DebugRefillResources();

            // Remove space suit.
            _spaceSuit.RemoveSuit(true);
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        public void Init()
        {
            var playerTransform = Locator.GetPlayerTransform();

            _playerResources = playerTransform.GetComponent <PlayerResources>();
            _spaceSuit       = Locator.GetPlayerSuit();
            _playerSpawner   = FindObjectOfType <PlayerSpawner>();
            _shipTractorBeam = FindObjectOfType <ShipTractorBeamSwitch>();
            _fluidDetector   = Locator.GetPlayerCamera().GetComponentInChildren <FluidDetector>();

            _playerSpawnPoint = GetSpawnPoint();
            _shipSpawnPoint   = GetSpawnPoint(true);

            var shipTransform = Locator.GetShipTransform();

            if (shipTransform == null)
            {
                DebugLog.ToConsole($"Warning - Init() ran when ship was null?", MessageType.Warning);
                return;
            }
            _shipComponents    = shipTransform.GetComponentsInChildren <ShipComponent>();
            _hatchController   = shipTransform.GetComponentInChildren <HatchController>();
            _cockpitController = shipTransform.GetComponentInChildren <ShipCockpitController>();
            _shipBody          = Locator.GetShipBody();

            if (_shipSpawnPoint == null)
            {
                DebugLog.ToConsole("Warning - _shipSpawnPoint is null in Init()!", MessageType.Warning);
                return;
            }

            // Move debug spawn point to initial ship position (so ship doesnt spawn in space!)
            var timberHearth = Locator.GetAstroObject(AstroObject.Name.TimberHearth).transform;

            _shipSpawnPoint.transform.SetParent(timberHearth);
            _shipSpawnPoint.transform.localPosition = ShipContainerOffset;
            _shipSpawnPoint.transform.localRotation = ShipContainerRotation;
        }
コード例 #13
0
        public static void Make(GameObject body, OWRigidbody rigidbody, IPlanetConfig config)
        {
            GameObject rfGO = new GameObject("RFVolume");

            rfGO.transform.parent = body.transform;
            rfGO.layer            = 19;
            rfGO.SetActive(false);

            SphereCollider SC = rfGO.AddComponent <SphereCollider>();

            SC.isTrigger = true;
            SC.radius    = config.AtmoEndSize * 2;

            ReferenceFrameVolume RFV = rfGO.AddComponent <ReferenceFrameVolume>();

            ReferenceFrame RV = new ReferenceFrame(rigidbody);

            RV.SetValue("_minSuitTargetDistance", 300);
            RV.SetValue("_maxTargetDistance", 0);
            RV.SetValue("_autopilotArrivalDistance", 1000);
            RV.SetValue("_autoAlignmentDistance", 1000);
            //Utility.AddDebugShape.AddSphere(rfGO, 1000, new Color32(0, 255, 0, 128));
            RV.SetValue("_hideLandingModePrompt", false);
            RV.SetValue("_matchAngularVelocity", true);
            RV.SetValue("_minMatchAngularVelocityDistance", 70);
            RV.SetValue("_maxMatchAngularVelocityDistance", 400);
            RV.SetValue("_bracketsRadius", 300);

            RFV.SetValue("_referenceFrame", RV);
            RFV.SetValue("_minColliderRadius", 300);
            RFV.SetValue("_maxColliderRadius", config.AtmoEndSize * 2);
            RFV.SetValue("_isPrimaryVolume", true);
            RFV.SetValue("_isCloseRangeVolume", false);

            rfGO.SetActive(true);
            Logger.Log("Finished building rfvolume", Logger.LogType.Log);
        }
コード例 #14
0
        public static bool ItemTool_DropItem(RaycastHit hit, OWRigidbody targetRigidbody, DetachableFragment detachableFragment, ref OWItem ____heldItem)
        {
            Locator.GetPlayerAudioController().PlayDropItem(____heldItem.GetItemType());
            var    hitGameObject = hit.collider.gameObject;
            var    gameObject2   = hitGameObject;
            var    sectorGroup   = gameObject2.GetComponent <ISectorGroup>();
            Sector sector        = null;

            while (sectorGroup == null && gameObject2.transform.parent != null)
            {
                gameObject2 = gameObject2.transform.parent.gameObject;
                sectorGroup = gameObject2.GetComponent <ISectorGroup>();
            }
            if (sectorGroup != null)
            {
                sector = sectorGroup.GetSector();
            }
            var parent = (detachableFragment != null)
                                ? detachableFragment.transform
                                : targetRigidbody.transform;
            var objectId = QSBWorldSync.GetIdFromTypeSubset(ItemManager.GetObject(____heldItem));

            ____heldItem.DropItem(hit.point, hit.normal, parent, sector, detachableFragment);
            ____heldItem = null;
            Locator.GetToolModeSwapper().UnequipTool();
            var parentSector = parent.GetComponentInChildren <Sector>();

            if (parentSector != null)
            {
                var localPos = parentSector.transform.InverseTransformPoint(hit.point);
                QSBEventManager.FireEvent(EventNames.QSBDropItem, objectId, localPos, hit.normal, parentSector);
                return(false);
            }
            DebugLog.ToConsole($"Error - No sector found for rigidbody {targetRigidbody.name}!.", MessageType.Error);
            return(false);
        }
コード例 #15
0
 public static Vector3 FromRelAngVel(this OWRigidbody reference, Vector3 relAngVel) => relAngVel + reference.GetAngularVelocity();
コード例 #16
0
 public static Vector3 ToRelAngVel(this OWRigidbody reference, Vector3 angVel) => angVel - reference.GetAngularVelocity();
コード例 #17
0
 public static Vector3 FromRelVel(this OWRigidbody reference, Vector3 relVel, Vector3 pos) => relVel + reference.GetPointVelocity(pos);
コード例 #18
0
 public static Vector3 ToRelVel(this OWRigidbody reference, Vector3 vel, Vector3 pos) => vel - reference.GetPointVelocity(pos);
コード例 #19
0
ファイル: TAIcheat.cs プロジェクト: TAImatem/OW_TAIcheat
        private RelativeLocationData relconstr(Vector3 body_position, Quaternion body_rotation, Vector3 body_velocity, OWRigidbody relativeBody, Transform relativeTransform = null)
        {
            if (relativeTransform == null)
            {
                relativeTransform = relativeBody.transform;
            }
            RelativeLocationData res = new RelativeLocationData(Locator.GetPlayerBody(), relativeBody);

            res.localPosition         = relativeTransform.InverseTransformPoint(body_position);
            res.localRotation         = Quaternion.Inverse(relativeTransform.rotation) * body_rotation;
            res.localRelativeVelocity = relativeTransform.InverseTransformDirection(body_velocity - relativeBody.GetPointVelocity(body_position));
            return(res);
        }
コード例 #20
0
 public static bool ShipDetachableModule_Detach(out OWRigidbody __result)
 {
     __result = null;
     return(false);
 }
コード例 #21
0
        private static void GetTargetPosition(QuantumMoon __instance, int stateIndex, int orbitIndex, out float orbitRadius, out OWRigidbody bodyToOrbit, out Vector3 targetPosition, out Vector3 onUnitSphere)
        {
            orbitRadius = (orbitIndex != -1)
                                        ? __instance._orbits[orbitIndex].GetOrbitRadius()
                                        : 10000f;

            bodyToOrbit = (orbitIndex != -1)
                                ? __instance._orbits[orbitIndex].GetAttachedOWRigidbody()
                                : Locator.GetAstroObject(AstroObject.Name.Sun).GetOWRigidbody();

            onUnitSphere = UnityEngine.Random.onUnitSphere;

            if (stateIndex == 5)
            {
                onUnitSphere.y = 0f;
                onUnitSphere.Normalize();
            }

            targetPosition = (onUnitSphere * orbitRadius) + bodyToOrbit.GetWorldCenterOfMass();
        }
コード例 #22
0
 private void OnEnterFlight(OWRigidbody shipBody)
 {
     SetAllToFalse();
     startTime1             = Time.time;
     _movingFlightCameraOut = true;
 }
コード例 #23
0
        public static bool Moon_ChangeQuantumState(
            QuantumMoon __instance,
            ref bool __result,
            bool skipInstantVisibilityCheck,
            bool ____isPlayerInside,
            bool ____hasSunCollapsed,
            float ____playerWarpTime,
            ref int ____stateIndex,
            ref int ____collapseToIndex,
            QuantumOrbit[] ____orbits,
            float ____sphereCheckRadius,
            VisibilityTracker ____visibilityTracker,
            OWRigidbody ____moonBody,
            ConstantForceDetector ____constantForceDetector,
            ref bool ____useInitialMotion,
            ref int ____lastStateIndex,
            ref int[] ____stateSkipCounts,
            AudioSignal ____quantumSignal,
            ReferenceFrameVolume ____referenceFrameVolume,
            GameObject[] ____deactivateAtEye
            )
        {
            if (QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, skipInstantVisibilityCheck) && !QuantumManager.Instance.Shrine.IsPlayerInDarkness())
            {
                if (!skipInstantVisibilityCheck)
                {
                    var method = new StackTrace().GetFrame(3).GetMethod();
                    DebugLog.ToConsole($"Warning - Tried to change moon state while still observed. Called by {method.DeclaringType}.{method.Name}", MessageType.Warning);
                }
                __result = false;
                return(false);
            }
            var flag = false;

            if (____isPlayerInside && ____hasSunCollapsed)
            {
                __result = false;
                return(false);
            }
            if (Time.time - ____playerWarpTime < 1f)
            {
                __result = false;
                return(false);
            }
            if (____stateIndex == 5 && ____isPlayerInside && !__instance.IsPlayerEntangled())
            {
                __result = false;
                return(false);
            }
            for (var i = 0; i < 10; i++)
            {
                var stateIndex = (____collapseToIndex == -1) ? (int)__instance.GetType().GetMethod("GetRandomStateIndex", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, null) : ____collapseToIndex;
                var orbitIndex = -1;
                for (var j = 0; j < ____orbits.Length; j++)
                {
                    if (____orbits[j].GetStateIndex() == stateIndex)
                    {
                        orbitIndex = j;
                        break;
                    }
                }
                if (orbitIndex == -1)
                {
                    DebugLog.ToConsole($"Error - QM failed to find orbit for state {stateIndex}", MessageType.Error);
                }
                var orbitRadius  = (orbitIndex == -1) ? 10000f : ____orbits[orbitIndex].GetOrbitRadius();
                var owRigidbody  = (orbitIndex == -1) ? Locator.GetAstroObject(AstroObject.Name.Sun).GetOWRigidbody() : ____orbits[orbitIndex].GetAttachedOWRigidbody();
                var onUnitSphere = UnityEngine.Random.onUnitSphere;
                if (stateIndex == 5)
                {
                    onUnitSphere.y = 0f;
                    onUnitSphere.Normalize();
                }
                var position = (onUnitSphere * orbitRadius) + owRigidbody.GetWorldCenterOfMass();
                if (!Physics.CheckSphere(position, ____sphereCheckRadius, OWLayerMask.physicalMask) || ____collapseToIndex != -1)
                {
                    ____visibilityTracker.transform.position = position;
                    if (!Physics.autoSyncTransforms)
                    {
                        Physics.SyncTransforms();
                    }
                    if (__instance.IsPlayerEntangled() || !QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, skipInstantVisibilityCheck))
                    {
                        ____moonBody.transform.position = position;
                        if (!Physics.autoSyncTransforms)
                        {
                            Physics.SyncTransforms();
                        }
                        ____visibilityTracker.transform.localPosition = Vector3.zero;
                        ____constantForceDetector.AddConstantVolume(owRigidbody.GetAttachedGravityVolume(), true, true);
                        var velocity = owRigidbody.GetVelocity();
                        if (____useInitialMotion)
                        {
                            var initialMotion = owRigidbody.GetComponent <InitialMotion>();
                            velocity             = (initialMotion == null) ? Vector3.zero : initialMotion.GetInitVelocity();
                            ____useInitialMotion = false;
                        }
                        var orbitAngle = UnityEngine.Random.Range(0, 360);
                        ____moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, ____moonBody, orbitAngle) + velocity);
                        ____lastStateIndex  = ____stateIndex;
                        ____stateIndex      = stateIndex;
                        ____collapseToIndex = -1;
                        flag = true;
                        for (var k = 0; k < ____stateSkipCounts.Length; k++)
                        {
                            ____stateSkipCounts[k] = (k != ____stateIndex) ? (____stateSkipCounts[k] + 1) : 0;
                        }
                        QSBEventManager.FireEvent(EventNames.QSBMoonStateChange, stateIndex, onUnitSphere, orbitAngle);
                        break;
                    }
                    ____visibilityTracker.transform.localPosition = Vector3.zero;
                }
                else
                {
                    DebugLog.ToConsole("Warning - Quantum moon orbit position occupied! Aborting collapse.", MessageType.Warning);
                }
            }
            if (flag)
            {
                if (____isPlayerInside)
                {
                    __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { ____stateIndex });
                }
                else
                {
                    __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { -1 });
                    ____quantumSignal.SetSignalActivation(____stateIndex != 5, 2f);
                }
                ____referenceFrameVolume.gameObject.SetActive(____stateIndex != 5);
                ____moonBody.SetIsTargetable(____stateIndex != 5);
                for (var l = 0; l < ____deactivateAtEye.Length; l++)
                {
                    ____deactivateAtEye[l].SetActive(____stateIndex != 5);
                }
                GlobalMessenger <OWRigidbody> .FireEvent("QuantumMoonChangeState", ____moonBody);

                __result = true;
                return(false);
            }
            __result = false;
            return(false);
        }
コード例 #24
0
        public static bool Moon_CheckPlayerFogProximity(
            QuantumMoon __instance,
            int ____stateIndex,
            float ____eyeStateFogOffset,
            ref bool ____isPlayerInside,
            float ____fogRadius,
            float ____fogThickness,
            float ____fogRolloffDistance,
            string ____revealFactID,
            OWRigidbody ____moonBody,
            bool ____hasSunCollapsed,
            Transform ____vortexReturnPivot,
            OWAudioSource ____vortexAudio,
            ref int ____collapseToIndex,
            VisibilityTracker ____visibilityTracker,
            QuantumFogEffectBubbleController ____playerFogBubble,
            QuantumFogEffectBubbleController ____shipLandingCamFogBubble)
        {
            var playerDistance  = Vector3.Distance(__instance.transform.position, Locator.GetPlayerCamera().transform.position);
            var fogOffset       = (____stateIndex != 5) ? 0f : ____eyeStateFogOffset;
            var distanceFromFog = playerDistance - (____fogRadius + fogOffset);
            var fogAlpha        = 0f;

            if (!____isPlayerInside)
            {
                fogAlpha = Mathf.InverseLerp(____fogThickness + ____fogRolloffDistance, ____fogThickness, distanceFromFog);
                if (distanceFromFog < 0f)
                {
                    if ((bool)__instance.GetType().GetMethod("IsLockedByProbeSnapshot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, null) || QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, true))
                    {
                        ____isPlayerInside = true;
                        __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { ____stateIndex });
                        Locator.GetShipLogManager().RevealFact(____revealFactID, true, true);
                        QSBEventManager.FireEvent("PlayerEnterQuantumMoon");
                    }
                    else
                    {
                        __instance.GetType().GetMethod("Collapse", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { true });
                    }
                }
            }
            else if (____isPlayerInside)
            {
                fogAlpha = Mathf.InverseLerp(-____fogThickness - ____fogRolloffDistance, -____fogThickness, distanceFromFog);
                if (distanceFromFog >= 0f)
                {
                    if (____stateIndex != 5)
                    {
                        ____isPlayerInside = false;
                        if (!(bool)__instance.GetType().GetMethod("IsLockedByProbeSnapshot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, null) && !QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, true))
                        {
                            __instance.GetType().GetMethod("Collapse", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { true });
                        }
                        __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { -1 });
                        QSBEventManager.FireEvent("PlayerExitQuantumMoon");
                    }
                    else
                    {
                        var vector = Locator.GetPlayerTransform().position - __instance.transform.position;
                        Locator.GetPlayerBody().SetVelocity(____moonBody.GetPointVelocity(Locator.GetPlayerTransform().position) - (vector.normalized * 5f));
                        var d = 80f;
                        Locator.GetPlayerBody().SetPosition(__instance.transform.position + (____vortexReturnPivot.up * d));
                        if (!Physics.autoSyncTransforms)
                        {
                            Physics.SyncTransforms();
                        }
                        var component = Locator.GetPlayerCamera().GetComponent <PlayerCameraController>();
                        component.SetDegreesY(component.GetMinDegreesY());
                        ____vortexAudio.SetLocalVolume(0f);
                        ____collapseToIndex = 1;
                        __instance.GetType().GetMethod("Collapse", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { true });
                    }
                }
            }
            ____playerFogBubble.SetFogAlpha(fogAlpha);
            ____shipLandingCamFogBubble.SetFogAlpha(fogAlpha);
            return(false);
        }