Exemplo n.º 1
0
        public static void SaveToXML(Blueprint blueprint)
        {
            try
            {
                try
                {
                    Scribe.InitWriting(FullSaveLocation(blueprint.name), "Blueprint");
                }
                catch (Exception ex)
                {
                    GenUI.ErrorDialog("ProblemSavingFile".Translate(ex.ToString()));
                    throw;
                }
                ScribeMetaHeaderUtility.WriteMetaHeader();

                Scribe_Deep.LookDeep(ref blueprint, "Blueprint");
            }
            catch (Exception ex2)
            {
                Log.Error("Exception while saving blueprint: " + ex2);
            }
            finally
            {
                Scribe.FinalizeWriting();
            }

            // set exported flag.
            blueprint.exported = true;
        }
        private void DoExport(string name)
        {
            try
            {
                try
                {
                    Scribe.InitWriting(FilePath(name), "ManagerJobs");
                }
                catch (Exception ex)
                {
                    GenUI.ErrorDialog("ProblemSavingFile".Translate(ex.ToString()));
                    throw;
                }

                ScribeMetaHeaderUtility.WriteMetaHeader();

                _jobStackIO = Manager.For(manager).JobStack;
                Scribe_Deep.LookDeep(ref _jobStackIO, "JobStack");
            }
            catch (Exception ex2)
            {
                Log.Error("Exception while saving jobstack: " + ex2);
            }
            finally
            {
                Scribe.FinalizeWriting();
                Messages.Message("FM.JobsExported".Translate(_jobStackIO.FullStack().Count), MessageSound.Standard);
                Refresh();
            }
        }
Exemplo n.º 3
0
 public static void Save()
 {
     try
     {
         var xDocument = new XDocument();
         var content   = DirectXmlSaver.XElementFromObject(data, typeof(BadPeoplePerfsData));
         xDocument.Add(content);
         xDocument.Save(prefsFilePath);
     }
     catch (Exception ex)
     {
         GenUI.ErrorDialog("ProblemSavingFile".Translate(prefsFilePath, ex.ToString()));
         Log.Error("Exception saving prefs: " + ex);
     }
 }
 public static void Save()
 {
     try
     {
         XDocument xDocument = new XDocument();
         XElement  content   = DirectXmlSaver.XElementFromObject(data, typeof(ConceptKnowledge));
         xDocument.Add(content);
         xDocument.Save(GenFilePaths.ConceptKnowledgeFilePath);
     }
     catch (Exception ex)
     {
         GenUI.ErrorDialog("ProblemSavingFile".Translate(GenFilePaths.ConceptKnowledgeFilePath, ex.ToString()));
         Log.Error("Exception saving knowledge database: " + ex);
     }
 }
Exemplo n.º 5
0
 public static void Save()
 {
     Other.Tutorials.UpdateTutorialFlags();
     try
     {
         var xDocument = new XDocument();
         var content   = DirectXmlSaver.XElementFromObject(data, typeof(PrisonLaborPrefsData));
         xDocument.Add(content);
         xDocument.Save(prefsFilePath);
     }
     catch (Exception ex)
     {
         GenUI.ErrorDialog("ProblemSavingFile".Translate(prefsFilePath, ex.ToString()));
         Log.Error("Exception saving prefs: " + ex);
     }
 }
Exemplo n.º 6
0
        public static void SaveFromPathCall(Map map, IntVec3 startVec, LocalTargetInfo dest, TraverseParms traverseParms, PathEndMode peMode)
        {
            CellRect destinationRect;

            if (dest.HasThing && peMode != PathEndMode.OnCell)
            {
                destinationRect = dest.Thing.OccupiedRect();
            }
            else
            {
                destinationRect = CellRect.SingleCell(dest.Cell);
            }

            var dumper = new PathDataLog
            {
                mapSize         = map.Size,
                start           = startVec,
                dest            = destinationRect,
                peMode          = peMode,
                tpMode          = traverseParms.mode,
                tpMaxDanger     = traverseParms.maxDanger,
                tpCanBash       = traverseParms.canBash,
                tpMoveCardinal  = traverseParms.pawn?.TicksPerMoveCardinal ?? -1,
                tpMoveDiagonal  = traverseParms.pawn?.TicksPerMoveDiagonal ?? -1,
                pathGrid        = map.pathGrid.pathGrid,
                fakeEdificeGrid = new ByteGrid(map),
                avoidGrid       = traverseParms.pawn?.GetAvoidGrid(),
                allowedArea     = traverseParms.pawn?.playerSettings?.AreaRestrictionInPawnCurrentMap
            };

            foreach (var cell in map.AllCells)
            {
                var rb    = cell.GetRegionBarrier(map);
                int value = Edifice_None;
                if (rb != null)
                {
                    var door = rb as Building_Door;
                    if (door != null)
                    {
                        switch (traverseParms.mode)
                        {
                        case TraverseMode.ByPawn:
                            if (!traverseParms.canBash && door.IsForbiddenToPass(traverseParms.pawn))
                            {
                                value = Edifice_NonTraversableDoor;
                            }
                            else if (!door.FreePassage)
                            {
                                value = door.PawnCanOpen(traverseParms.pawn) ? door.TicksToOpenNow : Edifice_NonTraversableDoor;
                            }
                            else
                            {
                                value = 0;
                            }
                            break;

                        case TraverseMode.NoPassClosedDoors:
                            value = !door.FreePassage ? Edifice_NonTraversableDoor : 0;
                            break;
                        }
                    }
                    else if ((rb as Building)?.PathFindCostFor(traverseParms.pawn) > 0)
                    {
                        value = Edifice_KnownArmedTrap;
                    }
                    else
                    {
                        value = Edifice_Impassible;
                    }
                }
                dumper.fakeEdificeGrid[cell] = (byte)value;
            }

            var savePath = Path.Combine(GenFilePaths.DevOutputFolderPath, $"{traverseParms.pawn} - {Find.TickManager.TicksAbs}");

            if (File.Exists(savePath + ".xml"))
            {
                savePath = savePath + " ";
                int saveNum = 1;
                while (File.Exists(savePath + saveNum + ".xml"))
                {
                    saveNum++;
                }
                savePath = savePath + saveNum;
            }
            try
            {
                SaveGame(savePath);
                try
                {
                    Scribe.InitWriting(savePath + ".xml", "PathDataLog");
                }
                catch (Exception ex)
                {
                    GenUI.ErrorDialog("Stuff went wrong " + ex);
                    throw;
                }
                ScribeMetaHeaderUtility.WriteMetaHeader();

                Scribe_Deep.LookDeep(ref dumper, "PathData");
            }
            catch (Exception ex2)
            {
                Log.Error("Exception while saving: " + ex2);
            }
            finally
            {
                Scribe.FinalizeWriting();
            }
        }