private void OnDisconnected(string error)
        {
            if (_intentionalDisconnect)
            {
                DebugLog.DebugWrite("intentional disconnect. dont show popup");
                _intentionalDisconnect = false;
                return;
            }

            PopupOK += () =>
            {
                if (QSBSceneManager.IsInUniverse)
                {
                    LoadManager.LoadScene(OWScene.TitleScreen, LoadManager.FadeType.ToBlack, 2f);
                }
            };

            OpenInfoPopup($"Client disconnected with error!\r\n{error}", "OK");

            SetButtonActive(DisconnectButton, false);
            SetButtonActive(ConnectButton, true);
            SetButtonActive(QuitButton, true);
            SetButtonActive(HostButton, true);
            SetButtonActive(ResumeGameButton, PlayerData.LoadLoopCount() > 1);
            SetButtonActive(NewGameButton, true);
        }
Esempio n. 2
0
 public override void OnReceiveRemote(bool server, PlayerStateMessage message)
 {
     DebugLog.DebugWrite($"Received playerstate of player ID {message.AboutId}", MessageType.Info);
     QSBCore.UnityEvents.RunWhen(
         () => QSBPlayerManager.GetSyncObject <TransformSync.TransformSync>(message.AboutId) != null,
         () => QSBPlayerManager.HandleFullStateMessage(message));
 }
        public void SetRepaired()
        {
            if (!AttachedObject._damaged)
            {
                return;
            }

            DebugLog.DebugWrite($"[SATELLITE NODE] {AttachedObject} Set repaired.");
            AttachedObject._damaged = false;
            var component = Locator.GetPlayerTransform().GetComponent <ReferenceFrameTracker>();

            if (component.GetReferenceFrame() == AttachedObject._rfVolume.GetReferenceFrame())
            {
                component.UntargetReferenceFrame();
            }

            if (AttachedObject._rfVolume != null)
            {
                AttachedObject._rfVolume.gameObject.SetActive(false);
            }

            if (AttachedObject._lanternLight != null)
            {
                AttachedObject._lanternLight.color = AttachedObject._lightRepairedColor;
            }

            if (AttachedObject._lanternEmissiveRenderer != null)
            {
                AttachedObject._lanternEmissiveRenderer.sharedMaterials.CopyTo(AttachedObject._lanternMaterials, 0);
                AttachedObject._lanternMaterials[AttachedObject._lanternMaterialIndex] = AttachedObject._lanternRepairedMaterial;
                AttachedObject._lanternEmissiveRenderer.sharedMaterials = AttachedObject._lanternMaterials;
            }

            AttachedObject.RaiseEvent(nameof(AttachedObject.OnRepaired), AttachedObject);
        }
Esempio n. 4
0
        public static void Init()
        {
            _patchList = new List <QSBPatch>
            {
                new ConversationPatches(),
                new DeathPatches(),
                new ElevatorPatches(),
                new OrbPatches(),
                new WakeUpPatches(),
                new LogPatches(),
                new QuantumVisibilityPatches(),
                new ServerQuantumPatches(),
                new ClientQuantumPatches(),
                new FrequencyPatches(),
                new SpiralPatches(),
                new QuantumPatches(),
                new ItemPatches(),
                new StatuePatches(),
                new GeyserPatches(),
                new PoolPatches(),
                new CampfirePatches(),
                new RoastingPatches()
            };

            DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
        }
Esempio n. 5
0
        public override void OnReceiveRemote(ElevatorMessage message)
        {
            DebugLog.DebugWrite($"Get ElevatorMessage {message.Direction} for {message.ObjectId}");
            var elevator = WorldRegistry.GetObject <QSBElevator>(message.ObjectId);

            elevator?.RemoteCall(message.Direction);
        }
        private void TossMarshmallow(uint playerId)
        {
            var player   = QSBPlayerManager.GetPlayer(playerId);
            var stick    = player.RoastingStick;
            var stickTip = stick.transform.GetChild(0);

            var mallowPrefab = Resources.FindObjectsOfTypeAll <RoastingStickController>().First().GetValue <GameObject>("_mallowBodyPrefab");

            var tossedMallow = Object.Instantiate(mallowPrefab, stickTip.position, stickTip.rotation);
            var rigidbody    = tossedMallow.GetComponent <OWRigidbody>();

            if (player.Campfire == null)
            {
                DebugLog.DebugWrite($"Error - Campfire for {playerId} is null.", OWML.Common.MessageType.Error);
                return;
            }
            rigidbody.SetVelocity(player.Campfire.AttachedObject.GetAttachedOWRigidbody(false).GetPointVelocity(stickTip.position) + (stickTip.forward * 3f));
            rigidbody.SetAngularVelocity(stickTip.right * 10f);
            if (player.Marshmallow == null)
            {
                DebugLog.DebugWrite($"Error - Marshmallow for {playerId} is null.", OWML.Common.MessageType.Error);
                return;
            }
            tossedMallow.GetComponentInChildren <MeshRenderer>().material.color = player.Marshmallow._burntColor;
        }
