Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:UnityNRuntime"/> class.
        /// </summary>
        /// <param name="assets">スクリプト アセット。</param>
        /// <param name="errorCommand">エラー時の出力に使用するNovel コマンド。</param>
        public UnityNRuntime(IEnumerable <TextAsset> assets, UnityNCommand errorCommand)
        {
            commands = new Dictionary <string, UnityNCommand>();
            // combined text asset
            Reload(assets);
            outErr     = errorCommand;
            goSubStack = new Stack <int>();

            #region 組み込みコマンド登録
            commands["goto"]   = Goto;
            commands["debug"]  = Debug;
            commands["wait"]   = Wait;
            commands["end"]    = End;
            commands["gosub"]  = Gosub;
            commands["return"] = Return;
            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Novel コマンドの登録を行います.
        /// </summary>
        /// <returns>このインスタンスをそのまま返します.これによってメソッドチェーンが可能です.</returns>
        /// <param name="name">Name.</param>
        /// <param name="command">Command.</param>
        public UnityNRuntime Register(string name, UnityNCommand command)
        {
            // 申し訳ないが重複はNG.
            if (commands.ContainsKey(name))
            {
                throw new ArgumentException($"The command name {name} is duplicated.");
            }
            #region NullCheck
            NullCheck(name);
            NullCheck(command);
            // 通る場合,それは通常ならありえない挙動.クラスのバグか,リフレクション等の不正アクセス,またはランタイムのバグ.
            if (commands == null)
            {
                throw new InvalidOperationException("bug: Command Dictionary is null");
            }
            #endregion

            commands.Add(name, command);

            return(this);
        }