// Token: 0x06000018 RID: 24 RVA: 0x00002A7B File Offset: 0x00000C7B
 public override void Generate(Map map, GenStepParams parms)
 {
     DeepProfiler.Start("RebuildAllRegions");
     map.regionAndRoomUpdater.RebuildAllRegionsAndRooms();
     DeepProfiler.End();
     MapGenerator.PlayerStartSpot = ((UndergroundMapParent)map.info.parent).holeLocation;
 }
Beispiel #2
0
 public override void Generate(Map map, GenStepParams parms)
 {
     DeepProfiler.Start("RebuildAllRegions");
     map.regionAndRoomUpdater.RebuildAllRegionsAndRooms();
     DeepProfiler.End();
     MapGenerator.PlayerStartSpot = map.Center + new IntVec3(0, 0, 1);
 }
Beispiel #3
0
        public static bool PreFLoadGameFromSaveFile(string fileName)
        {
            string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods
                                             select mod.ToString(), true);

            Log.Message("Loading game from file " + fileName + " with mods " + str);
            DeepProfiler.Start("Loading game from file " + fileName);
            Current.Game = new Game();
            DeepProfiler.Start("InitLoading (read file)");
            Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName));
            DeepProfiler.End();
            ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, true);
            bool flag = !Scribe.EnterNode("Κgame");
            bool result;

            if (flag)
            {
                Log.Error("Could not find DTMG XML node.");
                Scribe.ForceStop();
                GenScene.GoToMainMenu();
                Messages.Message("Game MUST be created with 'Don't Tempt Me!' loaded. Please select a 'Don't Tempt Me!' save game file.", MessageTypeDefOf.RejectInput);
                result = false;
            }
            else
            {
                Current.Game = new Game();
                Current.Game.LoadGame();
                PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName);
                DeepProfiler.End();
                result = false;
            }
            return(result);
        }
 protected KAnimControllerBase()
 {
     KAnim.Anim.Frame invalidFrame = KAnim.Anim.Frame.InvalidFrame;
     curAnimFrameIdx = invalidFrame.idx;
     KAnim.Anim.Frame invalidFrame2 = KAnim.Anim.Frame.InvalidFrame;
     prevAnimFrame      = invalidFrame2.idx;
     eventManagerHandle = HandleVector <int> .InvalidHandle;
     overrideAnimFiles  = new List <OverrideAnimFileData>();
     DeepProfiler       = new DeepProfiler(false);
     playSpeed          = 1f;
     mode          = KAnim.PlayMode.Once;
     stopped       = true;
     animHeight    = 1f;
     animWidth     = 1f;
     _enabled      = true;
     hiddenSymbols = new List <KAnimHashedString>();
     anims         = new Dictionary <HashedString, AnimLookupData>();
     overrideAnims = new Dictionary <HashedString, AnimLookupData>();
     animQueue     = new Queue <AnimData>();
     fgLayer       = Grid.SceneLayer.NoLayer;
     base._002Ector();
     previousFrame       = -1;
     currentFrame        = -1;
     PlaySpeedMultiplier = 1f;
     synchronizer        = new KAnimSynchronizer(this);
     layering            = new KAnimLayering(this, fgLayer);
     isVisible           = true;
 }
