void SetIsPaused(bool on)
 {
     voosEngine.SetIsRunning(!on);
 }
    IEnumerator LoadingSequence()
    {
        float t0 = Time.realtimeSinceStartup;

        loadingScreen.Show();
        yield return(new WaitForSecondsRealtime(0.5f));

        System.Action startPlaying = () =>
        {
            float t1 = Time.realtimeSinceStartup;
            loadingScreen.FadeAndHide();
            voosEngine.SetIsRunning(true);

            GameObject.FindObjectOfType <UserMain>().FadeInAudioAfterLoading();
        };

        if (!IsLoadingResources())
        {
            startPlaying();
            yield break;
        }

        loadingScreen.SetCancelButton("Start Playing Anyway", () => startPlaying());

        int totalDownloads = 1;
        int totalChunks    = 1;

        while (IsLoadingResources())
        {
            // We compute the # of total downloads in this weird and very approximate way,
            // but it's not like progress bars ever tell the truth anyway.
            // This is necessary because not all downloads may be immediately queueud.
            int downloadsRemaining = assetCache.GetNumActiveDownloads();
            totalDownloads = Mathf.Max(downloadsRemaining, totalDownloads);

            int chunksRemaining = terrain.GetNumImportantChunksRemaining();
            totalChunks = Mathf.Max(chunksRemaining, totalChunks);

            float progress = 1 - ((downloadsRemaining + chunksRemaining) * 1f / (totalDownloads + totalChunks));

            string text = "";

            if (downloadsRemaining > 0)
            {
                text += $"Loading models, {downloadsRemaining} remaining.";
            }

            if (chunksRemaining > 0)
            {
                text += $"\nGenerating terrain, {chunksRemaining} chunks remaining.";
            }

            loadingScreen.SetProgress(progress);
            loadingScreen.SetStatusText(text);

            yield return(new WaitForSecondsRealtime(0.1f));
        }

        // One last little bit to reduce chances of people falling through the
        // ground..
        yield return(new WaitForSecondsRealtime(0.5f));

        startPlaying();
    }
Beispiel #3
0
    public void SetEditMode(bool on)
    {
        if (on && !CanEdit())
        {
            AddDebugMessage("Play mode only");
            return;
        }

        SetMouseoverTooltipText("");


        if (on)
        {
            navigationControls.TryReleaseCursor();
        }

        editMode = on;

        if (editMode)
        {
        }
        else
        {
        }

        consoleAnchor.anchoredPosition = editMode ? CONSOLE_ANCHOR_POSITION_EDIT : CONSOLE_ANCHOR_POSITION_PLAY;

        userBody.SetInPlayMode(!editMode);

        AvatarMain lastAvatar = currentAvatar;

        currentAvatar = on ? editMain : playMain;

        navigationControls.SetMode(editMode ? NavigationControls.Mode.Fly : NavigationControls.Mode.Grounded);

        // Only do the teleport if:
        // 1. Going from play to edit mode for the first time
        // 2. Going from edit to play mode if there is no player actor, then DO teleport to prevent
        // us from returning to a meaningless play-mode position.
        // if (lastAvatar != null && lastAvatar != currentAvatar && ((on && firstTimeInEditMode) || GetPlayerActor() == null))
        // {
        //   currentAvatar.Teleport(lastAvatar.GetAvatarPosition(), lastAvatar.GetAim());
        // }

        bool shouldTeleport = on || Util.IsControlOrCommandHeld();

        if (lastAvatar != null && lastAvatar != currentAvatar && (shouldTeleport || GetPlayerActor() == null))
        {
            currentAvatar.Teleport(lastAvatar.GetAvatarPosition(), lastAvatar.GetAim());
        }

        //this is a hack for the conditional above to only teleport from play->edit the first time
        // if (on && firstTimeInEditMode) firstTimeInEditMode = false;

        //making user body have no parent to prevent momentary setactive(false) (which messes w/ animation)
        userBody.transform.SetParent(null);

        AddDebugMessage(editMode ? "Switching to EDIT mode" : "Switching to PLAY mode");

        playMain.Activate(!editMode);
        editMain.Activate(editMode);

        voosEngine.NotifyEditModeToggled(on);

        //putting user body on its new home
        userBody.transform.SetParent(currentAvatar.bodyParent);
        userBody.transform.localPosition = Vector3.zero;
        userBody.transform.localRotation = Quaternion.identity;

        navigationControls.ToggleEditCullingMask(on);

        if (!editMode)
        {
            navigationControls.TryCaptureCursor();
        }

        if (editMode)
        {
            hudTransitionControl.SetEditMode();
        }
        else
        {
            hudTransitionControl.SetPlayMode();
        }

        if (playerOptions.autoPause)
        {
            if (editMode)
            {
                voosEngine.SetIsRunning(false);
            }
            else
            {
                voosEngine.SetIsRunning(true);
            }
        }
    }