Esempio n. 7
0
 private void Handler()
 {
     foreach (var player in QSBPlayerManager.PlayerList)
     {
         DebugLog.DebugWrite($" - Sending playerstate of player ID {player.PlayerId}", MessageType.Info);
         SendEvent(CreateMessage(player));
     }
 }
Esempio n. 8
0
 private void OnWakeUp()
 {
     DebugLog.DebugWrite($"OnWakeUp", MessageType.Info);
     if (QNetworkServer.active)
     {
         QSBCore.HasWokenUp = true;
         RespawnOnDeath.Instance.Init();
     }
 }
Esempio n. 9
0
        public void ResetPlayer()
        {
            DebugLog.DebugWrite($"RESET PLAYER");
            if (_playerSpawnPoint == null)
            {
                DebugLog.ToConsole("Warning - _playerSpawnPoint is null!", MessageType.Warning);
                Init();
            }

            RespawnManager.Instance.TriggerRespawnMap();

            var inSpace = PlayerTransformSync.LocalInstance.SectorDetector.SectorList.Count == 0;

            if (inSpace)
            {
                DeathClosestAstroObject = Locator.GetAstroObject(AstroObject.Name.Sun).transform;
            }
            else
            {
                var allAstroobjects = QSBWorldSync.GetUnityObjects <AstroObject>().Where(x => x.GetAstroObjectName() != AstroObject.Name.None && x.GetAstroObjectType() != AstroObject.Type.Satellite);
                var closest         = allAstroobjects.MinBy(x => Vector3.SqrMagnitude(x.transform.position));
                DeathClosestAstroObject = closest.transform;
            }

            var deathPosition = Locator.GetPlayerTransform().position;

            _deathPositionRelative   = DeathClosestAstroObject.InverseTransformPoint(deathPosition);
            DeathPlayerUpVector      = Locator.GetPlayerTransform().up;
            DeathPlayerForwardVector = Locator.GetPlayerTransform().forward;

            var 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();

            _playerResources._isSuffocating = false;
            _playerResources.DebugRefillResources();
            _spaceSuit.RemoveSuit(true);

            foreach (var pickupVolume in _suitPickupVolumes)
            {
                if (!pickupVolume._containsSuit && pickupVolume._allowSuitReturn)
                {
                    pickupVolume._containsSuit = true;
                    pickupVolume._interactVolume.ChangePrompt(UITextType.SuitUpPrompt, pickupVolume._pickupSuitCommandIndex);
                    pickupVolume._suitGeometry.SetActive(true);
                    pickupVolume._suitOWCollider.SetActivation(true);
                    foreach (var geo in pickupVolume._toolGeometry)
                    {
                        geo.SetActive(true);
                    }
                }
            }
        }
        private void OnWakeUp()
        {
            DebugLog.DebugWrite($"OnWakeUp", MessageType.Info);
            if (QSBCore.IsHost)
            {
                RespawnOnDeath.Instance.Init();
            }

            _hasWokenUp = true;
        }
Esempio n. 11
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);
     }
 }
Esempio n. 12
0
 public static void DoUnpatchType(QSBPatchTypes type)
 {
     OnUnpatchType?.SafeInvoke(type);
     DebugLog.DebugWrite($"Unpatch block {Enum.GetName(typeof(QSBPatchTypes), type)}", MessageType.Info);
     foreach (var patch in _patchList.Where(x => x.Type == type))
     {
         DebugLog.DebugWrite($" - Unpatching in {patch.GetType().Name}", MessageType.Info);
         patch.DoUnpatches();
     }
 }
        public override void OnStopClient()
        {
            JoinLeaveSingularity.Create(Player, false);

            // TODO : Maybe move this to a leave event...? Would ensure everything could finish up before removing the player
            QSBPlayerManager.OnRemovePlayer?.Invoke(Player);
            base.OnStopClient();
            Player.HudMarker?.Remove();
            QSBPlayerManager.PlayerList.Remove(Player);
            DebugLog.DebugWrite($"Remove Player : id<{Player.PlayerId}>", MessageType.Info);
        }
        private void SetButtonActive(GameObject button, bool active)
        {
            if (button == null)
            {
                DebugLog.DebugWrite($"Warning - Tried to set button to {active}, but it was null.", OWML.Common.MessageType.Warning);
                return;
            }

            button.SetActive(active);
            button.GetComponent <CanvasGroup>().alpha = active ? 1 : 0;
        }
        public void SetDamaged()
        {
            if (AttachedObject._damaged)
            {
                return;
            }

            DebugLog.DebugWrite($"[HULL] {AttachedObject} Set damaged.");
            AttachedObject._damaged = true;
            AttachedObject.RaiseEvent(nameof(AttachedObject.OnDamaged), AttachedObject);
        }
        public override void OnStartClient()
        {
            var player = new PlayerInfo(this);

            QSBPlayerManager.PlayerList.SafeAdd(player);
            base.OnStartClient();
            QSBPlayerManager.OnAddPlayer?.Invoke(Player);
            DebugLog.DebugWrite($"Create Player : id<{Player.PlayerId}>", MessageType.Info);

            JoinLeaveSingularity.Create(Player, true);
        }