Beispiel #5
0
        public static void AddModCheckPatching(List <LoadableXmlAsset> __result)
        {
            DeepProfiler.Start("Loading ModCheckPatches");

            Memory.Instance.LoadModCheckPatches();

            if (Memory.Instance.getModCheckPatches().Count > 0)
            {
                int iLength = __result.Count;
                Memory.Instance.resetPatchCount();

                foreach (PatchOperation current2 in Memory.Instance.getModCheckPatches())
                {
                    // always measure time. The cost overhead is less than measuring conditionally.
                    Memory.startPatchingWithTimer();
                    for (int i = 0; i < iLength; ++i)
                    {
                        Memory.Instance.setModAndFile(__result[i].mod.Name, __result[i].name, false);
                        current2.Apply(__result[i].xmlDoc);
                    }
                    Memory.endPatchingWithTimer();
                }
            }
            DeepProfiler.End();
        }
 public override void Generate(Map map, GenStepParams parms)
 {
     DeepProfiler.Start("RebuildAllRegions");
     map.regionAndRoomUpdater.RebuildAllRegionsAndRooms();
     DeepProfiler.End();
     MapGenerator.PlayerStartSpot = ((MapParent_ZLevel)map.Parent).PlayerStartSpot;
 }
        public static bool ExecuteToExecuteWhenFinished()
        {
            if (toExecuteWhenFinished2.Count > 0)
            {
                DeepProfiler.Start("ExecuteToExecuteWhenFinished()");
            }
            Action action;

            while (toExecuteWhenFinished2.TryDequeue(out action))
            {
                DeepProfiler.Start(action.Method.DeclaringType.ToString() + " -> " + action.Method.ToString());
                try
                {
                    action();
                }
                catch (Exception arg)
                {
                    Log.Error("Could not execute post-long-event action. Exception: " + arg);
                }
                finally
                {
                    DeepProfiler.End();
                }
            }

            if (toExecuteWhenFinished2.Count > 0)
            {
                DeepProfiler.End();
            }

            toExecuteWhenFinished.Clear();
            return(false);
        }
 public override void Generate(Map map, GenStepParams parms)
 {
     DeepProfiler.Start("RebuildAllRegions");
     map.regionAndRoomUpdater.RebuildAllRegionsAndRooms();
     DeepProfiler.End();
     MapGenerator.PlayerStartSpot = CellFinderLoose.TryFindCentralCell(map, 7, 10, (IntVec3 x) => !x.Roofed(map));
 }
Beispiel #9
0
        public override void Generate(Map map, GenStepParams parms)
        {
            List <NeededRoad> neededRoads = CalculateNeededRoads(map);

            if (neededRoads.Count == 0)
            {
                return;
            }
            List <DrawCommand> list = new List <DrawCommand>();

            DeepProfiler.Start("RebuildAllRegions");
            map.regionAndRoomUpdater.RebuildAllRegionsAndRooms();
            DeepProfiler.End();
            TerrainDef rockDef      = BaseGenUtility.RegionalRockTerrainDef(map.Tile, beautiful: false);
            IntVec3    centerpoint  = CellFinderLoose.TryFindCentralCell(map, 3, 10);
            RoadDef    bestRoadType = DefDatabase <RoadDef> .AllDefs.Where((RoadDef rd) => neededRoads.Count((NeededRoad nr) => nr.road == rd) >= 2).MaxByWithFallback((RoadDef rd) => rd.priority);

            DrawCommand item;

            if (bestRoadType != null)
            {
                NeededRoad neededRoad = neededRoads[neededRoads.FindIndex((NeededRoad nr) => nr.road == bestRoadType)];
                neededRoads.RemoveAt(neededRoads.FindIndex((NeededRoad nr) => nr.road == bestRoadType));
                NeededRoad neededRoad2 = neededRoads[neededRoads.FindIndex((NeededRoad nr) => nr.road == bestRoadType)];
                neededRoads.RemoveAt(neededRoads.FindIndex((NeededRoad nr) => nr.road == bestRoadType));
                RoadPathingDef pathingDef = neededRoad.road.pathingMode;
                IntVec3        intVec     = FindRoadExitCell(map, neededRoad.angle, centerpoint, ref pathingDef);
                IntVec3        end        = FindRoadExitCell(map, neededRoad2.angle, intVec, ref pathingDef);
                Action         action     = PrepDrawRoad(map, rockDef, intVec, end, neededRoad.road, pathingDef, out centerpoint);
                item = new DrawCommand
                {
                    action  = action,
                    roadDef = bestRoadType
                };
                list.Add(item);
            }
            foreach (NeededRoad item2 in neededRoads)
            {
                RoadPathingDef pathingDef2 = item2.road.pathingMode;
                IntVec3        intVec2     = FindRoadExitCell(map, item2.angle, centerpoint, ref pathingDef2);
                if (!(intVec2 == IntVec3.Invalid))
                {
                    item = new DrawCommand
                    {
                        action  = PrepDrawRoad(map, rockDef, centerpoint, intVec2, item2.road, pathingDef2),
                        roadDef = item2.road
                    };
                    list.Add(item);
                }
            }
            foreach (DrawCommand item3 in list.OrderBy((DrawCommand dc) => dc.roadDef.priority))
            {
                if (item3.action != null)
                {
                    item3.action();
                }
            }
        }
