コード例 #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");
                }
            }
        }
コード例 #2
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;
                }
            }
        }
コード例 #3
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;
                        //}
                    }
                }
            }
        }