Esempio n. 1
0
 private MapScriptGroup(ScriptGroup scriptGroup)
 {
     Name          = scriptGroup.Name;
     _scripts      = MapScript.Create(scriptGroup.Scripts);
     IsActive      = scriptGroup.IsActive;
     _isSubroutine = scriptGroup.IsSubroutine;
 }
Esempio n. 2
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()
                };
            }));
        }
Esempio n. 3
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()
                };
            }));
        }