Exemplo n.º 1
0
        public override void OnStopClient()         // Called on the client when closing connection
        {
            DebugLog.DebugWrite("OnStopClient", MessageType.Info);
            DebugLog.ToConsole("Disconnecting from server...", MessageType.Info);
            Destroy(GetComponent <RespawnOnDeath>());
            QSBEventManager.Reset();
            QSBPlayerManager.PlayerList.ForEach(player => player.HudMarker?.Remove());

            RemoveWorldObjects();
            QSBWorldSync.OrbSyncList.Clear();
            QSBWorldSync.OldDialogueTrees.Clear();

            if (_everConnected)
            {
                var specificType = QNetworkServer.active ? QSBPatchTypes.OnServerClientConnect : QSBPatchTypes.OnNonServerClientConnect;
                QSBPatchManager.DoUnpatchType(specificType);
                QSBPatchManager.DoUnpatchType(QSBPatchTypes.OnClientConnect);
            }

            _lobby.CanEditName = true;
            QSBCore.HasWokenUp = false;

            IsReady        = false;
            _everConnected = false;
        }
Exemplo n.º 2
0
        public override void OnClientConnect(QNetworkConnection connection)         // Called on the client when connecting to a server
        {
            DebugLog.DebugWrite("OnClientConnect", MessageType.Info);
            base.OnClientConnect(connection);

            QSBEventManager.Init();

            gameObject.AddComponent <RespawnOnDeath>();

            if (QSBSceneManager.IsInUniverse)
            {
                WorldObjectManager.Rebuild(QSBSceneManager.CurrentScene);
            }

            var specificType = QNetworkServer.active ? QSBPatchTypes.OnServerClientConnect : QSBPatchTypes.OnNonServerClientConnect;

            QSBPatchManager.DoPatchType(specificType);
            QSBPatchManager.DoPatchType(QSBPatchTypes.OnClientConnect);

            _lobby.CanEditName = false;

            OnNetworkManagerReady?.SafeInvoke();
            IsReady = true;

            QSBCore.UnityEvents.RunWhen(() => QSBEventManager.Ready && PlayerTransformSync.LocalInstance != null,
                                        () => QSBEventManager.FireEvent(EventNames.QSBPlayerJoin, _lobby.PlayerName));

            if (!QSBCore.IsServer)
            {
                QSBCore.UnityEvents.RunWhen(() => QSBEventManager.Ready && PlayerTransformSync.LocalInstance != null,
                                            () => QSBEventManager.FireEvent(EventNames.QSBPlayerStatesRequest));
            }

            _everConnected = true;
        }
Exemplo n.º 3
0
        public static bool Shuffle_ChangeQuantumState(
            QuantumShuffleObject __instance,
            ref List <int> ____indexList,
            ref Vector3[] ____localPositions,
            ref Transform[] ____shuffledObjects,
            ref bool __result)
        {
            var shuffleWorldObject = QSBWorldSync.GetWorldFromUnity <QSBQuantumShuffleObject, QuantumShuffleObject>(__instance);

            if (shuffleWorldObject.ControllingPlayer != QSBPlayerManager.LocalPlayerId)
            {
                return(false);
            }

            ____indexList.Clear();
            ____indexList = Enumerable.Range(0, ____localPositions.Length).ToList();
            for (var i = 0; i < ____indexList.Count; ++i)
            {
                var random = UnityEngine.Random.Range(i, ____indexList.Count);
                var temp   = ____indexList[i];
                ____indexList[i]      = ____indexList[random];
                ____indexList[random] = temp;
            }
            for (var j = 0; j < ____shuffledObjects.Length; j++)
            {
                ____shuffledObjects[j].localPosition = ____localPositions[____indexList[j]];
            }
            QSBEventManager.FireEvent(
                EventNames.QSBQuantumShuffle,
                shuffleWorldObject.ObjectId,
                ____indexList.ToArray());
            __result = true;
            return(false);
        }
