Esempio n. 1
0
        private static ScbFile ParseScbData(BinaryReader reader)
        {
            var assetNames = AssetNameCollection.Parse(reader);

            var result = new ScbFile();

            var context = new MapParseContext(assetNames);

            context.PushAsset(nameof(ScbFile), reader.BaseStream.Length);

            Asset.ParseAssets(reader, context, assetName =>
            {
                switch (assetName)
                {
                case ScriptImportSize.AssetName:
                    result.ScriptImportSize = ScriptImportSize.Parse(reader, context);
                    break;

                case PlayerScriptsList.AssetName:
                    result.PlayerScripts = PlayerScriptsList.Parse(reader, context);
                    break;

                case NamedCameras.AssetName:
                    result.NamedCameras = NamedCameras.Parse(reader, context);
                    break;

                case CameraAnimationList.AssetName:
                    result.CameraAnimationList = CameraAnimationList.Parse(reader, context);
                    break;

                case ScriptsPlayers.AssetName:
                    result.ScriptsPlayers = ScriptsPlayers.Parse(reader, context);
                    break;

                case ObjectsList.AssetName:
                    result.ObjectsList = ObjectsList.Parse(reader, context);
                    break;

                case PolygonTriggers.AssetName:
                    result.PolygonTriggers = PolygonTriggers.Parse(reader, context);
                    break;

                case ScriptTeams.AssetName:
                    result.Teams = ScriptTeams.Parse(reader, context);
                    break;

                case WaypointsList.AssetName:
                    result.WaypointsList = WaypointsList.Parse(reader, context);
                    break;

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

            context.PopAsset();

            return(result);
        }