private void FixedUpdate()
 {
     if (this._enteringSim && Time.time > this._enterSimTime)
     {
         Locator.GetPlayerSuit().RemoveSuit(true);
         this._enteringSim = false;
         this._playerCamEffectController.OpenEyes(2f, false);
         this._insideSim     = true;
         this._localSleepPos = this._planetBody.transform.InverseTransformPoint(Locator.GetPlayerTransform().position);
         this._localSleepRot = Quaternion.Inverse(this._planetBody.transform.rotation) * Locator.GetPlayerTransform().rotation;
         Locator.GetFlashlight().TurnOff(false);
         Locator.GetPlayerBody().WarpToPositionRotation(this._entrySocket.position, this._entrySocket.rotation);
         Locator.GetPlayerBody().SetVelocity(this._simBody.GetPointVelocity(this._entrySocket.position));
         GlobalMessenger.FireEvent("EnterDreamWorld");
         OWInput.ChangeInputMode(InputMode.Character);
     }
     else if (this._exitingSim && Time.time > this._exitSimTime)
     {
         Locator.GetPlayerSuit().SuitUp(false, true);
         this._exitingSim = false;
         this._playerCamEffectController.OpenEyes(0.5f, false);
         this._insideSim = false;
         Locator.GetPlayerBody().WarpToPositionRotation(this._planetBody.transform.TransformPoint(this._localSleepPos), this._planetBody.transform.rotation * this._localSleepRot);
         Locator.GetPlayerBody().SetVelocity(this._planetBody.GetPointVelocity(this._planetBody.transform.TransformPoint(this._localSleepPos)));
         GlobalMessenger.FireEvent("ExitDreamWorld");
         OWInput.ChangeInputMode(InputMode.Character);
     }
 }
Ejemplo n.º 2
0
 private void HandleEvent(bool state)
 {
     if (NetworkServer.active)
     {
         GlobalMessenger <int, bool> .FireEvent(EventNames.QSBGeyserState, ObjectId, state);
     }
 }
 private void SwitchToPlayerCamera()
 {
     if (_slavePlatform._visualSector != null)
     {
         if (!_alreadyOccupiedSectors.Contains(_slavePlatform._visualSector))
         {
             _slavePlatform._visualSector.RemoveOccupant(Locator.GetPlayerSectorDetector());
         }
         var parentSector = _slavePlatform._visualSector.GetParentSector();
         while (parentSector != null)
         {
             if (!_alreadyOccupiedSectors.Contains(parentSector))
             {
                 parentSector.RemoveOccupant(Locator.GetPlayerSectorDetector());
             }
             parentSector = parentSector.GetParentSector();
         }
     }
     if (_slavePlatform._visualSector2 != null)
     {
         _slavePlatform._visualSector2.RemoveOccupant(Locator.GetPlayerSectorDetector());
     }
     if (_slavePlatform._darkZone != null)
     {
         _slavePlatform._darkZone.RemovePlayerFromZone(true);
     }
     QSBEventManager.FireEvent(EventNames.QSBExitPlatform, CustomPlatformList.IndexOf(this));
     GlobalMessenger.FireEvent("ExitNomaiRemoteCamera");
     _slavePlatform._ownedCamera.Deactivate();
     _slavePlatform._ownedCamera.SetImageEffectFade(0f);
 }
        public override void OnClientConnect(NetworkConnection connection) // Called on the client when connecting to a server
        {
            base.OnClientConnect(connection);

            gameObject.AddComponent <SectorSync>();
            gameObject.AddComponent <RespawnOnDeath>();
            gameObject.AddComponent <PreventShipDestruction>();

            if (NetworkClient.active && !NetworkServer.active)
            {
                gameObject.AddComponent <Events.PlayerState>();
                GeyserManager.Instance.EmptyUpdate();
                WakeUpPatches.AddPatches();
            }

            _lobby.CanEditName = false;

            OnNetworkManagerReady?.Invoke();
            IsReady = true;

            QSB.Helper.Events.Unity.RunWhen(() => PlayerTransformSync.LocalInstance != null, EventList.Init);

            QSB.Helper.Events.Unity.RunWhen(() => EventList.Ready,
                                            () => GlobalMessenger <string> .FireEvent(EventNames.QSBPlayerJoin, _lobby.PlayerName));
        }
 private void SwitchToRemoteCamera()
 {
     QSBEventManager.FireEvent(EventNames.QSBEnterPlatform, CustomPlatformList.IndexOf(this));
     GlobalMessenger.FireEvent("EnterNomaiRemoteCamera");
     _slavePlatform.RevealFactID();
     _slavePlatform._ownedCamera.Activate(this, _playerCamera);
     _slavePlatform._ownedCamera.SetImageEffectFade(0f);
     _alreadyOccupiedSectors.Clear();
     if (_slavePlatform._visualSector != null)
     {
         if (_visualSector.ContainsOccupant(DynamicOccupant.Player))
         {
             _alreadyOccupiedSectors.Add(_visualSector);
         }
         _slavePlatform._visualSector.AddOccupant(Locator.GetPlayerSectorDetector());
         var parentSector = _slavePlatform._visualSector.GetParentSector();
         while (parentSector != null)
         {
             if (parentSector.ContainsOccupant(DynamicOccupant.Player))
             {
                 _alreadyOccupiedSectors.Add(parentSector);
             }
             parentSector.AddOccupant(Locator.GetPlayerSectorDetector());
             parentSector = parentSector.GetParentSector();
         }
     }
     if (_slavePlatform._visualSector2 != null)
     {
         _slavePlatform._visualSector2.AddOccupant(Locator.GetPlayerSectorDetector());
     }
     if (_slavePlatform._darkZone != null)
     {
         _slavePlatform._darkZone.AddPlayerToZone(true);
     }
 }
        public override void OnReceiveRemote()
        {
            if (QSBCore.IsHost)
            {
                QSBWorldSync.SetDialogueCondition(ConditionName, ConditionState);
            }

            var sharedInstance = DialogueConditionManager.SharedInstance;

            var flag = true;

            if (sharedInstance.ConditionExists(ConditionName))
            {
                if (sharedInstance._dictConditions[ConditionName] == ConditionState)
                {
                    flag = false;
                }

                sharedInstance._dictConditions[ConditionName] = ConditionState;
            }
            else
            {
                sharedInstance.AddCondition(ConditionName, ConditionState);
            }

            if (flag)
            {
                GlobalMessenger <string, bool> .FireEvent("DialogueConditionChanged", ConditionName, ConditionState);
            }

            if (ConditionName == "LAUNCH_CODES_GIVEN")
            {
                PlayerData.LearnLaunchCodes();
            }
        }
