Esempio n. 1
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;
        }
Esempio n. 2
0
        private static void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene)
        {
            DebugLog.DebugWrite($"COMPLETE SCENE LOAD ({oldScene} -> {newScene})", MessageType.Info);
            if (QSBCore.IsInMultiplayer)
            {
                WorldObjectManager.Rebuild(newScene);
            }
            var universe = InUniverse(newScene);

            OnSceneLoaded?.SafeInvoke(newScene, universe);
            if (universe)
            {
                OnUniverseSceneLoaded?.SafeInvoke(newScene);
            }
        }