Exemplo n.º 4
0
 public void SwitchTo3rdPerson()
 {
     if (!IsSetUp)
     {
         DebugLog.ToConsole("Warning - Camera not set up!", MessageType.Warning);
         OWInput.ChangeInputMode(InputMode.None);
         Mode = CameraMode.ThirdPerson;
         return;
     }
     if (Mode == CameraMode.ThirdPerson)
     {
         DebugLog.ToConsole("Warning - Already in 3rd person!", MessageType.Warning);
         return;
     }
     if (OWInput.GetInputMode() != InputMode.Character)
     {
         DebugLog.ToConsole("Warning - Cannot change to 3rd person while not in Character inputmode!", MessageType.Warning);
         return;
     }
     OWInput.ChangeInputMode(InputMode.None);
     QSBEventManager.FireEvent("SwitchActiveCamera", _owCamera);
     Locator.GetPlayerCamera().mainCamera.enabled = false;
     if (_cameraObj.GetComponent <PostProcessingBehaviour>() == null)
     {
         var postProcessing = _cameraObj.AddComponent <PostProcessingBehaviour>();
         postProcessing.profile = Locator.GetPlayerCamera().gameObject.GetComponent <PostProcessingBehaviour>().profile;
     }
     _camera.enabled = true;
     Mode            = CameraMode.ThirdPerson;
 }
        private void OnDisable(Shape s)
        {
            if (!IsEnabled)
            {
                return;
            }
            if (GetAttachedShapes().Any(x => x.gameObject.activeInHierarchy))
            {
                return;
            }
            IsEnabled = false;
            if (!QSBCore.HasWokenUp && !QSBCore.IsServer)
            {
                return;
            }
            if (ControllingPlayer != QSBPlayerManager.LocalPlayerId)
            {
                // not being controlled by us, don't care if we leave area
                return;
            }
            var id = QSBWorldSync.GetIdFromTypeSubset <IQSBQuantumObject>(this);

            // send event to other players that we're releasing authority
            QSBEventManager.FireEvent(EventNames.QSBQuantumAuthority, id, 0u);
        }
Exemplo n.º 6
0
 private void HandleEvent(bool state)
 {
     if (QNetworkServer.active)
     {
         QSBEventManager.FireEvent(EventNames.QSBGeyserState, ObjectId, state);
     }
 }
Exemplo n.º 7
0
        public static void Socketed_MoveToSocket(SocketedQuantumObject __instance, QuantumSocket socket)
        {
            if (socket == null)
            {
                DebugLog.ToConsole($"Error - Trying to move {__instance.name} to a null socket!", MessageType.Error);
                return;
            }
            var objectWorldObject = QSBWorldSync.GetWorldFromUnity <QSBSocketedQuantumObject, SocketedQuantumObject>(__instance);
            var socketWorldObject = QSBWorldSync.GetWorldFromUnity <QSBQuantumSocket, QuantumSocket>(socket);

            if (objectWorldObject == null)
            {
                DebugLog.ToConsole($"Worldobject is null for {__instance.name}!");
                return;
            }

            if (objectWorldObject.ControllingPlayer != QSBPlayerManager.LocalPlayerId)
            {
                return;
            }

            QSBEventManager.FireEvent(
                EventNames.QSBSocketStateChange,
                objectWorldObject.ObjectId,
                socketWorldObject.ObjectId,
                __instance.transform.localRotation);
        }
Exemplo n.º 8
0
        public static bool ItemTool_MoveItemToCarrySocket(OWItem item)
        {
            var itemId = QSBWorldSync.GetIdFromTypeSubset(ItemManager.GetObject(item));

            QSBEventManager.FireEvent(EventNames.QSBMoveToCarry, itemId);
            return(true);
        }
        public static void StartLift(Elevator __instance)
        {
            var isGoingUp = __instance.GetValue <bool>("_goingToTheEnd");
            var id        = QSBWorldSync.GetIdFromUnity <QSBElevator, Elevator>(__instance);

            QSBEventManager.FireEvent(EventNames.QSBStartLift, id, isGoingUp);
        }
        private void Update()
        {
            if (!QSBCore.IsInMultiplayer)
            {
                return;
            }
            var controller = Locator.GetPlayerController();

            if (controller == null)
            {
                return;
            }
            var collidingQuantumObject = controller.GetValue <QuantumObject>("_collidingQuantumObject");

            if (_previousCollidingQuantumObject != collidingQuantumObject)
            {
                var objectIndex = (collidingQuantumObject != null)
                                        ? QSBWorldSync.GetIdFromTypeSubset(QuantumManager.GetObject(collidingQuantumObject))
                                        : -1;

                QSBEventManager.FireEvent(
                    EventNames.QSBPlayerEntangle,
                    objectIndex);
                _previousCollidingQuantumObject = collidingQuantumObject;
            }
        }
 private void OnSocketableRemoved(OWItem socketable)
 {
     if (_wasLocalInBounds)
     {
         QSBEventManager.FireEvent(EventNames.QSBExitPlatform, CustomPlatformList.IndexOf(this));
     }
     if (_slavePlatform == null)
     {
         return;
     }
     DisconnectCamera();
     _transitionStone.SetActive(false);
     _slavePlatform._transitionStone.SetActive(false);
     _socket.GetPedestalAnimator().PlayOpen();
     if (_transitionPedestalAnimator != null)
     {
         _transitionPedestalAnimator.PlayOpen();
     }
     if (_slavePlatform._pedestalAnimator != null)
     {
         _slavePlatform._pedestalAnimator.PlayOpen();
     }
     if (_slavePlatform._transitionPedestalAnimator != null)
     {
         _slavePlatform._transitionPedestalAnimator.PlayOpen();
     }
     _sharedStone      = null;
     _platformActive   = false;
     _wasLocalInBounds = false;
 }