Ejemplo n.º 7
0
        public static bool CloneFixedUpdate(PlayerCloneController __instance)
        {
            var playerTransform = Locator.GetPlayerTransform();
            var vector          = __instance.transform.parent.InverseTransformPoint(playerTransform.position);
            var b        = __instance._localMirrorPos - vector;
            var position = __instance._localMirrorPos + b;

            position.y = vector.y;
            __instance.transform.position = __instance.transform.parent.TransformPoint(position);
            var normalized = (__instance.transform.position - playerTransform.position).normalized;
            var forward    = Vector3.Reflect(playerTransform.forward, normalized);
            var upwards    = Vector3.Reflect(playerTransform.up, normalized);

            __instance.transform.rotation = Quaternion.LookRotation(forward, upwards);
            var num = Vector3.Distance(__instance.transform.position, playerTransform.position);

            if (!__instance._warpFlickerActivated && num < 10f)
            {
                __instance._warpFlickerActivated = true;
                __instance._warpTime             = Time.time + 0.5f;
                GlobalMessenger <float, float> .FireEvent(OWEvents.FlickerOffAndOn, 0.5f, 0.5f);

                new EyeCloneSeenMessage().Send();
            }

            if (__instance._warpPlayerNextFrame)
            {
                __instance.WarpPlayerToCampfire();
            }

            return(false);
        }