Esempio n. 17
0
 private void HandleClient(ToggleMessage message)
 {
     DebugLog.DebugWrite($"Get ready event from {message.FromId}", MessageType.Success);
     if (!QSBPlayerManager.PlayerExists(message.FromId))
     {
         DebugLog.ToConsole(
             "Error - Got ready event for non-existent player! Did we not send a PlayerStatesRequestEvent? Or was it not handled?",
             MessageType.Error);
         return;
     }
 }
Esempio n. 18
0
        public void Init()
        {
            DebugLog.DebugWrite($"INIT");
            var playerTransform = Locator.GetPlayerTransform();

            _playerResources   = playerTransform.GetComponent <PlayerResources>();
            _spaceSuit         = Locator.GetPlayerSuit();
            _playerSpawner     = FindObjectOfType <PlayerSpawner>();
            _suitPickupVolumes = FindObjectsOfType <SuitPickupVolume>();
            _fluidDetector     = Locator.GetPlayerCamera().GetComponentInChildren <FluidDetector>();
            _playerSpawnPoint  = GetSpawnPoint();
        }
Esempio n. 19
0
 private void BuildOrbs()
 {
     QSBWorldSync.OldOrbList.Clear();
     QSBWorldSync.OldOrbList = Resources.FindObjectsOfTypeAll <NomaiInterfaceOrb>().ToList();
     if (QSBCore.IsServer)
     {
         QSBWorldSync.OrbSyncList.ForEach(x => QNetworkServer.Destroy(x.gameObject));
         QSBWorldSync.OrbSyncList.Clear();
         QSBWorldSync.OldOrbList.ForEach(x => QNetworkServer.Spawn(Instantiate(QSBNetworkManager.Instance.OrbPrefab)));
     }
     DebugLog.DebugWrite($"Finished orb build with {QSBWorldSync.OldOrbList.Count} orbs.", MessageType.Success);
 }
Esempio n. 20
0
 protected override void RebuildWorldObjects(OWScene scene)
 {
     DebugLog.DebugWrite("Rebuilding OWItems...", MessageType.Warning);
     QSBWorldSync.Init <QSBScrollSocket, ScrollSocket>();
     QSBWorldSync.Init <QSBScrollItem, ScrollItem>();
     QSBWorldSync.Init <QSBSharedStoneSocket, SharedStoneSocket>();
     QSBWorldSync.Init <QSBSharedStone, SharedStone>();
     QSBWorldSync.Init <QSBWarpCoreSocket, WarpCoreSocket>();
     QSBWorldSync.Init <QSBWarpCoreItem, WarpCoreItem>();
     QSBWorldSync.Init <QSBNomaiConversationStoneSocket, NomaiConversationStoneSocket>();
     QSBWorldSync.Init <QSBNomaiConversationStone, NomaiConversationStone>();
 }
        public void ChangeIntegrity(float newIntegrity)
        {
            if (OWMath.ApproxEquals(AttachedObject._integrity, newIntegrity))
            {
                return;
            }

            DebugLog.DebugWrite($"[HULL] {AttachedObject} Change integrity to {newIntegrity}.");
            AttachedObject._integrity = newIntegrity;
            var damageEffect = AttachedObject._damageEffect;

            damageEffect.SetEffectBlend(1f - newIntegrity);
        }