Beispiel #10
0
        public override void Generate(Map map)
        {
            List <GenStep_Roads.NeededRoad> neededRoads = this.CalculateNeededRoads(map);

            if (neededRoads.Count == 0)
            {
                return;
            }
            List <GenStep_Roads.DrawCommand> list = new List <GenStep_Roads.DrawCommand>();

            DeepProfiler.Start("RebuildAllRegions");
            map.regionAndRoomUpdater.RebuildAllRegionsAndRooms();
            DeepProfiler.End();
            TerrainDef rockDef      = BaseGenUtility.RegionalRockTerrainDef(map.Tile, false);
            IntVec3    intVec       = CellFinderLoose.TryFindCentralCell(map, 3, 10, null);
            RoadDef    bestRoadType = (from rd in DefDatabase <RoadDef> .AllDefs
                                       where neededRoads.Count((GenStep_Roads.NeededRoad nr) => nr.road == rd) >= 2
                                       select rd).MaxByWithFallback((RoadDef rd) => rd.priority, null);

            if (bestRoadType != null)
            {
                GenStep_Roads.NeededRoad neededRoad = neededRoads[neededRoads.FindIndex((GenStep_Roads.NeededRoad nr) => nr.road == bestRoadType)];
                neededRoads.RemoveAt(neededRoads.FindIndex((GenStep_Roads.NeededRoad nr) => nr.road == bestRoadType));
                GenStep_Roads.NeededRoad neededRoad2 = neededRoads[neededRoads.FindIndex((GenStep_Roads.NeededRoad nr) => nr.road == bestRoadType)];
                neededRoads.RemoveAt(neededRoads.FindIndex((GenStep_Roads.NeededRoad nr) => nr.road == bestRoadType));
                RoadPathingDef pathingMode = neededRoad.road.pathingMode;
                IntVec3        intVec2     = this.FindRoadExitCell(map, neededRoad.angle, intVec, ref pathingMode);
                IntVec3        end         = this.FindRoadExitCell(map, neededRoad2.angle, intVec2, ref pathingMode);
                Action         action      = this.PrepDrawRoad(map, rockDef, intVec2, end, neededRoad.road, pathingMode, out intVec);
                list.Add(new GenStep_Roads.DrawCommand
                {
                    action  = action,
                    roadDef = bestRoadType
                });
            }
            foreach (GenStep_Roads.NeededRoad current in neededRoads)
            {
                RoadPathingDef pathingMode2 = current.road.pathingMode;
                IntVec3        intVec3      = this.FindRoadExitCell(map, current.angle, intVec, ref pathingMode2);
                if (!(intVec3 == IntVec3.Invalid))
                {
                    list.Add(new GenStep_Roads.DrawCommand
                    {
                        action  = this.PrepDrawRoad(map, rockDef, intVec, intVec3, current.road, pathingMode2),
                        roadDef = current.road
                    });
                }
            }
            foreach (GenStep_Roads.DrawCommand current2 in from dc in list
                     orderby dc.roadDef.priority
                     select dc)
            {
                if (current2.action != null)
                {
                    current2.action();
                }
            }
        }
        public static bool ExecuteToExecuteWhenFinished()
        {
            if (executingToExecuteWhenFinished)
            {
                //Log.Warning("Already executing.");
                //return false;
            }

            executingToExecuteWhenFinished = true;
            if (toExecuteWhenFinished2.Count > 0)
            {
                DeepProfiler.Start("ExecuteToExecuteWhenFinished()");
            }
            Action action;

            //for (int i = 0; i < toExecuteWhenFinished.Count; i++)
            while (toExecuteWhenFinished2.TryDequeue(out action))
            {
                /*
                 * try
                 * {
                 *      action = toExecuteWhenFinished[i];
                 * }
                 * catch (ArgumentOutOfRangeException)
                 * {
                 *      break;
                 * }
                 */
                DeepProfiler.Start(action.Method.DeclaringType.ToString() + " -> " + action.Method.ToString());
                try
                {
                    action();
                }
                catch (Exception arg)
                {
                    Log.Error("Could not execute post-long-event action. Exception: " + arg);
                }
                finally
                {
                    DeepProfiler.End();
                }
            }

            if (toExecuteWhenFinished2.Count > 0)
            {
                DeepProfiler.End();
            }

            //
            toExecuteWhenFinished.Clear();
            executingToExecuteWhenFinished = false;
            return(false);
        }
