Esempio n. 1
0
        private static void DistributeWorldSpaceReferecnes(TES3Lib.Records.CELL convertedCell)
        {
            foreach (var cellReference in convertedCell.REFR)
            {
                int cellGrindX = (int)(cellReference.DATA.XPos / Config.mwCellSize);
                int cellGrindY = (int)(cellReference.DATA.YPos / Config.mwCellSize);

                ConvertedRecordData targetConvertedCell = ConvertedRecords["CELL"].FirstOrDefault(x =>
                                                                                                  (x.Record as TES3Lib.Records.CELL).DATA.GridX.Equals(cellGrindX) && (x.Record as TES3Lib.Records.CELL).DATA.GridY.Equals(cellGrindY));

                if (!IsNull(targetConvertedCell))
                {
                    var cellRecord = targetConvertedCell.Record as TES3Lib.Records.CELL;
                    cellRecord.NAM0.ReferenceCount++;
                    cellReference.FRMR.ObjectIndex = cellRecord.NAM0.ReferenceCount;
                    cellRecord.REFR.Add(cellReference);

                    //need update parent formId
                    var convertedReference = CellReferences.FirstOrDefault(x => x.Reference.Equals(cellReference));
                    convertedReference.ParentCellFormId = targetConvertedCell.OriginFormId;
                }
                else
                {
                    Console.WriteLine($"target cell at coordinates {cellGrindX}.{cellGrindY} not found");
                }
            }
        }
Esempio n. 2
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. 3
0
        private static void DistributeGardenReferences(TES3Lib.Records.CELL convertedCell, string gardenWorldName)
        {
            string cellName = gardenWorldName == "SEManiaGarden\0" ? "SEManiaGardenExterior\0" : "SEDementiaGardenExterior\0";
            ConvertedRecordData targetConvertedCell = ConvertedRecords["CELL"].FirstOrDefault(x =>
                                                                                              (x.Record as TES3Lib.Records.CELL).NAME.EditorId.Equals(cellName));

            foreach (var cellReference in convertedCell.REFR)
            {
                if (!IsNull(targetConvertedCell))
                {
                    var cellRecord = targetConvertedCell.Record as TES3Lib.Records.CELL;
                    cellRecord.NAM0.ReferenceCount++;
                    cellReference.FRMR.ObjectIndex = cellRecord.NAM0.ReferenceCount;
                    cellRecord.REFR.Add(cellReference);

                    //need update parent formId
                    var convertedReference = CellReferences.FirstOrDefault(x => x.Reference.Equals(cellReference));
                    convertedReference.ParentCellFormId = targetConvertedCell.OriginFormId;
                }
            }
        }