コード例 #1
0
        private void WriteMapDataTo(BinaryWriter writer, AssetNameCollection assetNames)
        {
            if (AssetList != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(AssetList.AssetName));
                AssetList.WriteTo(writer);
            }

            if (GlobalVersion != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(GlobalVersion.AssetName));
                GlobalVersion.WriteTo(writer);
            }

            writer.Write(assetNames.GetOrCreateAssetIndex(HeightMapData.AssetName));
            HeightMapData.WriteTo(writer);

            writer.Write(assetNames.GetOrCreateAssetIndex(BlendTileData.AssetName));
            BlendTileData.WriteTo(writer);

            writer.Write(assetNames.GetOrCreateAssetIndex(WorldInfo.AssetName));
            WorldInfo.WriteTo(writer, assetNames);

            if (MPPositionList != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(MPPositionList.AssetName));
                MPPositionList.WriteTo(writer, assetNames);
            }

            writer.Write(assetNames.GetOrCreateAssetIndex(SidesList.AssetName));
            SidesList.WriteTo(writer, assetNames, AssetList != null);

            if (LibraryMapLists != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(LibraryMapLists.AssetName));
                LibraryMapLists.WriteTo(writer, assetNames);
            }

            if (Teams != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(Teams.AssetName));
                Teams.WriteTo(writer, assetNames);
            }

            if (PlayerScriptsList != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(PlayerScriptsList.AssetName));
                PlayerScriptsList.WriteTo(writer, assetNames);
            }

            if (BuildLists != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(BuildLists.AssetName));
                BuildLists.WriteTo(writer, assetNames, AssetList != null);
            }

            writer.Write(assetNames.GetOrCreateAssetIndex(ObjectsList.AssetName));
            ObjectsList.WriteTo(writer, assetNames);

            if (PolygonTriggers != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(PolygonTriggers.AssetName));
                PolygonTriggers.WriteTo(writer);
            }

            if (TriggerAreas != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(TriggerAreas.AssetName));
                TriggerAreas.WriteTo(writer);
            }

            if (GlobalWaterSettings != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(GlobalWaterSettings.AssetName));
                GlobalWaterSettings.WriteTo(writer);
            }

            if (FogSettings != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(FogSettings.AssetName));
                FogSettings.WriteTo(writer);
            }

            if (MissionHotSpots != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(MissionHotSpots.AssetName));
                MissionHotSpots.WriteTo(writer);
            }

            if (MissionObjectives != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(MissionObjectives.AssetName));
                MissionObjectives.WriteTo(writer);
            }

            if (StandingWaterAreas != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(StandingWaterAreas.AssetName));
                StandingWaterAreas.WriteTo(writer);
            }

            if (RiverAreas != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(RiverAreas.AssetName));
                RiverAreas.WriteTo(writer);
            }

            if (StandingWaveAreas != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(StandingWaveAreas.AssetName));
                StandingWaveAreas.WriteTo(writer);
            }

            writer.Write(assetNames.GetOrCreateAssetIndex(GlobalLighting.AssetName));
            GlobalLighting.WriteTo(writer);

            if (PostEffectsChunk != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(PostEffectsChunk.AssetName));
                PostEffectsChunk.WriteTo(writer);
            }

            if (EnvironmentData != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(EnvironmentData.AssetName));
                EnvironmentData.WriteTo(writer);
            }

            if (NamedCameras != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(NamedCameras.AssetName));
                NamedCameras.WriteTo(writer);
            }

            if (CameraAnimationList != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(CameraAnimationList.AssetName));
                CameraAnimationList.WriteTo(writer);
            }

            if (CastleTemplates != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(CastleTemplates.AssetName));
                CastleTemplates.WriteTo(writer, assetNames);
            }

            writer.Write(assetNames.GetOrCreateAssetIndex(WaypointsList.AssetName));
            WaypointsList.WriteTo(writer);

            if (SkyboxSettings != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(SkyboxSettings.AssetName));
                SkyboxSettings.WriteTo(writer);
            }
        }
コード例 #2
0
        private static MapFile ParseMapData(BinaryReader reader)
        {
            var assetNames = AssetNameCollection.Parse(reader);

            var result = new MapFile();

            var context = new MapParseContext(assetNames);

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

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

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

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

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

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

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

                case SidesList.AssetName:
                    result.SidesList = SidesList.Parse(reader, context, result.AssetList != null);
                    break;

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

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

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

                case BuildLists.AssetName:
                    result.BuildLists = BuildLists.Parse(reader, context, result.AssetList != null);
                    break;

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

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

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

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

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

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

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

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

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

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

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

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

                case EnvironmentData.AssetName:
                    result.EnvironmentData = EnvironmentData.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 CastleTemplates.AssetName:
                    result.CastleTemplates = CastleTemplates.Parse(reader, context);
                    break;

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

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

                default:
                    throw new NotImplementedException(assetName);
                }
            });

            context.PopAsset();

            return(result);
        }