Exemplo n.º 12
0
        public static bool ItemTool_CompleteUnsocketItem(OWItem ____heldItem)
        {
            var itemId = QSBWorldSync.GetIdFromTypeSubset(ItemManager.GetObject(____heldItem));

            QSBEventManager.FireEvent(EventNames.QSBSocketItem, 0, itemId, SocketEventType.CompleteUnsocket);
            return(true);
        }
Exemplo n.º 13
0
        public static bool ItemTool_StartUnsocketItem(OWItemSocket socket)
        {
            var socketId = QSBWorldSync.GetIdFromTypeSubset(ItemManager.GetObject(socket));

            QSBEventManager.FireEvent(EventNames.QSBSocketItem, socketId, 0, SocketEventType.StartUnsocket);
            return(true);
        }
 private void OnLeaveBounds()
 {
     DisconnectCamera();
     QSBEventManager.FireEvent(EventNames.QSBExitPlatform, CustomPlatformList.IndexOf(this));
     if (_anyoneStillOnPlatform)
     {
         return;
     }
     _platformActive = false;
     if (_pedestalAnimator != null)
     {
         _pedestalAnimator.PlayOpen();
     }
     if (_transitionPedestalAnimator != null)
     {
         _transitionPedestalAnimator.PlayOpen();
     }
     if (_slavePlatform != null)
     {
         if (_slavePlatform._pedestalAnimator != null)
         {
             _slavePlatform._pedestalAnimator.PlayOpen();
         }
         if (_slavePlatform._transitionPedestalAnimator != null)
         {
             _slavePlatform._transitionPedestalAnimator.PlayOpen();
         }
     }
 }
 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);
 }
 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);
     }
 }
Exemplo n.º 17
0
        public void CheckUnreferencedEvents()
        {
            var qsbAssembly   = Assembly.Load("QSB");
            var allEventTypes = qsbAssembly
                                .GetTypes()
                                .Where(x => typeof(IQSBEvent).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract);

            QSBEventManager.Init();
            var eventInstances = (List <IQSBEvent>) typeof(QSBEventManager)
                                 .GetField("_eventList", BindingFlags.NonPublic | BindingFlags.Static)
                                 .GetValue(typeof(QSBEventManager));

            var failedTypes = new List <Type>();

            foreach (var type in allEventTypes)
            {
                if (!eventInstances.Any(x => x.GetType() == type))
                {
                    failedTypes.Add(type);
                }
            }

            if (failedTypes.Count > 0)
            {
                Assert.Fail(string.Join(", ", failedTypes.Select(x => x.Name)));
            }
        }
Exemplo n.º 18
0
 public static void StartDragCallEvent(bool __result, NomaiInterfaceOrb __instance)
 {
     if (__result)
     {
         QSBEventManager.FireEvent(EventNames.QSBOrbUser, QSBWorldSync.OldOrbList.FindIndex(x => x == __instance));
     }
 }
Exemplo n.º 19
0
 public void HandleEvent(bool state, int orbId)
 {
     if (!QSBCore.HasWokenUp)
     {
         return;
     }
     QSBEventManager.FireEvent(EventNames.QSBOrbSlot, ObjectId, orbId, state);
 }
