示例#1
0
        public void ForceInit(string path)
        {
            currentNode      = null;
            stateLocale      = I18n.DefaultLocale;
            lazyBindingLinks = new List <LazyBindingEntry>();

            // requires.lua is executed and ScriptDialogueEntryParser.PatternToActionGenerator is filled before calling ParseScript()
            LuaRuntime.Instance.BindObject("scriptLoader", this);
            LuaRuntime.Instance.UpdateExecutionContext(new ExecutionContext(ExecutionMode.Eager, DialogueActionStage.Default, false));
            InitOnlyIncludedNames();

            flowChartTree.Unfreeze();

            foreach (var locale in I18n.SupportedLocales)
            {
                stateLocale = locale;

                string localizedPath = path;
                if (locale != I18n.DefaultLocale)
                {
                    localizedPath = I18n.LocalizedResourcesPath + locale + "/" + path;
                }

                var scripts = Resources.LoadAll(localizedPath, typeof(TextAsset)).Cast <TextAsset>();
                foreach (var script in scripts)
                {
                    if (onlyIncludedNames.Count > 0 && !onlyIncludedNames.Contains(script.name))
                    {
                        continue;
                    }

#if UNITY_EDITOR
                    var scriptPath = AssetDatabase.GetAssetPath(script);
                    Debug.Log($"Nova: Parse script {scriptPath}");
#endif

                    try
                    {
                        ParseScript(script);
                    }
                    catch (ParseException e)
                    {
                        throw new ParseException($"Failed to parse {script.name}", e);
                    }
                }
            }

            // Bind all lazy binding entries
            BindAllLazyBindingEntries();

            // Perform sanity check
            flowChartTree.SanityCheck();

            // Construction finished, freeze the tree status
            flowChartTree.Freeze();
        }
示例#2
0
        public void ForceInit(string path)
        {
            flowChartTree    = new FlowChartTree();
            currentNode      = null;
            stateLocale      = I18n.DefaultLocale;
            lazyBindingLinks = new List <LazyBindingEntry>();

            // requires.lua is executed and ScriptDialogueEntryParser.PatternToActionGenerator is filled before calling ParseScript()
            LuaRuntime.Instance.BindObject("scriptLoader", this);

            foreach (var locale in I18n.SupportedLocales)
            {
                stateLocale = locale;

                string localizedPath = path;
                if (locale != I18n.DefaultLocale)
                {
                    localizedPath = I18n.LocalePath + locale + "/" + path;
                }

                var scripts = Resources.LoadAll(localizedPath, typeof(TextAsset)).Cast <TextAsset>().ToArray();
                foreach (var script in scripts)
                {
                    ParseScript(script.text);
                }
            }

            // Bind all lazy binding entries
            BindAllLazyBindingEntries();

            // Perform sanity check
            flowChartTree.SanityCheck();

            // Construction finished, freeze the tree status
            flowChartTree.Freeze();
        }