Ejemplo n.º 8
0
        private void LateUpdate()
        {
            if (!_isOpenEyesSkipped && _isSolarSystemLoaded)
            {
                _isOpenEyesSkipped = true;

                // Skip wake up animation.
                var cameraEffectController = FindObjectOfType <PlayerCameraEffectController>();
                cameraEffectController.OpenEyes(0, true);
                cameraEffectController.SetValue("_wakeLength", 0f);
                cameraEffectController.SetValue("_waitForWakeInput", false);

                // Skip wake up prompt.
                LateInitializerManager.pauseOnInitialization = false;
                Locator.GetPauseCommandListener().RemovePauseCommandLock();
                Locator.GetPromptManager().RemoveScreenPrompt(cameraEffectController.GetValue <ScreenPrompt>("_wakePrompt"));
                OWTime.Unpause(OWTime.PauseType.Sleeping);
                cameraEffectController.Invoke("WakeUp");

                // Enable all inputs immedeately.
                OWInput.ChangeInputMode(InputMode.Character);
                typeof(OWInput).SetValue("_inputFadeFraction", 0f);
                GlobalMessenger.FireEvent("TakeFirstFlashbackSnapshot");
            }
        }
        public void StartConversation()
        {
            VerifyInitialized();
            enabled = true;
            if (!_timeFrozen && PlayerData.GetFreezeTimeWhileReadingConversations() && !Locator.GetGlobalMusicController().IsEndTimesPlaying())
            {
                _timeFrozen = true;
                OWTime.Pause(OWTime.PauseType.Reading);
            }

            Locator.GetToolModeSwapper().UnequipTool();
            GlobalMessenger.FireEvent("EnterConversation");
            Locator.GetPlayerAudioController().PlayDialogueEnter();
            _wasFlashlightOn = Locator.GetFlashlight().IsFlashlightOn();
            if (_wasFlashlightOn && _turnOffFlashlight)
            {
                Locator.GetFlashlight().TurnOff(false);
            }

            DialogueConditionManager.SharedInstance.ReadPlayerData();
            SetEntryNode();
            _currentDialogueBox = DisplayDialogueBox2();
            if (_attentionPoint != null && !PlayerState.InZeroG())
            {
                Locator.GetPlayerTransform().GetRequiredComponent <PlayerLockOnTargeting>().LockOn(_attentionPoint, _attentionPointOffset, 2f);
            }

            if (PlayerState.InZeroG() && !_timeFrozen)
            {
                Locator.GetPlayerBody().GetComponent <Autopilot>().StartMatchVelocity(this.GetAttachedOWRigidbody().GetReferenceFrame());
            }
        }
Ejemplo n.º 10
0
 public static void FireEvent(string eventName)
 {
     if (!QSBCore.IsInMultiplayer)
     {
         return;
     }
     GlobalMessenger.FireEvent(eventName);
 }
Ejemplo n.º 11
0
        public static void StartLift(Elevator __instance)
        {
            var isGoingUp = __instance.GetValue <bool>("_goingToTheEnd");
            var direction = isGoingUp ? ElevatorDirection.Up : ElevatorDirection.Down;
            var id        = ElevatorManager.Instance.GetId(__instance);

            GlobalMessenger <int, ElevatorDirection> .FireEvent(EventNames.QSBStartLift, id, direction);
        }
 private static bool ProbeWarp(ref bool ____isRetrieving)
 {
     if (!____isRetrieving)
     {
         GlobalMessenger.FireEvent(EventNames.QSBOnProbeWarp);
     }
     return(true);
 }
 private void ExitShip()
 {
     _cockpitController.Invoke("ExitFlightConsole");
     _cockpitController.Invoke("CompleteExitFlightConsole");
     _hatchController.SetValue("_isPlayerInShip", false);
     _hatchController.Invoke("OpenHatch");
     GlobalMessenger.FireEvent(EventNames.ExitShip);
 }
Ejemplo n.º 14
0
 public static void FireEvent <T, U, V, W, X, Y>(string eventName, T arg1, U arg2, V arg3, W arg4, X arg5, Y arg6)
 {
     if (!QSBCore.IsInMultiplayer)
     {
         DebugLog.ToConsole($"Warning - Tried to send event {eventName} while not connected to/hosting server.", MessageType.Warning);
         return;
     }
     GlobalMessenger <T, U, V, W, X, Y> .FireEvent(eventName, arg1, arg2, arg3, arg4, arg5, arg6);
 }
Ejemplo n.º 15
0
 private void OnEvent(MonoBehaviour behaviour, Events ev)
 {
     ModHelper.Console.WriteLine("Behaviour name: " + behaviour.name);
     if (behaviour.GetType() == typeof(Flashlight) && ev == Events.AfterStart)
     {
         ModHelper.Console.WriteLine("BOOM!");
         GlobalMessenger.FireEvent("TriggerSupernova");
     }
 }
