public static TES3Lib.TES3 ConvertExteriors(TES4Lib.TES4 tes4) { ConvertedRecords.Add("CELL", new List <ConvertedRecordData>()); ConvertExteriorCells(tes4); Console.WriteLine($"EXTERIOR CELL AND REFERENCED RECORDS CONVERSION DONE \n BUILDING TES3 PLUGIN/MASTER INSTANCE"); var tes3 = new TES3Lib.TES3(); TES3Lib.Records.TES3 header = createTES3HEader(); tes3.Records.Add(header); foreach (var record in Enum.GetNames(typeof(TES3Lib.RecordTypes))) { if (!ConvertedRecords.ContainsKey(record)) { continue; } tes3.Records.InsertRange(tes3.Records.Count, ConvertedRecords[record].Select(x => x.Record)); } //dispose helper structures ConvertedRecords = new Dictionary <string, List <ConvertedRecordData> >(); CellReferences = new List <ConvertedCellReference>(); DoorReferences = new List <TES3Lib.Records.REFR>(); return(tes3); }
private static void ConvertInteriorCells(TES4Lib.TES4 tes4) { //convert cells var cellGroupsTop = tes4.Groups.FirstOrDefault(x => x.Label == "CELL"); if (IsNull(cellGroupsTop)) { Console.WriteLine("no CELL records"); return; } foreach (var cellBlock in cellGroupsTop.Groups) { ProcessInteriorSubBlocks(cellBlock); } }
public static TES3Lib.TES3 ConvertInteriorsAndExteriors(TES4Lib.TES4 tes4) { ConvertRecords(tes4, "SE"); ConvertedRecords.Add("CELL", new List <ConvertedRecordData>()); ConvertedRecords.Add("PGRD", new List <ConvertedRecordData>()); ConvertInteriorCells(tes4); ConvertExteriorCells(tes4); UpdateDoorReferences(); //SI PostProcessing(); var tes3 = new TES3Lib.TES3(); TES3Lib.Records.TES3 header = createTES3HEader(); tes3.Records.Add(header); EquipementSplitter.SELL0NPCOrderKnightArmor100(); foreach (var record in Enum.GetNames(typeof(TES3Lib.RecordTypes))) { //SI if (record.Equals("BODY")) { tes3.Records.AddRange(GetListOfBodyParts()); } if (!ConvertedRecords.ContainsKey(record)) { continue; } tes3.Records.AddRange(ConvertedRecords[record].Select(x => x.Record)); } //dispose helper structures ConvertedRecords = new Dictionary <string, List <ConvertedRecordData> >(); CellReferences = new List <ConvertedCellReference>(); DoorReferences = new List <TES3Lib.Records.REFR>(); var dupex = tes3.Records.Find(x => x.GetEditorId() == "SEOrderKnightArmor1Iron\0"); return(tes3); }
/// <summary> /// Convert all non hierarchical records from loaded TES4 file /// </summary> /// <param name="tes4">TES4 ESM/ESP with records</param> /// <param name="prefix">optional prefix for records editorId to convert</param> private static void ConvertRecords(TES4Lib.TES4 tes4, string prefix = null) { foreach (TES4Lib.Base.Group group in tes4.Groups) { if (group.Label.Equals("CELL") || group.Label.Equals("DIAL") || group.Label.Equals("WRLD")) { continue; } foreach (TES4Lib.Base.Record record in group.Records) { string editorId = record.GetEditorId(); if (string.IsNullOrEmpty(editorId) || editorId.Equals("SE14GSEscortList\0")) { continue; } if (!string.IsNullOrEmpty(prefix)) { if (editorId.StartsWith(prefix) || editorId.StartsWith("XP")) { ConvertedRecordData mwRecord = ConvertRecord(record); if (IsNull(mwRecord)) { continue; } if (!ConvertedRecords.ContainsKey(mwRecord.Type)) { ConvertedRecords.Add(mwRecord.Type, new List <ConvertedRecordData>()); } ConvertedRecords[mwRecord.Type].Add(mwRecord); } } else { ConvertedRecordData mwRecord = ConvertRecord(record); if (!ConvertedRecords.ContainsKey(mwRecord.Type)) { ConvertedRecords.Add(mwRecord.Type, new List <ConvertedRecordData>()); } ConvertedRecords[mwRecord.Type].Add(mwRecord); } } } }
private static void ConvertExteriorCells(TES4Lib.TES4 tes4) { //convert cells var wrldGroupsTop = tes4.Groups.FirstOrDefault(x => x.Label == "WRLD"); if (IsNull(wrldGroupsTop)) { Console.WriteLine("no WRLD records"); return; } foreach (TES4Lib.Records.WRLD wrld in wrldGroupsTop.Records) { Console.WriteLine($"Converting worldspace {wrld.FULL.DisplayName}"); var wrldFormId = wrld.FormId; var worldChildren = wrldGroupsTop.Groups.FirstOrDefault(x => x.Label == wrldFormId); if (IsNull(worldChildren)) { Console.WriteLine($"{wrld.FULL.DisplayName} has no WorldChildren"); continue; } //Here are records ROAD foreach (var exteriorCellBlock in worldChildren.Groups) { if (exteriorCellBlock.Type.Equals(GroupLabel.CellChildren)) { continue; } ProcessExteriorSubBlocks(exteriorCellBlock); } //process extra CELL record var wrldCell = worldChildren.Records.FirstOrDefault(x => x.Name.Equals("CELL")) as TES4Lib.Records.CELL; if (!IsNull(wrldCell)) { //gardens hacks if (wrld.EDID.EditorId.Equals("SEManiaGarden\0") || wrld.EDID.EditorId.Equals("SEDementiaGarden\0")) { wrldCell.DATA.Flags.Add(TES4Lib.Enums.Flags.CellFlag.IsInteriorCell); wrldCell.DATA.Flags.Add(TES4Lib.Enums.Flags.CellFlag.BehaveLikeExterior); var convertedGardenCell = ConvertCELL(wrldCell); var gWrldCellChildren = worldChildren.Groups.FirstOrDefault(x => x.Type.Equals(GroupLabel.CellChildren)); ConvertCellChildren(ref convertedGardenCell, gWrldCellChildren, wrld.FormId); DistributeGardenReferences(convertedGardenCell, wrld.EDID.EditorId); continue; } var convertedCell = ConvertCELL(wrldCell); var wrldCellChildren = worldChildren.Groups.FirstOrDefault(x => x.Type.Equals(GroupLabel.CellChildren)); ConvertCellChildren(ref convertedCell, wrldCellChildren, wrld.FormId); DistributeWorldSpaceReferecnes(convertedCell); } //merge path grids: mabye some other time //foreach (var exteriorCellPathGrid in ExteriorPathGrids) //{ // var mergedGrid = MergeExteriorPathGrids(exteriorCellPathGrid.Value); // ConvertedRecords["PGRD"].Add(new ConvertedRecordData("PGRD", "PGRD", "PGRD", mergedGrid)); //} } }