Beispiel #12
0
        private void DoGlobalWork()
        {
            // priority settings on worktables.
            DeepProfiler.Start("Global work for production manager");
            // TODO: Fix global work for production jobs.
            // ManagerJob_Production.GlobalWork();
            DeepProfiler.End();

            // clear turbine cells.
            DeepProfiler.Start("Global work for forestry manager");
            DeepProfiler.End();
        }
Beispiel #13
0
        public override void Generate(Map map, GenStepParams parms)
        {
            DeepProfiler.Start("GenerateInitialFogGrid");
            map.fogGrid.SetAllFogged();
            FloodFillerFog.FloodUnfog(MapGenerator.PlayerStartSpot, map);
            List <IntVec3> rootsToUnfog = MapGenerator.rootsToUnfog;

            for (int i = 0; i < rootsToUnfog.Count; i++)
            {
                FloodFillerFog.FloodUnfog(rootsToUnfog[i], map);
            }
            DeepProfiler.End();
        }
        public static World GenerateWorld(float planetCoverage, string seedString, OverallRainfall overallRainfall, OverallTemperature overallTemperature)
        {
            DeepProfiler.Start("GenerateWorld");
            Rand.PushState();
            int seedFromSeedString = WorldGenerator.GetSeedFromSeedString(seedString);

            Rand.Seed = seedFromSeedString;
            World creatingWorld;

            try
            {
                Current.CreatingWorld = new World();
                Current.CreatingWorld.info.seedString         = seedString;
                Current.CreatingWorld.info.planetCoverage     = planetCoverage;
                Current.CreatingWorld.info.overallRainfall    = overallRainfall;
                Current.CreatingWorld.info.overallTemperature = overallTemperature;
                Current.CreatingWorld.info.name = NameGenerator.GenerateName(RulePackDefOf.NamerWorld, null, false, null, null);
                WorldGenerator.tmpGenSteps.Clear();
                WorldGenerator.tmpGenSteps.AddRange(WorldGenerator.GenStepsInOrder);
                for (int i = 0; i < WorldGenerator.tmpGenSteps.Count; i++)
                {
                    DeepProfiler.Start("WorldGenStep - " + WorldGenerator.tmpGenSteps[i]);
                    try
                    {
                        Rand.Seed = Gen.HashCombineInt(seedFromSeedString, WorldGenerator.GetSeedPart(WorldGenerator.tmpGenSteps, i));
                        WorldGenerator.tmpGenSteps[i].worldGenStep.GenerateFresh(seedString);
                    }
                    catch (Exception arg)
                    {
                        Log.Error("Error in WorldGenStep: " + arg, false);
                    }
                    finally
                    {
                        DeepProfiler.End();
                    }
                }
                Rand.Seed = seedFromSeedString;
                Current.CreatingWorld.grid.StandardizeTileData();
                Current.CreatingWorld.FinalizeInit();
                Find.Scenario.PostWorldGenerate();
                creatingWorld = Current.CreatingWorld;
            }
            finally
            {
                Rand.PopState();
                DeepProfiler.End();
                Current.CreatingWorld = null;
            }
            return(creatingWorld);
        }
        public static bool Prefix(Map map)
        {
            ModExt_Biome_FeatureControl extFtControl = map.Biome.GetModExtension <ModExt_Biome_FeatureControl>();

            if (extFtControl == null || extFtControl.overwriteRoof != RoofOverwriteType.FullStable)
            {
                return(true);
            }
            DeepProfiler.Start("RebuildAllRegions");
            map.regionAndRoomUpdater.RebuildAllRegionsAndRooms();
            DeepProfiler.End();
            MapGenerator.PlayerStartSpot = CellFinderLoose.TryFindCentralCell(map, 7, MinRoomCellCount, (IntVec3 x) => x.CloseToEdge(map, MaxDistanceToEdge));
            return(false);
        }
