Beispiel #1
0
        private void Convert(int zoneSetIndex, BspFlags bspMask, MultiplayerScenarioConversionFlags conversionFlags)
        {
            var blamCache   = BlamCache;
            var blamScnrTag = BlamCache.IndexItems.FirstOrDefault(x => x.GroupTag == "scnr");
            var blamScnr    = BlamCache.Deserializer.Deserialize <Scenario>(new CacheSerializationContext(ref blamCache, blamScnrTag));

            using (var cacheStream = CacheContext.OpenTagCacheReadWrite())
            {
                var resourceStreams = new Dictionary <ResourceLocation, Stream>();

                var defaultPortingFlags = PortingFlags.Default;
                if (!conversionFlags.HasFlag(MultiplayerScenarioConversionFlags.Audio))
                {
                    defaultPortingFlags &= ~PortingFlags.Audio;
                }
                if (!conversionFlags.HasFlag(MultiplayerScenarioConversionFlags.Ms30))
                {
                    defaultPortingFlags &= ~PortingFlags.Ms30;
                }

                if (blamScnr.Lightmap != null)
                {
                    PortTag.RemoveFlags(~defaultPortingFlags);
                    PortTag.SetFlags(defaultPortingFlags);
                    ConvertLightmap(cacheStream, resourceStreams,
                                    blamCache.GetIndexItemFromID(blamScnr.Lightmap.Index), zoneSetIndex, bspMask);
                }

                var tagCollector = new MultiplayerScenarioTagCollector(blamCache, blamScnr, zoneSetIndex, bspMask, conversionFlags);
                tagCollector.Collect();

                PortTag.RemoveFlags(~defaultPortingFlags);
                PortTag.SetFlags(defaultPortingFlags);

                foreach (var tag in tagCollector.Tags)
                {
                    PortTag.ConvertTag(cacheStream, resourceStreams, tag);
                }

                PortTag.RemoveFlags(PortingFlags.Recursive);
                var scnrTag = PortTag.ConvertTag(cacheStream, resourceStreams, blamScnrTag);

                new MultiplayerScenarioFixup(cacheStream, CacheContext, blamScnrTag.Name, zoneSetIndex, bspMask, conversionFlags).Fixup();

                foreach (var entry in resourceStreams.Values)
                {
                    entry.Close();
                }
            }

            using (var stringIdCacheStream = CacheContext.OpenStringIdCacheReadWrite())
                CacheContext.StringIdCache.Save(stringIdCacheStream);

            CacheContext.SaveTagNames();
        }
Beispiel #2
0
            private void CollectAllScenarioObjects()
            {
                if (!ConversionFlags.HasFlag(MultiplayerScenarioConversionFlags.Objects))
                {
                    return;
                }

                CollectScenarioObjects(BlamScnr.Scenery, BlamScnr.SceneryPalette);
                CollectScenarioObjects(BlamScnr.Bipeds, BlamScnr.BipedPalette);
                CollectScenarioObjects(BlamScnr.Vehicles, BlamScnr.VehiclePalette);
                CollectScenarioObjects(BlamScnr.Equipment, BlamScnr.EquipmentPalette);
                CollectScenarioObjects(BlamScnr.Weapons, BlamScnr.WeaponPalette);
                CollectScenarioObjects(BlamScnr.Machines, BlamScnr.MachinePalette);
                CollectScenarioObjects(BlamScnr.Terminals, BlamScnr.TerminalPalette);
                CollectScenarioObjects(BlamScnr.Controls, BlamScnr.ControlPalette);
                CollectScenarioObjects(BlamScnr.SoundScenery, BlamScnr.SoundSceneryPalette);
                CollectScenarioObjects(BlamScnr.Giants, BlamScnr.GiantPalette);
                CollectScenarioObjects(BlamScnr.EffectScenery, BlamScnr.EffectSceneryPalette);
                CollectScenarioObjects(BlamScnr.LightVolumes, BlamScnr.LightVolumePalette);
                CollectScenarioObjects(BlamScnr.Crates, BlamScnr.CratePalette);
                CollectScenarioObjects(BlamScnr.Creatures, BlamScnr.CreaturePalette);
            }
