Exemple #1
0
        public static IEnumerator LoadAsync()
        {
            WaitScreen.Item item = WaitScreen.Add("Loading Multiplayer", null);
            WaitScreen.ShowImmediately();
            Main.StartSession();
            yield return(new WaitUntil(() => Main.InitialSyncCompleted));

            WaitScreen.Remove(item);
            SetLoadingComplete();
        }
Exemple #2
0
        public static IEnumerator LoadAsync()
        {
            WaitScreen.Item item = WaitScreen.Add("Loading Multiplayer", null);
            WaitScreen.ShowImmediately();
            Main.StartSession();
            yield return(new WaitUntil(() => Main.InitialSyncCompleted == true));

            PropertyInfo property = PAXTerrainController.main.GetType().GetProperty("isWorking");

            property.SetValue(PAXTerrainController.main, false, null);
            WaitScreen.Remove(item);
        }
Exemple #3
0
        private IEnumerator ProcessInitialSyncPacket(object sender, EventArgs eventArgs)
        {
            bool moreProcessorsToRun;

            do
            {
                yield return(Multiplayer.Main.StartCoroutine(RunPendingProcessors()));

                moreProcessorsToRun = (alreadyRan.Count < processors.Count);

                if (moreProcessorsToRun && processorsRanLastCycle == 0)
                {
                    throw new Exception("Detected circular dependencies in initial packet sync between: " + GetRemainingProcessorsText());
                }
            } while (moreProcessorsToRun);

            WaitScreen.Remove(loadingMultiplayerWaitItem);
            Multiplayer.Main.InitialSyncCompleted = true;
        }
Exemple #4
0
        public static IEnumerator LoadAsync()
        {
            WaitScreen.ManualWaitItem worldSettleItem = WaitScreen.Add(Language.main.Get("Nitrox_WorldSettling"));
            WaitScreen.ShowImmediately();

            yield return(new WaitUntil(() => LargeWorldStreamer.main != null &&
                                       LargeWorldStreamer.main.land != null &&
                                       LargeWorldStreamer.main.IsReady() &&
                                       LargeWorldStreamer.main.IsWorldSettled()));

            WaitScreen.Remove(worldSettleItem);

            WaitScreen.ManualWaitItem item = WaitScreen.Add(Language.main.Get("Nitrox_JoiningSession"));
            yield return(Main.StartCoroutine(Main.StartSession()));

            WaitScreen.Remove(item);

            yield return(new WaitUntil(() => Main.InitialSyncCompleted));

            SetLoadingComplete();
        }
        private IEnumerator ProcessInitialSyncPacket(object sender, EventArgs eventArgs)
        {
            // Some packets should not fire during game session join but only afterwards so that initialized/spawned game objects don't trigger packet sending again.
            using (packetSender.Suppress <PingRenamed>())
            {
                bool moreProcessorsToRun;
                do
                {
                    yield return(Multiplayer.Main.StartCoroutine(RunPendingProcessors()));

                    moreProcessorsToRun = alreadyRan.Count < processors.Count;
                    if (moreProcessorsToRun && processorsRanLastCycle == 0)
                    {
                        throw new Exception("Detected circular dependencies in initial packet sync between: " + GetRemainingProcessorsText());
                    }
                } while (moreProcessorsToRun);
            }

            WaitScreen.Remove(loadingMultiplayerWaitItem);
            Multiplayer.Main.InitialSyncCompleted = true;
        }
        private IEnumerator RunPendingProcessors()
        {
            processorsRanLastCycle = 0;

            foreach (InitialSyncProcessor processor in processors)
            {
                if (IsWaitingToRun(processor.GetType()) && HasDependenciesSatisfied(processor))
                {
                    loadingMultiplayerWaitItem.SetProgress(cumulativeProcessorsRan, processors.Count);

                    Log.Info("Running " + processor.GetType());
                    alreadyRan.Add(processor.GetType());
                    processorsRanLastCycle++;
                    cumulativeProcessorsRan++;

                    subWaitScreenItem = WaitScreen.Add("Running " + processor.GetType().Name);
                    yield return(Multiplayer.Main.StartCoroutine(processor.Process(packet, subWaitScreenItem)));

                    WaitScreen.Remove(subWaitScreenItem);
                }
            }
        }
        private static IEnumerator PreloadCustomMusic()
        {
            WaitScreen.ManualWaitItem waitItemCustomMusic = null;
            yield return(new WaitUntil(() => WaitScreen.main != null));

            waitItemCustomMusic = WaitScreen.Add("Preloading custom music ♫");

            foreach (var audioClipPath in CustomMusic.ToList())
            {
                if (audioClipPath.Value == null)
                {
                    var loadTrackTask = LoadTrack(audioClipPath.Key);
                    yield return(loadTrackTask);

                    yield return(new WaitWhile(() => loadTrackTask.GetResult() == null));

                    var audioClip = loadTrackTask.GetResult();

                    if (audioClip.AudioClip == null)
                    {
                        CustomMusic.Remove(audioClipPath.Key);
                        failedPaths.Add(audioClipPath.Key);
                    }
                    else
                    {
                        yield return(new WaitWhile(() => audioClip.AudioClip.loadState == AudioDataLoadState.Loading));

                        RegisterAudioClip(audioClipPath.Key, audioClip.AudioClip);
                    }

                    waitItemCustomMusic.SetProgress(CustomMusic.Count(x => x.Value != null), CustomMusic.Count());
                }
            }

            WaitScreen.Remove(waitItemCustomMusic);
            CustomMusicPreload = null;
        }