Beispiel #16
0
        public static bool ExecuteToExecuteWhenFinished()
        {
            if (executingToExecuteWhenFinished)
            {
                Log.Warning("Already executing.", false);
                return(false);
            }
            executingToExecuteWhenFinished = true;
            if (toExecuteWhenFinished.Count > 0)
            {
                DeepProfiler.Start("ExecuteToExecuteWhenFinished()");
            }
            Action action;

            for (int i = 0; i < toExecuteWhenFinished.Count; i++)
            {
                action = null;
                try
                {
                    action = toExecuteWhenFinished[i];
                }
                catch (ArgumentOutOfRangeException) { break; }
                if (null == action)
                {
                    break;
                }
                DeepProfiler.Start(action.Method.DeclaringType.ToString() + " -> " + action.Method.ToString());
                try
                {
                    action();
                }
                catch (Exception arg)
                {
                    Log.Error("Could not execute post-long-event action. Exception: " + arg, false);
                }
                finally
                {
                    DeepProfiler.End();
                }
            }
            if (toExecuteWhenFinished.Count > 0)
            {
                DeepProfiler.End();
            }
            toExecuteWhenFinished.Clear();
            executingToExecuteWhenFinished = false;
            return(false);
        }
Beispiel #17
0
        static bool Prefix(Dictionary <XmlNode, LoadableXmlAsset> assetlookup)
        {
            DeepProfiler.Start("Applying Patches");

            // setup table of patch ownership
            if (!Memory.Instance.init())
            {
                // failure tells no patches were found
                // if this is the case, return false to avoid the index crash related to iterting an empty list in ApplyPatches
                return(false);
            }

            // Blank the current mod/file since it's not present for vanilla patching.
            Memory.Instance.setModAndFile("", "", true);
            Memory.Instance.setassetlookup(assetlookup);
            return(true);
        }
 private static void ApplySaveGamePatches()
 {
     DeepProfiler.Start("Patching Save Game");
     LoadGameFromSaveFilePatch.LoadSaveGamePatches();
     LoadGameFromSaveFilePatch.LoadNotPresentPatches();
     Log.Message(string.Format("Applying {0:d} SaveGamePatches", SaveGamePatches.patches.Count));
     foreach (PatchOperation patch in SaveGamePatches.patches)
     {
         patch.Apply(Scribe.loader.curXmlParent.OwnerDocument);
     }
     Log.Message(string.Format("Applying {0:d} NotPresent Patches", SaveGamePatches.notPresentPatches.Count));
     foreach (PatchOperation patch in SaveGamePatches.notPresentPatches)
     {
         patch.Apply(Scribe.loader.curXmlParent.OwnerDocument);
     }
     DeepProfiler.End();
 }
Beispiel #19
0
 public void Run()
 {
     if (DeepProfiler.enabled)
     {
         DeepProfiler.Start(ToString());
     }
     try
     {
         RunInt();
     }
     catch (Exception ex)
     {
         Log.Error("Exception running " + GetType().Name + ": " + ex + "\n\nSlate vars:\n" + QuestGen.slate.ToString());
     }
     if (DeepProfiler.enabled)
     {
         DeepProfiler.End();
     }
 }
Beispiel #20
0
 public void Run()
 {
     if (DeepProfiler.enabled)
     {
         DeepProfiler.Start(ToString());
     }
     try
     {
         RunInt();
     }
     catch (Exception ex)
     {
         Log.Error(string.Concat("Exception running ", GetType().Name, ": ", ex, "\n\nSlate vars:\n", QuestGen.slate.ToString()));
     }
     if (DeepProfiler.enabled)
     {
         DeepProfiler.End();
     }
 }
Beispiel #21
0
        //static void Prefix(IEnumerable<GenStepWithParams> genStepDefs, Map map, int seed)
        static bool Prefix(Map map, int seed)
        {
            if (!map.Biome.defName.Equals("Ocean"))
            {
                return(true);
            }

            //based on MapGenerator.GenerateMap
            //MapGenerator.data.Clear();
            Rand.PushState();
            try
            {
                Rand.Seed = seed;
                RockNoises.Init(map);
                //OceanGenSteps.Clear();
                //OceanGenSteps.AddRange((IEnumerable<GenStepWithParams>)genStepDefs.OrderBy<GenStepWithParams, float>((Func<GenStepWithParams, float>)(x => x.def.order)).ThenBy<GenStepWithParams, ushort>((Func<GenStepWithParams, ushort>)(x => x.def.index)));
                for (int index = 0; index < WaterGenerator.oceanGenSteps.Count; ++index)
                {
                    DeepProfiler.Start("GenStep - " + (object)WaterGenerator.oceanGenSteps[index].def);
                    try
                    {
                        //Rand.Seed = Gen.HashCombineInt(seed, MapGenerator.GetSeedPart(OceanGenSteps, index));
                        WaterGenerator.oceanGenSteps[index].def.genStep.Generate(map, WaterGenerator.oceanGenSteps[index].parms);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Error in GenStep: " + (object)ex, false);
                    }
                    finally
                    {
                        DeepProfiler.End();
                    }
                }
            }
            finally
            {
                Rand.PopState();
                RockNoises.Reset();
                //MapGenerator.data.Clear();
            }

            return(false);
        }