Beispiel #3
0
            public void Fixup()
            {
                Scnr.MapType    = ScenarioMapType.Multiplayer;
                Scnr.MapSubType = ScenarioMapSubType.None;
                Scnr.CampaignId = -1;

                FixupStructureBspReferences();
                FixupSkies();
                FixupZoneSets();
                FixupAllScenarioObjects();
                FixupScenarioClusterData();

                Scnr.BspAtlas.Clear();
                Scnr.CampaignPlayers.Clear();
                Scnr.SoftCeilings.Clear();
                Scnr.PlayerStartingProfile.Clear();
                Scnr.PlayerStartingLocations.Clear();
                Scnr.TriggerVolumes.Clear();
                Scnr.RecordedAnimations.Clear();
                Scnr.ZonesetSwitchTriggerVolumes.Clear();
                Scnr.Unknown32.Clear();
                Scnr.Unknown33.Clear();
                Scnr.Unknown34.Clear();
                Scnr.Unknown35.Clear();
                Scnr.Unknown36.Clear();
                Scnr.StylePalette.Clear();
                Scnr.SquadGroups.Clear();
                Scnr.Squads.Clear();
                Scnr.Zones.Clear();
                Scnr.SquadPatrols.Clear();
                Scnr.MissionScenes.Clear();
                Scnr.CharacterPalette.Clear();
                Scnr.Scripts.Clear();
                Scnr.ScriptingData.Clear();
                Scnr.ScriptStrings = null;
                Scnr.ScriptSourceFileReferences.Clear();
                Scnr.ScriptExternalFileReferences.Clear();
                Scnr.Scripts.Clear();
                Scnr.Globals.Clear();
                Scnr.CutsceneFlags.Clear();
                Scnr.CutsceneCameraPoints.Clear();
                Scnr.Cinematics.Clear();
                Scnr.CinematicLighting.Clear();
                Scnr.CutsceneTitles.Clear();
                Scnr.CustomObjectNameStrings = null;
                Scnr.ChapterTitleStrings     = null;
                Scnr.UnitSeatsMapping.Clear();
                Scnr.ScenarioKillTriggers.Clear();
                Scnr.ScenarioSafeTriggers.Clear();
                Scnr.ScriptExpressions.Clear();
                Scnr.SubtitleStrings = null;
                Scnr.MissionDialogue.Clear();
                Scnr.ObjectiveStrings = null;
                Scnr.Interpolators.Clear();
                Scnr.SimulationDefinitionTable.Clear();
                Scnr.ObjectReferenceFrames.Clear();
                Scnr.AiObjectives.Clear();
                Scnr.DesignerZoneSets.Clear();
                Scnr.Unknown135.Clear();
                Scnr.ScenarioMetagame.Clear();
                Scnr.EditorFolders.Clear();

                if (!ConversionFlags.HasFlag(MultiplayerScenarioConversionFlags.PathFinding))
                {
                    Scnr.AiPathfindingData.Clear();
                }

                ScenarioInstance targetInstance = Scnr.Scenery.FirstOrDefault();

                if (targetInstance == null)
                {
                    targetInstance = Scnr.Crates.FirstOrDefault();
                }

                if (targetInstance != null)
                {
                    var position = targetInstance.Position;
                    position.Z += 0.5f;

                    if (ConversionFlags.HasFlag(MultiplayerScenarioConversionFlags.SpawnPoint))
                    {
                        AddRespawnPoint(position, targetInstance.Rotation);
                    }

                    AddPrematchCamera(position, targetInstance.Rotation);
                }

                Scnr.PlayerStartingProfile = new List <PlayerStartingProfileBlock>
                {
                    new PlayerStartingProfileBlock
                    {
                        Name                     = "start_assault",
                        PrimaryWeapon            = CacheContext.GetTag <Weapon>(@"objects\weapons\rifle\assault_rifle\assault_rifle"),
                        PrimaryRoundsLoaded      = 32,
                        PrimaryRoundsTotal       = 96,
                        StartingFragGrenadeCount = 2,
                        Unknown3                 = -1
                    }
                };

                CacheContext.Serialize(CacheStream, ScnrTag, Scnr);

                FixupInstancedGeometry();
            }