internal static void GenerateTitle(DCSMission mission, MissionTemplateRecord template) { ImageMaker imageMaker = new(); imageMaker.TextOverlay.Alignment = ContentAlignment.MiddleCenter; imageMaker.TextOverlay.Text = mission.Briefing.Name; List <ImageMakerLayer> imageLayers = new List <ImageMakerLayer>(); string[] theaterImages = Directory.GetFiles($"{BRPaths.INCLUDE_JPG}Theaters\\", $"{Database.Instance.GetEntry<DBEntryTheater>(template.ContextTheater).DCSID}*.jpg"); if (theaterImages.Length == 0) { imageLayers.Add(new ImageMakerLayer("_default.jpg")); } else { imageLayers.Add(new ImageMakerLayer("Theaters\\" + Path.GetFileName(Toolbox.RandomFrom(theaterImages)))); } imageLayers.Add(new ImageMakerLayer($"Flags\\{template.GetCoalitionID(template.ContextPlayerCoalition)}.png", ContentAlignment.TopLeft, 8, 8, 0, .5)); byte[] imageBytes = imageMaker.GetImageBytes(imageLayers.ToArray()); mission.AddMediaFile($"l10n/DEFAULT/title_{mission.UniqueID}.jpg", imageBytes); }
internal static string[] GetEmbeddedAirDefenseUnits(MissionTemplateRecord template, Side side, Country?country = null) { DBCommonAirDefenseLevel airDefenseInfo = (side == Side.Ally) ? Database.Instance.Common.AirDefense.AirDefenseLevels[(int)template.SituationFriendlyAirDefense.Get()] : Database.Instance.Common.AirDefense.AirDefenseLevels[(int)template.SituationEnemyAirDefense.Get()]; DBEntryCoalition unitsCoalitionDB = Database.Instance.GetEntry <DBEntryCoalition>(template.GetCoalitionID(side)); if (unitsCoalitionDB == null) { return(new string[0]); } List <string> units = new List <string>(); if (Toolbox.RandomDouble() >= airDefenseInfo.EmbeddedChance) { return(new string[0]); } int airDefenseUnitsCount = airDefenseInfo.EmbeddedUnitCount.GetValue(); for (int i = 0; i < airDefenseUnitsCount; i++) { var families = new List <UnitFamily> { UnitFamily.VehicleAAA, UnitFamily.VehicleAAA, UnitFamily.VehicleSAMShortIR, UnitFamily.VehicleSAMShortIR, UnitFamily.VehicleSAMShort }; units.AddRange(unitsCoalitionDB.GetRandomUnits(families, template.ContextDecade, 1, template.Mods, country).Item2); } return(units.ToArray()); }