Beispiel #22
0
        public void LoadModCheckPatches()
        {
            DeepProfiler.Start("Loading all ModCheck patches");
            this.patches = new List <PatchOperation>();
            int modIndex = -1;

            foreach (ModContentPack mod in LoadedModManager.RunningMods)
            {
                ++modIndex;
                List <LoadableXmlAsset> list = DirectXmlLoader.XmlAssetsInModFolder(mod, "ModCheckPatches/").ToList <LoadableXmlAsset>();
                for (int i = 0; i < list.Count; i++)
                {
                    XmlElement documentElement = list[i].xmlDoc.DocumentElement;
                    if (documentElement.Name != "Patch")
                    {
                        Log.Error(string.Format("Unexpected document element in patch XML; got {0}, expected 'Patch'", documentElement.Name), false);
                    }
                    else
                    {
                        for (int j = 0; j < documentElement.ChildNodes.Count; j++)
                        {
                            XmlNode xmlNode = documentElement.ChildNodes[j];
                            if (xmlNode.NodeType == XmlNodeType.Element)
                            {
                                if (xmlNode.Name != "Operation")
                                {
                                    Log.Error(string.Format("Unexpected element in patch XML; got {0}, expected 'Operation'", documentElement.ChildNodes[j].Name), false);
                                }
                                else
                                {
                                    PatchOperation patchOperation = DirectXmlToObject.ObjectFromXml <PatchOperation>(xmlNode, false);
                                    patchOperation.sourceFile = list[i].FullFilePath;
                                    this.patches.Add(patchOperation);
                                    PatchMemory.Add(new PatchMemoryModule(modIndex, mod.Name, patchOperation, true));
                                }
                            }
                        }
                    }
                }
            }
            DeepProfiler.End();
        }
Beispiel #23
0
        public static void LoadInMainThread(TempGameData gameData)
        {
            DeepProfiler.Start("Multiplayer LoadInMainThread");

            ClearState();
            MemoryUtility.ClearAllMapsAndWorld();

            LoadPatch.gameToLoad = gameData;

            CancelRootPlayStartLongEvents.cancel = true;
            Find.Root.Start();
            CancelRootPlayStartLongEvents.cancel = false;

            // SaveCompression enabled in the patch
            SavedGameLoaderNow.LoadGameFromSaveFileNow(null);

            Log.Message($"loading stack {FactionContext.stack.Count}");

            DeepProfiler.End();
        }
        public static void load(ref List <Thing> thingsToLoad, string fileLocation, Thing currentSource)
        {
            Log.Message("ScribeINIT, loding from:" + fileLocation);
            Scribe.loader.InitLoading(fileLocation);

            //Scribe.EnterNode("Stargate");

            Log.Message("DeepProfiler.Start()");
            DeepProfiler.Start("Load non-compressed things");

            // List<Thing> list2 = (List<Thing>)null;
            Log.Message("Scribe_Collections.LookList");
            Scribe_Collections.Look <Thing>(ref thingsToLoad, "things", LookMode.Deep);
            Log.Message("List1Count:" + thingsToLoad.Count);

            Log.Message("DeepProfiler.End()");
            DeepProfiler.End();

            //Scribe.ExitNode();
            Scribe.mode = LoadSaveMode.Inactive;

            //Log.Message("list: " + thingsToLoad.Count.ToString());


            Log.Message("Exit Node");
            //Scribe.ExitNode();


            Log.Message("ResolveAllCrossReferences");
            //CrossRefHandler
            var c = new CrossRefHandler();

            c.ResolveAllCrossReferences();

            Log.Message("DoAllPostLoadInits");
            var p = new PostLoadIniter();

            p.DoAllPostLoadInits();

            Log.Message("Return");
        }