Esempio n. 22
0
 private void StartPausing()
 {
     if (_state == State.Pausing)
     {
         return;
     }
     DebugLog.DebugWrite($"START PAUSING (Target:{_serverTime} Current:{Time.timeSinceLevelLoad})", MessageType.Info);
     Locator.GetActiveCamera().enabled = false;
     OWTime.SetTimeScale(0f);
     _state = State.Pausing;
     SpinnerUI.Show();
     TimeSyncUI.Start(TimeSyncType.Pausing);
 }
        public override void OnReceiveRemote()
        {
            var sector = SectorId.GetWorldObject <QSBSector>().AttachedObject;

            WorldObject.DropItem(Position, Normal, sector);

            var player = QSBPlayerManager.GetPlayer(From);

            player.HeldItem = WorldObject;

            DebugLog.DebugWrite("DROP HELD ITEM");
            player.AnimationSync.VisibleAnimator.SetTrigger("DropHeldItem");
        }
        public void RepairTick(float repairFraction)
        {
            if (OWMath.ApproxEquals(AttachedObject._repairFraction, repairFraction))
            {
                return;
            }

            DebugLog.DebugWrite($"[SATELLITE NODE] {AttachedObject} repair tick {repairFraction}");
            AttachedObject._repairFraction = repairFraction;
            var damageEffect = AttachedObject._damageEffect;

            damageEffect.SetEffectBlend(1f - repairFraction);
        }
Esempio n. 25
0
        public override void OnReceiveRemote(bool server, PlayerJoinMessage message)
        {
            if (server && (message.QSBVersion != QSBCore.QSBVersion))
            {
                DebugLog.ToConsole($"Error - Client {message.PlayerName} connecting with wrong version. (Client:{message.QSBVersion}, Server:{QSBCore.QSBVersion})", MessageType.Error);
                QSBEventManager.FireEvent(EventNames.QSBPlayerKick, message.AboutId, KickReason.VersionNotMatching);
                return;
            }
            var player = QSBPlayerManager.GetPlayer(message.AboutId);

            player.Name = message.PlayerName;
            DebugLog.ToAll($"{player.Name} joined!", MessageType.Info);
            DebugLog.DebugWrite($"{player.Name} joined as id {player.PlayerId}", MessageType.Info);
        }
        public void OnRespawn()
        {
            var currentScene = QSBSceneManager.CurrentScene;

            if (currentScene == OWScene.SolarSystem)
            {
                DebugLog.DebugWrite($"RESPAWN!");
                new ClientStateMessage(ClientState.AliveInSolarSystem).Send();
            }
            else
            {
                DebugLog.ToConsole($"Error - Player tried to respawn in scene {currentScene}", OWML.Common.MessageType.Error);
            }
        }
        public void SetRepaired()
        {
            if (!AttachedObject._damaged)
            {
                return;
            }

            DebugLog.DebugWrite($"[HULL] {AttachedObject} Set repaired.");
            AttachedObject._damaged = false;
            AttachedObject.RaiseEvent(nameof(AttachedObject.OnRepaired), AttachedObject);
            var damageEffect = AttachedObject._damageEffect;

            damageEffect.SetEffectBlend(0f);
        }
        public void Start()
        {
            _lightSourceVolume = this.GetRequiredComponentInChildren <LightSourceVolume>();
            _lightSourceVolume.LinkLightSource(this);
            _lightSourceVolume.SetVolumeActivation(FlashlightOn);
            if (_basePivot == null)
            {
                DebugLog.DebugWrite($"Error - _basePivot is null!", OWML.Common.MessageType.Error);
                return;
            }

            _baseForward  = _basePivot.forward;
            _baseRotation = _basePivot.rotation;
        }
        protected override Transform InitLocalTransform()
        {
            SectorSync.SetSectorDetector(Locator.GetPlayerSectorDetector());
            var body = Locator.GetPlayerCamera().gameObject.transform;

            Player.Camera     = Locator.GetPlayerCamera();
            Player.CameraBody = body.gameObject;

            Player.IsReady = true;
            QSBEventManager.FireEvent(EventNames.QSBPlayerReady, true);
            DebugLog.DebugWrite("PlayerCameraSync init done - Request state!");
            QSBEventManager.FireEvent(EventNames.QSBPlayerStatesRequest);

            return(body);
        }
 protected override void RebuildWorldObjects(OWScene scene)
 {
     DebugLog.DebugWrite("Rebuilding quantum objects...", MessageType.Warning);
     QSBWorldSync.Init <QSBQuantumState, QuantumState>();
     QSBWorldSync.Init <QSBSocketedQuantumObject, SocketedQuantumObject>();
     QSBWorldSync.Init <QSBMultiStateQuantumObject, MultiStateQuantumObject>();
     QSBWorldSync.Init <QSBQuantumSocket, QuantumSocket>();
     QSBWorldSync.Init <QSBQuantumShuffleObject, QuantumShuffleObject>();
     QSBWorldSync.Init <QSBQuantumMoon, QuantumMoon>();
     QSBWorldSync.Init <QSBEyeProxyQuantumMoon, EyeProxyQuantumMoon>();
     if (scene == OWScene.SolarSystem)
     {
         Shrine = Resources.FindObjectsOfTypeAll <QuantumShrine>().First();
     }
     IsReady = true;
 }