Ejemplo n.º 16
0
 public static void FireEvent <T>(string eventName, T arg)
 {
     if (!QSBCore.IsInMultiplayer)
     {
         DebugLog.ToConsole($"Warning - Tried to send event {eventName} while not connected to/hosting server.", MessageType.Warning);
         return;
     }
     GlobalMessenger <T> .FireEvent(eventName, arg);
 }
        public override void OnServerDisconnect(NetworkConnection connection) // Called on the server when any client disconnects
        {
            var playerId = connection.playerControllers[0].gameObject.GetComponent <PlayerTransformSync>().netId.Value;
            var netIds   = connection.clientOwnedObjects.Select(x => x.Value).ToArray();

            GlobalMessenger <uint, uint[]> .FireEvent(EventNames.QSBPlayerLeave, playerId, netIds);

            PlayerRegistry.GetPlayer(playerId).HudMarker?.Remove();
            CleanupConnection(connection);
        }
Ejemplo n.º 18
0
 public override void OnServerReceive(PlayerMessage message)
 {
     DebugLog.DebugWrite($"Server get state request from {message.FromId}");
     PlayerState.LocalInstance.Send();
     foreach (var item in PlayerRegistry.GetSyncObjects <TransformSync.TransformSync>()
              .Where(x => x != null && x.IsReady && x.ReferenceSector != null))
     {
         GlobalMessenger <uint, QSBSector> .FireEvent(EventNames.QSBSectorChange, item.netId.Value, item.ReferenceSector);
     }
 }
        public static bool MapController_EnterMapView(
            MapController __instance
            )
        {
            if (__instance._isMapMode)
            {
                return(false);
            }

            __instance._mapMarkerManager.SetVisible(true);
            GlobalMessenger.FireEvent("EnterMapView");
            GlobalMessenger <OWCamera> .FireEvent("SwitchActiveCamera", __instance._mapCamera);

            if (__instance._audioSource.isPlaying)
            {
                __instance._audioSource.Stop();
                __instance._audioSource.SetLocalVolume(1f);
                __instance._audioSource.Play();
            }
            else
            {
                __instance._audioSource.SetLocalVolume(1f);
                __instance._audioSource.Play();
            }

            Locator.GetAudioMixer().MixMap();
            __instance._activeCam.enabled       = false;
            __instance._mapCamera.enabled       = true;
            __instance._gridRenderer.enabled    = false;
            __instance._targetTransform         = null;
            __instance._lockedToTargetTransform = false;
            __instance._position          = RespawnOnDeath.Instance.DeathPositionWorld - Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().GetPosition();
            __instance._position.y        = 0f;
            __instance._yaw               = __instance._defaultYawAngle;
            __instance._pitch             = __instance._initialPitchAngle;
            __instance._zoom              = __instance._initialZoomDist;
            __instance._targetZoom        = __instance._defaultZoomDist;
            __instance.transform.rotation = Quaternion.LookRotation(-RespawnOnDeath.Instance.DeathPlayerUpVector, RespawnOnDeath.Instance.DeathPlayerForwardVector);
            __instance.transform.position = RespawnOnDeath.Instance.DeathPositionWorld;
            __instance._interpPosition    = true;
            __instance._interpPitch       = true;
            __instance._interpZoom        = true;
            __instance._framingPlayer     = __instance._lockedToTargetTransform;
            __instance._lockTimer         = __instance._lockOnMoveLength;
            __instance._gridOverrideSize  = (__instance._currentRFrame == null) ? 0f : __instance._currentRFrame.GetAutopilotArrivalDistance();
            __instance._gridOverride      = __instance._gridOverrideSize > 0f;
            __instance._gridTimer         = (!__instance._gridOverride) ? 0f : __instance._gridLockOnLength;
            __instance._revealLength      = 20f;
            __instance._revealTimer       = 0f;
            __instance._isMapMode         = true;
            return(false);
        }
        protected override Transform InitLocalTransform()
        {
            var body = Locator.GetPlayerCamera().gameObject.transform;

            Player.Camera = body.gameObject;

            Player.IsReady = true;
            GlobalMessenger <bool> .FireEvent(EventNames.QSBPlayerReady, true);

            GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);

            return(body);
        }
