示例#1
0
        internal static ScriptGroup Parse(BinaryReader reader, MapParseContext context)
        {
            return(ParseAsset(reader, context, version =>
            {
                var name = reader.ReadUInt16PrefixedAsciiString();
                var isActive = reader.ReadBooleanChecked();
                var isSubroutine = reader.ReadBooleanChecked();

                var scripts = new List <Script>();
                var groups = new List <ScriptGroup>();

                ParseAssets(reader, context, assetName =>
                {
                    switch (assetName)
                    {
                    case ScriptGroup.AssetName:
                        if (version < 3)
                        {
                            goto default;
                        }
                        groups.Add(ScriptGroup.Parse(reader, context));
                        break;

                    case Script.AssetName:
                        scripts.Add(Script.Parse(reader, context));
                        break;

                    default:
                        throw new InvalidDataException($"Unexpected asset: {assetName}");
                    }
                });

                return new ScriptGroup
                {
                    Name = name,
                    IsActive = isActive,
                    IsSubroutine = isSubroutine,
                    Scripts = scripts.ToArray(),
                    Groups = groups.ToArray()
                };
            }));
        }
示例#2
0
        internal static ScriptList Parse(BinaryReader reader, MapParseContext context)
        {
            return(ParseAsset(reader, context, version =>
            {
                if (version != 1)
                {
                    throw new InvalidDataException();
                }

                var scriptGroups = new List <ScriptGroup>();
                var scripts = new List <Script>();

                ParseAssets(reader, context, assetName =>
                {
                    switch (assetName)
                    {
                    case ScriptGroup.AssetName:
                        scriptGroups.Add(ScriptGroup.Parse(reader, context));
                        break;

                    case Script.AssetName:
                        scripts.Add(Script.Parse(reader, context));
                        break;

                    default:
                        throw new InvalidDataException($"Unexpected asset: {assetName}");
                    }
                });

                return new ScriptList
                {
                    ScriptGroups = scriptGroups.ToArray(),
                    Scripts = scripts.ToArray()
                };
            }));
        }