Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        /// <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);
                    }
                }
            }
        }
Esempio n. 4
0
        private static void ConvertCellChildren(ref TES3Lib.Records.CELL mwCELL, Group cellChildren, string originalCellFormId)
        {
            foreach (var childrenType in cellChildren.Groups)
            {
                if (IsNull(mwCELL.NAM0))
                {
                    mwCELL.NAM0 = new TES3Lib.Subrecords.CELL.NAM0 {
                        ReferenceCount = 1
                    };
                }

                foreach (var obRef in childrenType.Records)
                {
                    if (obRef.Flag.Contains(TES4Lib.Enums.Flags.RecordFlag.Deleted))
                    {
                        continue;
                    }

                    TES3Lib.Records.REFR mwREFR;

                    var referenceTypeName = obRef.GetType().Name;

                    if (referenceTypeName.Equals("REFR"))
                    {
                        var obREFR = obRef as TES4Lib.Records.REFR;
                        if (IsNull(obREFR.NAME))
                        {
                            continue;
                        }
                        var ReferenceBaseFormId = obREFR.NAME.BaseFormId;

                        var BaseId = GetBaseId(ReferenceBaseFormId);
                        if (string.IsNullOrEmpty(BaseId))
                        {
                            continue;
                        }

                        mwREFR = ConvertREFR(obREFR, BaseId, mwCELL.NAM0.ReferenceCount, mwCELL.DATA.Flags.Contains(TES3Lib.Enums.Flags.CellFlag.IsInteriorCell));
                        CellReferences.Add(new ConvertedCellReference(originalCellFormId, obREFR.FormId, mwREFR)); //for tracking

                        {                                                                                          // disable exterior statics as requested, remove when SI mod will be finished
                            if (!mwCELL.DATA.Flags.Contains(TES3Lib.Enums.Flags.CellFlag.IsInteriorCell))
                            {
                                if (ConvertedRecords.ContainsKey("STAT") && ConvertedRecords["STAT"].Any(x => x.EditorId.Equals(BaseId)))
                                {
                                    continue;
                                }
                            }
                        }

                        mwCELL.REFR.Add(mwREFR);
                        mwCELL.NAM0.ReferenceCount++;
                        continue;
                    }

                    if (referenceTypeName.Equals("ACRE"))
                    {
                        var obACRE = obRef as TES4Lib.Records.ACRE;
                        if (IsNull(obACRE.NAME))
                        {
                            continue;
                        }
                        var ReferenceBaseFormId = obACRE.NAME.BaseFormId;

                        var BaseId = GetBaseId(ReferenceBaseFormId);
                        if (string.IsNullOrEmpty(BaseId))
                        {
                            continue;
                        }

                        mwREFR = ConvertACRE(obACRE, BaseId, mwCELL.NAM0.ReferenceCount, mwCELL.DATA.Flags.Contains(TES3Lib.Enums.Flags.CellFlag.IsInteriorCell));
                        CellReferences.Add(new ConvertedCellReference(originalCellFormId, obACRE.FormId, mwREFR)); //for tracking

                        mwCELL.REFR.Add(mwREFR);
                        mwCELL.NAM0.ReferenceCount++;
                        continue;
                    }

                    if (referenceTypeName.Equals("ACHR"))
                    {
                        var obACHR = obRef as TES4Lib.Records.ACHR;
                        if (IsNull(obACHR.NAME))
                        {
                            continue;
                        }
                        var ReferenceBaseFormId = obACHR.NAME.BaseFormId;

                        var BaseId = GetBaseId(ReferenceBaseFormId);
                        if (string.IsNullOrEmpty(BaseId))
                        {
                            continue;
                        }

                        mwREFR = ConvertACHR(obACHR, BaseId, mwCELL.NAM0.ReferenceCount, mwCELL.DATA.Flags.Contains(TES3Lib.Enums.Flags.CellFlag.IsInteriorCell));
                        CellReferences.Add(new ConvertedCellReference(originalCellFormId, obACHR.FormId, mwREFR)); //for tracking

                        mwCELL.REFR.Add(mwREFR);
                        mwCELL.NAM0.ReferenceCount++;
                        continue;
                    }

                    if (referenceTypeName.Equals("LAND"))
                    {
                        continue;
                    }

                    if (referenceTypeName.Equals("PGRD"))
                    {
                        if (mwCELL.DATA.Flags.Contains(TES3Lib.Enums.Flags.CellFlag.IsInteriorCell))
                        {
                            var obPGRD = obRef as TES4Lib.Records.PGRD;
                            var mwPGRD = ConvertPGRD(obPGRD, mwCELL);
                            ConvertedRecords["PGRD"].Add(new ConvertedRecordData(originalCellFormId, "CELL", mwCELL.NAME.EditorId, mwPGRD));
                            continue;
                        }
                        //else
                        //{
                        //    var coordinates = $"{mwPGRD.DATA.GridX},{mwPGRD.DATA.GridY}";

                        //    if (!ExteriorPathGrids.ContainsKey(coordinates))
                        //    {
                        //        ExteriorPathGrids.Add(coordinates, new List<ConvertedExteriorPathgrid>());
                        //    }

                        //    ExteriorPathGrids[coordinates].Add(new ConvertedExteriorPathgrid(mwPGRD, obPGRD.PGRI));
                        //    continue;
                        //}
                    }
                }
            }
        }