Ejemplo n.º 21
0
 private void Init()
 {
     GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);
     _state = State.Loaded;
     gameObject.AddComponent <PreserveTimeScale>();
     if (isServer)
     {
         SendServerTime();
     }
     else
     {
         WakeUpOrSleep();
     }
 }
Ejemplo n.º 22
0
        public override void OnReceiveRemote(bool server, MoonStateChangeMessage message)
        {
            if (!QSBCore.HasWokenUp)
            {
                return;
            }
            var moon = Locator.GetQuantumMoon();
            var wasPlayerEntangled   = moon.IsPlayerEntangled();
            var location             = new RelativeLocationData(Locator.GetPlayerTransform().GetComponent <OWRigidbody>(), moon.transform);
            var moonBody             = moon.GetValue <OWRigidbody>("_moonBody");
            var constantFoceDetector = (ConstantForceDetector)moonBody.GetAttachedForceDetector();
            var orbits      = moon.GetValue <QuantumOrbit[]>("_orbits");
            var orbit       = orbits.First(x => x.GetStateIndex() == message.StateIndex);
            var orbitRadius = orbit.GetOrbitRadius();
            var owRigidbody = orbit.GetAttachedOWRigidbody();
            var position    = (message.OnUnitSphere * orbitRadius) + owRigidbody.GetWorldCenterOfMass();

            moonBody.transform.position = position;
            if (!Physics.autoSyncTransforms)
            {
                Physics.SyncTransforms();
            }
            constantFoceDetector.AddConstantVolume(owRigidbody.GetAttachedGravityVolume(), true, true);
            moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, moonBody, message.OrbitAngle) + owRigidbody.GetVelocity());
            moon.SetValue("_stateIndex", message.StateIndex);

            if (moon.IsPlayerInside())
            {
                moon.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(moon, new object[] { message.StateIndex });
            }
            else
            {
                moon.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(moon, new object[] { -1 });
                moon.GetValue <AudioSignal>("_quantumSignal").SetSignalActivation(message.StateIndex != 5, 2f);
            }
            moon.GetValue <ReferenceFrameVolume>("_referenceFrameVolume").gameObject.SetActive(message.StateIndex != 5);
            moonBody.SetIsTargetable(message.StateIndex != 5);
            foreach (var obj in moon.GetValue <GameObject[]>("_deactivateAtEye"))
            {
                obj.SetActive(message.StateIndex != 5);
            }
            GlobalMessenger <OWRigidbody> .FireEvent("QuantumMoonChangeState", moonBody);

            if (wasPlayerEntangled)
            {
                Locator.GetPlayerTransform().GetComponent <OWRigidbody>().MoveToRelativeLocation(location, moon.transform);
            }
        }
Ejemplo n.º 23
0
        private void ResetTimeScale()
        {
            _timeScale = 1f;
            _state     = State.Loaded;

            if (!_isInputEnabled)
            {
                EnableInput();
            }
            _isFirstFastForward = false;
            Physics.SyncTransforms();
            SpinnerUI.Hide();
            FindObjectOfType <SleepTimerUI>().Invoke("OnEndFastForward");
            GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);
            RespawnOnDeath.Instance.Init();
        }
        public override void OnReceiveRemote()
        {
            var moon = Locator.GetQuantumMoon();
            var wasPlayerEntangled    = moon.IsPlayerEntangled();
            var location              = new RelativeLocationData(Locator.GetPlayerTransform().GetComponent <OWRigidbody>(), moon.transform);
            var moonBody              = moon._moonBody;
            var constantForceDetector = (ConstantForceDetector)moonBody.GetAttachedForceDetector();
            var orbits      = moon._orbits;
            var orbit       = orbits.First(x => x.GetStateIndex() == StateIndex);
            var orbitRadius = orbit.GetOrbitRadius();
            var owRigidbody = orbit.GetAttachedOWRigidbody();
            var position    = OnUnitSphere * orbitRadius + owRigidbody.GetWorldCenterOfMass();

            moonBody.transform.position = position;
            if (!Physics.autoSyncTransforms)
            {
                Physics.SyncTransforms();
            }

            constantForceDetector.AddConstantVolume(owRigidbody.GetAttachedGravityVolume(), true, true);
            moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, moonBody, OrbitAngle) + owRigidbody.GetVelocity());
            moon._stateIndex = StateIndex;

            if (moon.IsPlayerInside())
            {
                moon.SetSurfaceState(StateIndex);
            }
            else
            {
                moon.SetSurfaceState(-1);
                moon._quantumSignal.SetSignalActivation(StateIndex != 5);
            }

            moon._referenceFrameVolume.gameObject.SetActive(StateIndex != 5);
            moonBody.SetIsTargetable(StateIndex != 5);
            foreach (var obj in moon._deactivateAtEye)
            {
                obj.SetActive(StateIndex != 5);
            }

            GlobalMessenger <OWRigidbody> .FireEvent("QuantumMoonChangeState", moonBody);

            if (wasPlayerEntangled)
            {
                Locator.GetPlayerTransform().GetComponent <OWRigidbody>().MoveToRelativeLocation(location, moon.transform);
            }
        }
