public override void OnClientConnect() // Called on the client when connecting to a server { DebugLog.DebugWrite("OnClientConnect", MessageType.Info); base.OnClientConnect(); OnClientConnected?.SafeInvoke(); QSBMessageManager.Init(); gameObject.AddComponent <RespawnOnDeath>(); gameObject.AddComponent <ServerStateManager>(); gameObject.AddComponent <ClientStateManager>(); if (QSBSceneManager.IsInUniverse) { QSBWorldSync.BuildWorldObjects(QSBSceneManager.CurrentScene).Forget(); } var specificType = QSBCore.IsHost ? QSBPatchTypes.OnServerClientConnect : QSBPatchTypes.OnNonServerClientConnect; QSBPatchManager.DoPatchType(specificType); QSBPatchManager.DoPatchType(QSBPatchTypes.OnClientConnect); Delay.RunWhen(() => PlayerTransformSync.LocalInstance, () => new PlayerJoinMessage(PlayerName).Send()); if (!QSBCore.IsHost) { Delay.RunWhen(() => PlayerTransformSync.LocalInstance, () => new RequestStateResyncMessage().Send()); } _everConnected = true; }
private static void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene) { DebugLog.DebugWrite($"COMPLETE SCENE LOAD ({oldScene} -> {newScene})", MessageType.Info); QSBWorldSync.RemoveWorldObjects(); var universe = InUniverse(newScene); if (QSBCore.IsInMultiplayer && universe) { // So objects have time to be deleted, made, whatever Delay.RunNextFrame(() => QSBWorldSync.BuildWorldObjects(newScene).Forget()); } OnSceneLoaded?.SafeInvoke(oldScene, newScene, universe); if (universe) { OnUniverseSceneLoaded?.SafeInvoke(oldScene, newScene); } if (newScene == OWScene.TitleScreen && QSBCore.IsInMultiplayer) { QSBNetworkManager.singleton.StopHost(); } }