private IEnumerator OnStartSceneLoadAsync(AsyncOperation sceneLoadOperation, TCScene scene)
        {
            //Check to make sure that we aren't already loading, that LoadingScreenManager is setup, and that we aren't quitting
            if (sceneLoadOperation == null || IsLoading || !isSetup || Game.IsGameQuitting || scene == null)
            {
                yield break;
            }

            IsLoading = true;

            //Create LoadingScreenUI and set it up
            LoadingScreenUI loadingScreenUI =
                Instantiate(loadingScenePrefab).GetComponent <LoadingScreenUI>();

            loadingScreenUI.Setup(scene);

            //While we are loading, set the progress bar to sceneLoadOperation progress
            // ReSharper disable once PossibleNullReferenceException
            while (!sceneLoadOperation.isDone)
            {
                loadingScreenUI.SetLoadingBarAmount(Mathf.Clamp01(sceneLoadOperation.progress / .9f));

                yield return(null);
            }

            //We are done, no need to destroy loadingScreenUI as it will automatically be done by changing scenes
            IsLoading = false;
        }
Пример #2
0
        /// <summary>
        ///		Sets up the loading screen
        /// </summary>
        /// <param name="scene"></param>
        public void Setup(TCScene scene)
        {
            if (scene.loadingScreenBackgroundImage != null)
            {
                backgroundImage.texture = scene.loadingScreenBackgroundImage;
            }

            mapTex.text = scene.DisplayNameLocalized;
        }
Пример #3
0
        private void Start()
        {
            scene = nextScene.LoadAssetAsync <TCScene>().WaitForCompletion();

            if (skipVideo)
            {
                ChangeScene();
                return;
            }

            videoClip = startUpVideoClip.LoadAssetAsync <VideoClip>().WaitForCompletion();

            InputReader.StartVideoSkip += SkipStartVideo;
            InputReader.EnableStartVideoInput();
            Play();
        }
        private void SceneLoaded(TCScene scene)
        {
            if (client != null)
            {
                Activity presence = new()
                {
                    Assets = new ActivityAssets
                    {
                        LargeImage = scene.largeImageKey,
                        LargeText  = scene.LargeImageKeyText
                    }
                };

                if (scene.showStartTime)
                {
                    presence.Timestamps = new ActivityTimestamps
                    {
                        Start = TimeHelper.UnixTimeNow()
                    }
                }
                ;

                if (scene.isOnlineScene)
                {
                    presence.Details = TCScenesManager.GetActiveScene().DisplayNameLocalized;
                    presence.State   = "Team Capture";
                }
                else if (scene.isMainMenu)
                {
                    presence.Details = "Main Menu";
                }
                else if (!scene.isMainMenu && !scene.isOnlineScene)
                {
                    presence.Details = "Loading...";
                }
                else
                {
                    Logger.Error("You CANNOT have an online scene and a main menu scene!");
                }

                UpdateActivity(presence);
            }
        }

        #endregion
    }
}
Пример #5
0
 private void PreparingSceneLoad(TCScene scene)
 {
     //Update our RPC to show we are loading
     if (client != null)
     {
         UpdateActivity(new Activity
         {
             Assets = new ActivityAssets
             {
                 LargeImage = scene.largeImageKey,
                 LargeText  = scene.LargeImageKeyTextLocalized
             },
             Details = $"Loading into {scene.DisplayNameLocalized}",
             State   = "Loading..."
         });
     }
 }
Пример #6
0
        public static void StartServerCommand(string[] args)
        {
            NetworkManager networkManager = NetworkManager.singleton;
            string         scene          = args[0];
            TCScene        tcScene        = TCScenesManager.FindSceneInfo(scene);

            if (tcScene == null)
            {
                Logger.Error("That scene doesn't exist!");
                return;
            }

            Scene = tcScene.SceneFileName;
            networkManager.onlineScene = tcScene.scene;

            networkManager.StartServer();
        }
Пример #7
0
        private void Setup()
        {
            scene = TCScenesManager.GetActiveScene();
            if (scene == null)
            {
                Logger.Error("The scene '{@Scene}' doesn't have a TCScene assigned to it!",
                             SceneManager.GetActiveScene().name);
                return;
            }

            sceneCamera = GameObject.FindWithTag(SceneCameraTag);
            if (sceneCamera == null)
            {
                Logger.Error(
                    "The scene {@Scene} doesn't have a Camera with the tag `{@SceneCameraTag}` assigned to it!",
                    scene.scene, SceneCameraTag);
            }
        }
 private void OnScenePreparingToLoad(TCScene scene)
 {
     uImGui.enabled = false;
 }
 private void OnSceneLoaded(TCScene scene)
 {
     SetInstanceCamera(FindMainCamera());
     StartCoroutine(AfterSceneLoad());
 }
Пример #10
0
 private void OnDestroy()
 {
     scene = null;
 }
        public override void OnBoot()
        {
            TCScene scene = sceneToLoadTo.LoadAssetAsync <TCScene>().WaitForCompletion();

            TCScenesManager.LoadScene(scene);
        }
Пример #12
0
        /// <summary>
        ///     Call this when the server is started
        /// </summary>
        internal static void OnStartServer(TCNetworkManager workingNetManager)
        {
            serverOnlineFilePath = $"{Game.GetGameExecutePath()}/{ServerOnlineFile}";

            if (File.Exists(serverOnlineFilePath))
            {
                throw new Exception("Server is already online!");
            }

            netManager = workingNetManager;

            Logger.Info("Starting server...");

            //Get the online scene
            TCScene onlineScene = TCScenesManager.FindSceneInfo(Scene);

            if (onlineScene == null)
            {
                Logger.Error($"Failed to find scene {Scene}!");
                throw new FileNotFoundException($"Scene {Scene} not found!");
            }

            //Setup the server's config
            SetupServerConfig();
            Application.targetFrameRate = netManager.serverTickRate;

            //Make some adjustments to scenes config if we are running headless
            if (Game.IsHeadless)
            {
                netManager.offlineScene = null;
                netManager.onlineScene  = onlineScene.scene;
                TCScenesManager.LoadScene(onlineScene);
            }

            //Set what network address to use and start to advertise the server on lan
            netManager.networkAddress = NetHelper.LocalIpAddress();
            netManager.gameDiscovery.AdvertiseServer();

            //Setup ping related stuff
            PingManager.ServerSetup();
            LagCompensationManager.ServerSetup();

            //Run the server autoexec config
            ConsoleBackend.ExecuteFile("server-autoexec");

            //Server chat
            NetworkServer.RegisterHandler <ChatMessage>(ServerChat.ReceivedChatMessage);

            //Create server online file
            try
            {
                serverOnlineFileStream = File.Create(serverOnlineFilePath, 128, FileOptions.DeleteOnClose);
                serverOnlineFileStream.Write(ServerOnlineFileMessage, 0, ServerOnlineFileMessage.Length);
                serverOnlineFileStream.Flush();
                File.SetAttributes(serverOnlineFilePath, FileAttributes.Hidden);
            }
            catch (IOException ex)
            {
                Logger.Error(ex, "An error occurred while setting up the server!");
                netManager.StopHost();

                return;
            }

            Logger.Info("Server has started and is running on '{Address}' with max connections of {MaxPlayers}!",
                        netManager.networkAddress, netManager.maxConnections);
        }