Ejemplo n.º 25
0
        public static bool EndConversation(GabbroTravelerController __instance, float audioDelay)
        {
            if (__instance._animator.enabled)
            {
                __instance._animator.CrossFadeInFixedTime("Gabbro_Playing", audioDelay, -1, -audioDelay);
                __instance._hammockAnimator.CrossFadeInFixedTime("GabbroHammock_Playing", audioDelay, -1, -audioDelay);
            }

            Locator.GetTravelerAudioManager().PlayTravelerAudio(__instance, audioDelay);
            if (DialogueConditionManager.SharedInstance.GetConditionState("MAP_PROMPT_REMINDER") || DialogueConditionManager.SharedInstance.GetConditionState("MAP_PROMPT_ATTENTION"))
            {
                var conditionState = DialogueConditionManager.SharedInstance.GetConditionState("MAP_PROMPT_ATTENTION");
                DialogueConditionManager.SharedInstance.SetConditionState("MAP_PROMPT_REMINDER");
                DialogueConditionManager.SharedInstance.SetConditionState("MAP_PROMPT_ATTENTION");
                GlobalMessenger <bool> .FireEvent("TriggerMapPromptReminder", conditionState);
            }

            return(false);
        }
Ejemplo n.º 26
0
        public override void OnReceiveRemote()
        {
            var flag = false;

            if (!PlayerData._currentGameSave.PersistentConditionExists("LAUNCH_CODES_GIVEN"))
            {
                flag = true;
            }
            else if (!PlayerData._currentGameSave.GetPersistentCondition("LAUNCH_CODES_GIVEN"))
            {
                flag = true;
            }

            if (flag)
            {
                DialogueConditionManager.SharedInstance.SetConditionState("SCIENTIST_3", true);
                PlayerData._currentGameSave.SetPersistentCondition("LAUNCH_CODES_GIVEN", true);
                GlobalMessenger.FireEvent("LearnLaunchCodes");
            }
        }
        private static void DealWithNewPosition(QuantumMoon __instance)
        {
            if (__instance._isPlayerInside)
            {
                __instance.SetSurfaceState(__instance._stateIndex);
            }
            else
            {
                __instance.SetSurfaceState(-1);
                __instance._quantumSignal.SetSignalActivation(__instance._stateIndex != 5);
            }

            __instance._referenceFrameVolume.gameObject.SetActive(__instance._stateIndex != 5);
            __instance._moonBody.SetIsTargetable(__instance._stateIndex != 5);

            for (var l = 0; l < __instance._deactivateAtEye.Length; l++)
            {
                __instance._deactivateAtEye[l].SetActive(__instance._stateIndex != 5);
            }

            GlobalMessenger <OWRigidbody> .FireEvent("QuantumMoonChangeState", __instance._moonBody);
        }
        public void EndConversation()
        {
            if (!enabled)
            {
                return;
            }

            enabled = false;
            if (_timeFrozen)
            {
                _timeFrozen = false;
                OWTime.Unpause(OWTime.PauseType.Reading);
            }

            _interactVolume.ResetInteraction();
            Locator.GetPlayerTransform().GetRequiredComponent <PlayerLockOnTargeting>().BreakLock();
            GlobalMessenger.FireEvent("ExitConversation");
            Locator.GetPlayerAudioController().PlayDialogueExit();
            if (_wasFlashlightOn && _turnOffFlashlight && _turnOnFlashlight)
            {
                Locator.GetFlashlight().TurnOn(false);
            }

            GameObject.FindWithTag("DialogueGui").GetRequiredComponent <DialogueBoxVer2>().OnEndDialogue();
            if (_currentNode != null)
            {
                _currentNode.SetNodeCompleted();
            }

            if (PlayerState.InZeroG())
            {
                var component = Locator.GetPlayerBody().GetComponent <Autopilot>();
                if (component.enabled)
                {
                    component.Abort();
                }
            }
        }
