<commit_before>using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using OwrBase.Exception;

namespace OwrBase.Scene {
    using OwrBase.EventMessage;

    public class SceneService
    {



        /*
            Properties
        */

        private static List<string> scenes = new List<string>();

        private static MonoBehaviour this_behaviour;

        private const string first_scene_name = SceneName.bootStrap;

        private const string loading_scene_name = SceneName.loading;

        static string[] keep_one_object_tags;

        static Camera main_camera;

        static Light directonal_light;

        public static SceneTransition transition_scene_data;


        /*
            Foundation
        */

        public static void init(MonoBehaviour base_behaviour, string[] tags)
        {
            this_behaviour = base_behaviour;
            keep_one_object_tags = tags;

            scenes.Clear();
            scenes.Add(first_scene_name);
        }



        /*
            Modules
        */

        public static void load(SceneTransition next_scene)
        {
            if (-1 < scenes.BinarySearch(next_scene.scene_name)) {
                throw new SceneDoubleLoadException();
            }

            transition_scene_data = next_scene;
            this_behaviour.StartCoroutine(sceneLoader(next_scene.scene_name));
            //scenes.Add(scene_name);
        }

        public static void change(SceneTransition next_scene)
        {
            if (-1 < scenes.BinarySearch(next_scene.scene_name))
            {
                /*
                foreach(string s in scenes) {
                    Debug.Log("s: " + s);
                }
                */
                throw new SceneDoubleLoadException();
            }

            string current_scene = scenes.Last();

            if (current_scene == next_scene.scene_name) {
                throw new CurrentSceneDoubleLoadException();
            }

            if (first_scene_name != current_scene) {
                this_behaviour.StartCoroutine(sceneUnLoader(current_scene));
            }

            transition_scene_data = next_scene;
            this_behaviour.StartCoroutine(sceneLoader(next_scene.scene_name));
        }



        /*
            Utilities
        */

        static IEnumerator<AsyncOperation> sceneLoader(string scene_name)
        {
            SceneManager.LoadScene(loading_scene_name, LoadSceneMode.Additive);
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(loading_scene_name));

            yield return SceneManager.LoadSceneAsync(scene_name, LoadSceneMode.Additive);
            keepOne(scene_name);
            scenes.Add(scene_name);
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(scene_name));

            //Debug.Log("scenes.Add(scene_name): " + scene_name);
            SceneManager.UnloadSceneAsync(loading_scene_name);
        }

        static IEnumerator<AsyncOperation> sceneUnLoader(string scene_name)
        {
            yield return SceneManager.UnloadSceneAsync(scene_name);
            scenes.Remove(scene_name);
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(scenes.Last()));
            //Debug.Log("scenes.Remove(scene_name): " + scene_name);
        }


<commit_msg>Revert "Revert "[update] Display loading scene.""<commit_after>using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using OwrBase.Exception;

namespace OwrBase.Scene {
    using OwrBase.EventMessage;

    public class SceneService
    {



        /*
            Properties
        */

        private static List<string> scenes = new List<string>();

        private static MonoBehaviour this_behaviour;

        private const string first_scene_name = SceneName.bootStrap;

        private const string loading_scene_name = SceneName.loading;

        static string[] keep_one_object_tags;

        static Camera main_camera;

        static Light directonal_light;

        public static SceneTransition transition_scene_data;


        /*
            Foundation
        */

        public static void init(MonoBehaviour base_behaviour, string[] tags)
        {
            this_behaviour = base_behaviour;
            keep_one_object_tags = tags;

            scenes.Clear();
            scenes.Add(first_scene_name);
        }



        /*
            Modules
        */

        public static void load(SceneTransition next_scene)
        {
            if (-1 < scenes.BinarySearch(next_scene.scene_name)) {
                throw new SceneDoubleLoadException();
            }

            transition_scene_data = next_scene;
            this_behaviour.StartCoroutine(sceneLoader(next_scene.scene_name));
            //scenes.Add(scene_name);
        }

        public static void change(SceneTransition next_scene)
        {
            if (-1 < scenes.BinarySearch(next_scene.scene_name))
            {
                /*
                foreach(string s in scenes) {
                    Debug.Log("s: " + s);
                }
                */
                throw new SceneDoubleLoadException();
            }

            string current_scene = scenes.Last();

            if (current_scene == next_scene.scene_name) {
                throw new CurrentSceneDoubleLoadException();
            }

            if (first_scene_name != current_scene) {
                this_behaviour.StartCoroutine(sceneUnLoader(current_scene));
            }

            transition_scene_data = next_scene;
            this_behaviour.StartCoroutine(sceneLoader(next_scene.scene_name));
        }



        /*
            Utilities
        */

        static IEnumerator<AsyncOperation> sceneLoader(string scene_name)
        {
            yield return SceneManager.LoadSceneAsync(loading_scene_name, LoadSceneMode.Additive);
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(loading_scene_name));

            yield return SceneManager.LoadSceneAsync(scene_name, LoadSceneMode.Additive);
            keepOne(scene_name);
            scenes.Add(scene_name);
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(scene_name));

            //Debug.Log("scenes.Add(scene_name): " + scene_name);
            SceneManager.UnloadSceneAsync(loading_scene_name);
        }

        static IEnumerator<AsyncOperation> sceneUnLoader(string scene_name)
        {
            yield return SceneManager.UnloadSceneAsync(scene_name);
            scenes.Remove(scene_name);
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(scenes.Last()));
            //Debug.Log("scenes.Remove(scene_name): " + scene_name);
        }



{'fraction_non_alphanumeric': 0.08028874484384207, 'fraction_numerical': 0.0005892751915144372, 'mean_word_length': 2.018674966651845, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1350119', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1717, 'n_words': 297}