Beispiel #25
0
        static bool Prefix(Verse.ModContentPack __instance)
        {
            DeepProfiler.Start("Loading all patches");
            List <PatchOperation> lst = new List <PatchOperation>();

            typeof(ModContentPack).GetField("patches", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
            .SetValue(__instance, lst);
            List <LoadableXmlAsset> list = DirectXmlLoader.XmlAssetsInModFolder(__instance, "Patches/").ToList <LoadableXmlAsset>();

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement documentElement = list[i].xmlDoc.DocumentElement;
                if (documentElement.Name != "Patch")
                {
                    Log.Error(string.Format("Unexpected document element in patch XML; got {0}, expected 'Patch'", documentElement.Name), false);
                }
                else
                {
                    foreach (XmlNode xmlNode in documentElement.ChildNodes)
                    {
                        if (xmlNode.NodeType == XmlNodeType.Element)
                        {
                            if (xmlNode.Name != "Operation")
                            {
                                Log.Error(string.Format("Unexpected element in patch XML; got {0}, expected 'Operation'", xmlNode.Name), false);
                            }
                            else
                            {
                                PatchOperation patchOperation = DirectXmlToObject.ObjectFromXml <PatchOperation>(xmlNode, false);
                                patchOperation.sourceFile = list[i].FullFilePath;
                                lst.Add(patchOperation);
                            }
                        }
                    }
                }
            }
            DeepProfiler.End();

            return(false);
        }
Beispiel #26
0
 public static void ReloadAllBackstories()
 {
     foreach (Backstory item in DirectXmlLoader.LoadXmlDataInResourcesFolder <Backstory>("Backstories/Shuffled"))
     {
         DeepProfiler.Start("Backstory.PostLoad");
         try
         {
             item.PostLoad();
         }
         finally
         {
             DeepProfiler.End();
         }
         DeepProfiler.Start("Backstory.ResolveReferences");
         try
         {
             item.ResolveReferences();
         }
         finally
         {
             DeepProfiler.End();
         }
         foreach (string item2 in item.ConfigErrors(ignoreNoSpawnCategories: false))
         {
             Log.Error(item.title + ": " + item2);
         }
         DeepProfiler.Start("AddBackstory");
         try
         {
             AddBackstory(item);
         }
         finally
         {
             DeepProfiler.End();
         }
     }
     SolidBioDatabase.LoadAllBios();
 }
Beispiel #27
0
        public static World GenerateWorld(float planetCoverage, string seedString, OverallRainfall overallRainfall, OverallTemperature overallTemperature)
        {
            DeepProfiler.Start("GenerateWorld");
            Rand.Seed             = (GenText.StableStringHash(seedString) ^ 4323276);
            Current.CreatingWorld = new World();
            Current.CreatingWorld.info.planetCoverage     = planetCoverage;
            Current.CreatingWorld.info.seedString         = seedString;
            Current.CreatingWorld.info.overallRainfall    = overallRainfall;
            Current.CreatingWorld.info.overallTemperature = overallTemperature;
            Current.CreatingWorld.info.name = NameGenerator.GenerateName(RulePackDefOf.NamerWorld, null, false, null);
            foreach (WorldGenStepDef current in from gs in DefDatabase <WorldGenStepDef> .AllDefs
                     orderby gs.order
                     select gs)
            {
                DeepProfiler.Start("WorldGenStep - " + current);
                try
                {
                    current.worldGenStep.GenerateFresh(seedString);
                }
                catch (Exception arg)
                {
                    Log.Error("Error in WorldGenStep: " + arg);
                }
                finally
                {
                    DeepProfiler.End();
                }
            }
            Current.CreatingWorld.grid.StandardizeTileData();
            Current.CreatingWorld.FinalizeInit();
            Find.Scenario.PostWorldGenerate();
            World creatingWorld = Current.CreatingWorld;

            Current.CreatingWorld = null;
            DeepProfiler.End();
            return(creatingWorld);
        }