Exemplo n.º 20
0
 public static void RevealFact(string id, bool saveGame, bool showNotification, bool __result)
 {
     if (!__result)
     {
         return;
     }
     QSBEventManager.FireEvent(EventNames.QSBRevealFact, id, saveGame, showNotification);
 }
        public override void OnReceiveRemote(bool server, EnumMessage <SignalName> message)
        {
            PlayerData.LearnSignal(message.EnumValue);
            QSBEventManager.FireEvent("IdentifySignal");
            var displayMsg = $"{UITextLibrary.GetString(UITextType.NotificationSignalIdentified)} <color=orange>{AudioSignal.SignalNameToString(message.EnumValue)}</color>";
            var data       = new NotificationData(NotificationTarget.All, displayMsg, 10f, true);

            NotificationManager.SharedInstance.PostNotification(data, false);
        }
 public void SendConvState(int charId, bool state)
 {
     if (charId == -1)
     {
         DebugLog.ToConsole("Warning - Tried to send conv. start/end event with char id -1.", MessageType.Warning);
         return;
     }
     QSBEventManager.FireEvent(EventNames.QSBConversationStartEnd, charId, QSBPlayerManager.LocalPlayerId, state);
 }
 public void SendCharacterDialogue(int id, string text)
 {
     if (id == -1)
     {
         DebugLog.ToConsole("Warning - Tried to send conv. event with char id -1.", MessageType.Warning);
         return;
     }
     QSBEventManager.FireEvent(EventNames.QSBConversation, (uint)id, text, ConversationType.Character);
 }
        public override void OnReceiveRemote(bool server, QuantumAuthorityMessage message)
        {
            var obj = QSBWorldSync.GetWorldFromId <IQSBQuantumObject>(message.ObjectId);

            obj.ControllingPlayer = message.AuthorityOwner;
            if (obj.ControllingPlayer == 0 && obj.IsEnabled)
            {
                // object has no owner, but is still active for this player. request ownership
                QSBEventManager.FireEvent(EventNames.QSBQuantumAuthority, message.ObjectId, QSBPlayerManager.LocalPlayerId);
            }
        }
Exemplo n.º 25
0
 public static bool Marshmallow_Shrivel(
     ref Marshmallow.MallowState ____mallowState,
     ref float ____initShrivelTime)
 {
     if (____mallowState == Marshmallow.MallowState.Burning)
     {
         ____initShrivelTime = Time.time;
         ____mallowState     = Marshmallow.MallowState.Shriveling;
         QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Shrivel);
     }
     return(false);
 }
Exemplo n.º 26
0
        public override void OnStopServer()
        {
            DebugLog.DebugWrite("OnStopServer", MessageType.Info);
            Destroy(GetComponent <RespawnOnDeath>());
            QSBEventManager.Reset();
            DebugLog.ToConsole("Server stopped!", MessageType.Info);
            QSBPlayerManager.PlayerList.ForEach(player => player.HudMarker?.Remove());

            QSBCore.HasWokenUp = false;

            base.OnStopServer();
        }
Exemplo n.º 27
0
 public static bool Wall_SetAsTranslated(NomaiWallText __instance, int id)
 {
     if (__instance.IsTranslated(id))
     {
         return(true);
     }
     QSBEventManager.FireEvent(
         EventNames.QSBTextTranslated,
         NomaiTextType.WallText,
         QSBWorldSync.GetIdFromUnity <QSBWallText, NomaiWallText>(__instance),
         id);
     return(true);
 }
Exemplo n.º 28
0
 public static bool VesselComputer_SetAsTranslated(NomaiVesselComputer __instance, int id)
 {
     if (__instance.IsTranslated(id))
     {
         return(true);
     }
     QSBEventManager.FireEvent(
         EventNames.QSBTextTranslated,
         NomaiTextType.VesselComputer,
         QSBWorldSync.GetIdFromUnity <QSBVesselComputer, NomaiVesselComputer>(__instance),
         id);
     return(true);
 }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
0
 private void Init()
 {
     QSBEventManager.FireEvent(EventNames.QSBPlayerStatesRequest);
     _state = State.Loaded;
     gameObject.AddComponent <PreserveTimeScale>();
     if (IsServer)
     {
         SendServerTime();
     }
     else
     {
         WakeUpOrSleep();
     }
 }