Ejemplo n.º 29
0
        public static bool LearnLaunchCodes()
        {
            var flag = false;

            if (!PlayerData._currentGameSave.PersistentConditionExists("LAUNCH_CODES_GIVEN"))
            {
                flag = true;
            }

            else if (PlayerData._currentGameSave.GetPersistentCondition("LAUNCH_CODES_GIVEN"))
            {
                flag = true;
            }

            if (flag)
            {
                DialogueConditionManager.SharedInstance.SetConditionState("SCIENTIST_3", true);
                PlayerData._currentGameSave.SetPersistentCondition("LAUNCH_CODES_GIVEN", true);
                GlobalMessenger.FireEvent("LearnLaunchCodes");
                new LaunchCodesMessage().Send();
            }

            return(false);
        }
        public static bool QuantumMoon_CheckPlayerFogProximity(QuantumMoon __instance)
        {
            var playerDistance  = Vector3.Distance(__instance.transform.position, Locator.GetPlayerCamera().transform.position);
            var fogOffset       = (__instance._stateIndex != 5) ? 0f : __instance._eyeStateFogOffset;
            var distanceFromFog = playerDistance - (__instance._fogRadius + fogOffset);
            var fogAlpha        = 0f;

            if (!__instance._isPlayerInside)
            {
                fogAlpha = Mathf.InverseLerp(__instance._fogThickness + __instance._fogRolloffDistance, __instance._fogThickness, distanceFromFog);
                if (distanceFromFog < 0f)
                {
                    if (__instance.IsLockedByProbeSnapshot() || QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)__instance._visibilityTracker, true).Item1)
                    {
                        __instance._isPlayerInside = true;
                        __instance.SetSurfaceState(__instance._stateIndex);
                        Locator.GetShipLogManager().RevealFact(__instance._revealFactID);
                        GlobalMessenger.FireEvent(OWEvents.PlayerEnterQuantumMoon);
                    }
                    else
                    {
                        __instance.Collapse(true);
                    }
                }
            }
            else if (__instance._isPlayerInside)
            {
                fogAlpha = Mathf.InverseLerp(-__instance._fogThickness - __instance._fogRolloffDistance, -__instance._fogThickness, distanceFromFog);
                if (distanceFromFog >= 0f)
                {
                    if (__instance._stateIndex != 5)
                    {
                        __instance._isPlayerInside = false;
                        if (!__instance.IsLockedByProbeSnapshot() && !QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)__instance._visibilityTracker, true).Item1)
                        {
                            __instance.Collapse(true);
                        }

                        __instance.SetSurfaceState(-1);
                        GlobalMessenger.FireEvent(OWEvents.PlayerExitQuantumMoon);
                    }
                    else
                    {
                        var vector = Locator.GetPlayerTransform().position - __instance.transform.position;
                        Locator.GetPlayerBody().SetVelocity(__instance._moonBody.GetPointVelocity(Locator.GetPlayerTransform().position) - (vector.normalized * 5f));
                        var d = 80f;
                        Locator.GetPlayerBody().SetPosition(__instance.transform.position + (__instance._vortexReturnPivot.up * d));
                        if (!Physics.autoSyncTransforms)
                        {
                            Physics.SyncTransforms();
                        }

                        var component = Locator.GetPlayerCamera().GetComponent <PlayerCameraController>();
                        component.SetDegreesY(component.GetMinDegreesY());
                        __instance._vortexAudio.SetLocalVolume(0f);
                        __instance._collapseToIndex = 1;
                        __instance.Collapse(true);
                    }
                }
            }

            __instance._playerFogBubble.SetFogAlpha(fogAlpha);
            __instance._shipLandingCamFogBubble.SetFogAlpha(fogAlpha);
            return(false);
        }