Beispiel #28
0
        /// <summary>
        /// Generate a minimal map with elevation and fertility grids
        /// </summary>
        private static MapGridSet GenerateMapGrids(int mapTile, int mapSize, bool revealCaves)
        {
            DeepProfiler.Start("generateMapPreviewGrids");
            try {
                Rand.PushState();
                var mapGeneratorData = (Dictionary <string, object>)ReflectionCache.MapGenerator_Data.GetValue(null);
                mapGeneratorData.Clear();

                var map = CreateMapStub(mapSize, mapTile);
                MapGenerator.mapBeingGenerated = map;

                var mapSeed = Gen.HashCombineInt(Find.World.info.Seed, map.Tile);
                Rand.Seed = mapSeed;
                RockNoises.Init(map);

                var elevationFertilityGenstep = new GenStep_ElevationFertility();
                Rand.Seed = Gen.HashCombineInt(mapSeed, elevationFertilityGenstep.SeedPart);
                elevationFertilityGenstep.Generate(map, new GenStepParams());

                if (revealCaves)
                {
                    var cavesGenstep = new GenStep_Caves();
                    Rand.Seed = Gen.HashCombineInt(mapSeed, cavesGenstep.SeedPart);
                    cavesGenstep.Generate(map, new GenStepParams());
                }

                var result = new MapGridSet(MapGenerator.Elevation, MapGenerator.Fertility, MapGenerator.Caves, map);
                mapGeneratorData.Clear();

                return(result);
            } finally {
                DeepProfiler.End();
                MapGenerator.mapBeingGenerated = null;
                Rand.PopState();
            }
        }
Beispiel #29
0
        static bool Prefix()
        {
            foreach (Type type in GenTypes.AllTypesWithAttribute <StaticConstructorOnStartup>())
            {
                DeepProfiler.Start($"Static ctor: {type.FullName}");

                try
                {
                    RuntimeHelpers.RunClassConstructor(type.TypeHandle);
                }
                catch (Exception ex)
                {
                    Log.Error(string.Concat("Error in static constructor of ", type, ": ", ex));
                }
                finally
                {
                    DeepProfiler.End();
                }
            }

            StaticConstructorOnStartupUtility.coreStaticAssetsLoaded = true;

            return(false);
        }
Beispiel #30
0
        public static Quest Generate(QuestScriptDef root, Slate initialVars)
        {
            if (DeepProfiler.enabled)
            {
                DeepProfiler.Start("Generate quest");
            }
            Quest result = null;

            try
            {
                if (working)
                {
                    throw new Exception("Called Generate() while already working.");
                }
                working       = true;
                QuestGen.root = root;
                slate.Reset();
                slate.SetAll(initialVars);
                quest = Quest.MakeRaw();
                quest.ticksUntilAcceptanceExpiry = (int)(root.expireDaysRange.RandomInRange * 60000f);
                if (root.defaultChallengeRating > 0)
                {
                    quest.challengeRating = root.defaultChallengeRating;
                }
                quest.root   = root;
                quest.hidden = root.defaultHidden;
                slate.SetIfNone("inSignal", quest.InitiateSignal);
                root.Run();
                try
                {
                    QuestNode_ResolveQuestName.Resolve();
                }
                catch (Exception arg)
                {
                    Log.Error("Error while generating quest name: " + arg);
                }
                try
                {
                    QuestNode_ResolveQuestDescription.Resolve();
                }
                catch (Exception arg2)
                {
                    Log.Error("Error while generating quest description: " + arg2);
                }
                try
                {
                    QuestNode_ResolveTextRequests.Resolve();
                }
                catch (Exception arg3)
                {
                    Log.Error("Error while resolving text requests: " + arg3);
                }
                AddSlateQuestTags();
                bool flag = root.autoAccept;
                if (flag)
                {
                    List <QuestPart> partsListForReading = quest.PartsListForReading;
                    for (int i = 0; i < partsListForReading.Count; i++)
                    {
                        if (partsListForReading[i].PreventsAutoAccept)
                        {
                            flag = false;
                            break;
                        }
                    }
                }
                if (flag)
                {
                    quest.SetInitiallyAccepted();
                }
                result = quest;
                return(result);
            }
            catch (Exception arg4)
            {
                Log.Error("Error in QuestGen: " + arg4);
                return(result);
            }
            finally
            {
                if (DeepProfiler.enabled)
                {
                    DeepProfiler.End();
                }
                quest         = null;
                QuestGen.root = null;
                working       = false;
                generatedPawns.Clear();
                textRequests.Clear();
                slate.Reset();
                questDescriptionRules.Clear();
                questDescriptionConstants.Clear();
                questNameRules.Clear();
                questNameConstants.Clear();
                questContentRules.Clear();
                slateQuestTagsToAddWhenFinished.Clear();
                ResetIdCounters();
            }
        }