public static CommonEvent GenerateCommonEvent005()
            {
                var result = new CommonEvent
                {
                    Id            = 5,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.Auto,
                        LeftSide            = 2000004,
                        Operation           = CriteriaOperator.Above,
                        RightSide           = 10
                    },
                    NumberArgsLength = 0,
                    StrArgsLength    = 0,
                    Name             = "コモンイベント005",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        EventCommandFactory.CreateCommandString("[0][0,0]<0>()()"),
                    }),
                    Description  = "",
                    Memo         = "",
                    LabelColor   = CommonEventLabelColor.Green,
                    FooterString = "",
                };

                return(result);
            }
            public static CommonEvent GenerateCommonEvent002()
            {
                var result = new CommonEvent
                {
                    Id            = 2,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.OnlyCall,
                        LeftSide            = 2000000,
                        Operation           = CriteriaOperator.Equal,
                        RightSide           = 0
                    },
                    NumberArgsLength = 0,
                    StrArgsLength    = 0,
                    Name             = "コモンイベント002",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        EventCommandFactory.CreateCommandString(
                            "[300][10,1]<0>(0,68,128,2,127,255,1600005,1600005,1600005,1600005)(\"コモンイベント001\")"),
                        EventCommandFactory.CreateCommandString("[0][0,0]<0>()()")
                    }),
                    Description  = "",
                    Memo         = "",
                    LabelColor   = CommonEventLabelColor.Black,
                    FooterString = "",
                };

                /* ---------- 数値引数 ---------- */
                result.UpdateSpecialNumberArgDesc(0,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    /* 画面では見えないが、一度設定したことがあるためデータ内に存在する。*/
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "テスト",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Normal, null);
                    return(desc);
                }))());

                result.SelfVariableNameList[0] = "テスト";

                result.SetReturnVariableIndex(0);
                result.ReturnValueDescription = "";

                return(result);
            }
            public static CommonEvent GenerateCommonEvent007()
            {
                var result = new CommonEvent
                {
                    Id            = 7,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.ParallelAlways,
                        LeftSide            = 2000000,
                        Operation           = CriteriaOperator.Equal,
                        RightSide           = 0
                    },
                    NumberArgsLength = 1,
                    StrArgsLength    = 0,
                    Name             = "コモンイベント007",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        EventCommandFactory.CreateCommandString("[0][0,0]<0>()()"),
                    }),
                    Description  = "",
                    Memo         = "",
                    LabelColor   = CommonEventLabelColor.Black,
                    FooterString = "",
                };

                /* ---------- 数値引数 ---------- */
                result.UpdateSpecialNumberArgDesc(0,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.ReferDatabase, null);
                    desc.SetDatabaseRefer(DBKind.System, 0);
                    desc.SetDatabaseUseAdditionalItemsFlag(false);
                    return(desc);
                }))());

                result.SetReturnVariableIndex(41);
                result.ReturnValueDescription = "Return";

                return(result);
            }
        private void ReadEventCommand(BinaryReadStatus readStatus, ICollection <IEventCommand> commandList)
        {
            // 数値変数の数
            var numVarLength = readStatus.ReadByte();

            readStatus.IncreaseByteOffset();

            // 数値変数
            var numVarList = new List <int>();

            for (var i = 0; i < numVarLength; i++)
            {
                var numVar = readStatus.ReadInt();
                numVarList.Add(numVar);
                readStatus.IncreaseIntOffset();
            }

            // インデント
            var indent = (sbyte)readStatus.ReadByte();

            readStatus.IncreaseByteOffset();

            // 文字データ数
            var strVarLength = readStatus.ReadByte();

            readStatus.IncreaseByteOffset();

            // 文字列変数
            var strVarList = new List <string>();

            for (var i = 0; i < strVarLength; i++)
            {
                var woditorString = readStatus.ReadString();
                strVarList.Add(woditorString.String);
                readStatus.AddOffset(woditorString.ByteLength);
            }

            // 動作指定フラグ
            var hasMoveCommand = readStatus.ReadByte() != 0;

            readStatus.IncreaseByteOffset();

            // 動作指定コマンド
            ActionEntry actionEntry = null;

            if (hasMoveCommand)
            {
                actionEntry = new ActionEntry();
                ReadEventActionEntry(readStatus, actionEntry);
            }

            // 引数の数チェック
            if (numVarLength != numVarList.Count)
            {
                throw new InvalidOperationException(
                          "指定された数値引数の数と実際の数値引数の数が一致しません。");
            }
            if (strVarLength != strVarList.Count)
            {
                throw new InvalidOperationException(
                          "指定された文字列引数の数と実際の文字列引数の数が一致しません。");
            }

            // 結果
            var eventCommand = EventCommandFactory.CreateRaw(
                numVarList,
                indent,
                strVarList,
                actionEntry);

            commandList.Add(eventCommand);
        }
            public static CommonEvent GenerateCommonEvent006()
            {
                var result = new CommonEvent
                {
                    Id            = 6,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.ParallelAlways,
                        LeftSide            = 2000000,
                        Operation           = CriteriaOperator.Above,
                        RightSide           = 10
                    },
                    NumberArgsLength = 4,
                    StrArgsLength    = 4,
                    Name             = "コモンイベント006",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        EventCommandFactory.CreateCommandString("[0][0,0]<0>()()"),
                    }),
                    Description  = "",
                    Memo         = "",
                    LabelColor   = CommonEventLabelColor.Black,
                    FooterString = "",
                };

                /* ---------- セルフ変数名 ---------- */
                result.SelfVariableNameList[0] = "NumArg1Name";
                result.SelfVariableNameList[1] = "NumArg2Name";
                result.SelfVariableNameList[2] = "NumArg3Name";
                result.SelfVariableNameList[3] = "NumArg4Name";
                result.SelfVariableNameList[5] = "StrArg1Name";
                result.SelfVariableNameList[6] = "StrArg2Name";
                result.SelfVariableNameList[7] = "StrArg3Name";
                result.SelfVariableNameList[8] = "StrArg4Name";

                /* ---------- 数値引数 ---------- */
                result.UpdateSpecialNumberArgDesc(0,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "NumArg1Name",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Normal, null);
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(1,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "NumArg2Name",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Normal, null);
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(2,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "NumArg3Name",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Normal, null);
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(3,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "NumArg4Name",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Normal, null);
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(4,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "N",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Normal, null);
                    return(desc);
                }))());

                /* ---------- 文字列引数 ---------- */
                result.UpdateSpecialStringArgDesc(0,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "StrArg1Name"
                });
                result.UpdateSpecialStringArgDesc(1,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "StrArg2Name"
                });
                result.UpdateSpecialStringArgDesc(2,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "StrArg3Name"
                });
                result.UpdateSpecialStringArgDesc(3,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "StrArg4Name"
                });
                result.UpdateSpecialStringArgDesc(4,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "U"
                });

                result.SetReturnValueNone();

                return(result);
            }
            public static CommonEvent GenerateCommonEvent003()
            {
                var result = new CommonEvent
                {
                    Id            = 3,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.Parallel,
                        LeftSide            = 2300002,
                        Operation           = CriteriaOperator.Below,
                        RightSide           = (-13)
                    },
                    NumberArgsLength = 4,
                    StrArgsLength    = 2,
                    Name             = "コモンイベント003",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        EventCommandFactory.CreateCommandString("[210][6,0]<0>(600100,34,0,0,1600005,1600005)()"),
                        EventCommandFactory.CreateCommandString("[210][3,0]<0>(600099,16777216,1600000)()"),
                        EventCommandFactory.CreateCommandString("[0][0,0]<0>()()"),
                    }),
                    Description  = "",
                    Memo         = "Memo",
                    LabelColor   = CommonEventLabelColor.Purple,
                    FooterString = "",
                };

                /* ---------- セルフ変数名 ---------- */
                result.SelfVariableNameList[0]  = "Summary1";
                result.SelfVariableNameList[3]  = "Summary4";
                result.SelfVariableNameList[50] = "Test";
                result.SelfVariableNameList[51] = "てすと";

                /* ---------- 数値引数 ---------- */
                result.UpdateSpecialNumberArgDesc(0,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "Summary1",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Normal, null);
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(1,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "引数2",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.ReferDatabase, null);
                    desc.SetDatabaseRefer(DBKind.System, 10);
                    desc.SetDatabaseUseAdditionalItemsFlag(false);
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(2,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "引数3",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.ReferDatabase, new[]
                    {
                        new CommonEventSpecialArgCase(-1, "Value-1"),
                        new CommonEventSpecialArgCase(-2, "Value-2"),
                        new CommonEventSpecialArgCase(-3, "Value-3"),
                    });
                    desc.SetDatabaseRefer(DBKind.Changeable, 10);
                    desc.SetDatabaseUseAdditionalItemsFlag(true);
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(3,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "Summary4",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Manual, new[]
                    {
                        new CommonEventSpecialArgCase(0, "Select0"),
                        new CommonEventSpecialArgCase(1, "Select1"),
                        new CommonEventSpecialArgCase(2, "Select2"),
                        new CommonEventSpecialArgCase(3, "Select3"),
                    });
                    return(desc);
                }))());

                /* ---------- 文字列引数 ---------- */
                result.UpdateSpecialStringArgDesc(0,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = ""
                });
                result.UpdateSpecialStringArgDesc(1,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = ""
                });

                /* ---------- セルフ変数名 ---------- */
                result.SelfVariableNameList[0]  = "Summary1";
                result.SelfVariableNameList[1]  = "引数2";
                result.SelfVariableNameList[2]  = "引数3";
                result.SelfVariableNameList[3]  = "Summary4";
                result.SelfVariableNameList[50] = "Test";
                result.SelfVariableNameList[51] = "てすと";

                result.SetReturnValueNone();

                return(result);
            }
        /// <summary>
        /// イベントコマンド
        /// </summary>
        /// <param name="status">読み込み経過状態</param>
        /// <param name="commandList">データ格納先</param>
        /// <exception cref="InvalidOperationException">ファイル仕様が異なる場合</exception>
        private void ReadEventCommand(FileReadStatus status, ICollection <IEventCommand> commandList)
        {
            // 数値変数の数
            var numVarLength = status.ReadByte();

            status.IncreaseByteOffset();

            Logger.Debug(FileIOMessage.SuccessRead(typeof(EventCommandListReader),
                                                   "数値変数の数", numVarLength));

            // 数値変数
            var numVarList = new List <int>();

            for (var i = 0; i < numVarLength; i++)
            {
                var numVar = status.ReadInt();
                numVarList.Add(numVar);
                status.IncreaseIntOffset();

                Logger.Debug(FileIOMessage.SuccessRead(typeof(EventCommandListReader),
                                                       $"数値変数{i}", numVar));
            }

            // インデント
            var indent = (sbyte)status.ReadByte();

            status.IncreaseByteOffset();

            Logger.Debug(FileIOMessage.SuccessRead(typeof(EventCommandListReader),
                                                   "インデント", indent));

            // 文字データ数
            var strVarLength = status.ReadByte();

            status.IncreaseByteOffset();

            Logger.Debug(FileIOMessage.SuccessRead(typeof(EventCommandListReader),
                                                   "文字列変数の数", strVarLength));

            // 文字列変数
            var strVarList = new List <string>();

            for (var i = 0; i < strVarLength; i++)
            {
                var woditorString = status.ReadString();
                strVarList.Add(woditorString.String);
                status.AddOffset(woditorString.ByteLength);

                Logger.Debug(FileIOMessage.SuccessRead(typeof(EventCommandListReader),
                                                       $"文字列変数{i}", woditorString.String));
            }

            // 動作指定フラグ
            var hasMoveCommand = status.ReadByte() != 0;

            status.IncreaseByteOffset();

            Logger.Debug(FileIOMessage.SuccessRead(typeof(EventCommandListReader),
                                                   "動作指定フラグ", hasMoveCommand));

            // 動作指定コマンド
            ActionEntry actionEntry = null;

            if (hasMoveCommand)
            {
                actionEntry = new ActionEntry();
                ReadEventActionEntry(status, actionEntry);
            }

            // 引数の数チェック
            if (numVarLength != numVarList.Count)
            {
                throw new InvalidOperationException(
                          "指定された数値引数の数と実際の数値引数の数が一致しません。");
            }
            if (strVarLength != strVarList.Count)
            {
                throw new InvalidOperationException(
                          "指定された文字列引数の数と実際の文字列引数の数が一致しません。");
            }

            // 結果
            var eventCommand = EventCommandFactory.CreateRaw(
                numVarList,
                indent,
                strVarList,
                actionEntry);

            Logger.Debug("イベントコマンド生成成功");

            commandList.Add(eventCommand);
        }