public void SetRootPosAndSize(Vector3 rootPos, float rootSize) { this.rootPos = rootPos; this.rootSize = rootSize; desiredDolly = Vector2.zero; desiredDollyRaw = Vector2.zero; desiredSize = rootSize; dragTimeStamps.Clear(); LongEventHandler.ExecuteWhenFinished(ApplyPositionToGameObject); }
public void ReloadContent() { LongEventHandler.ExecuteWhenFinished(delegate { this.audioClips.ReloadAll(); this.textures.ReloadAll(); this.strings.ReloadAll(); }); this.assemblies.ReloadAll(); }
public override void PostLoad() { treeNode = new TreeNode_ThingCategory(this); if (!iconPath.NullOrEmpty()) { LongEventHandler.ExecuteWhenFinished(delegate { icon = ContentFinder <Texture2D> .Get(iconPath); }); } }
public void ClearDestroy() { LongEventHandler.ExecuteWhenFinished(delegate { for (int i = 0; i < loadedAssetBundles.Count; i++) { loadedAssetBundles[i].Unload(unloadAllLoadedObjects: true); } loadedAssetBundles.Clear(); }); }
public override void PostLoad() { base.PostLoad(); if (this.defName == "UnnamedDef") { this.defName = "Scatterable_" + this.texturePath; } LongEventHandler.ExecuteWhenFinished(delegate { this.mat = MaterialPool.MatFrom(this.texturePath, ShaderDatabase.Transparent); }); }
public override void PostLoad() { placingDraggableDimensions = 2; LongEventHandler.ExecuteWhenFinished(delegate { Shader shader = null; switch (edgeType) { case TerrainEdgeType.Hard: shader = ShaderDatabase.TerrainHard; break; case TerrainEdgeType.Fade: shader = ShaderDatabase.TerrainFade; break; case TerrainEdgeType.FadeRough: shader = ShaderDatabase.TerrainFadeRough; break; case TerrainEdgeType.Water: shader = ShaderDatabase.TerrainWater; break; } graphic = GraphicDatabase.Get <Graphic_Terrain>(texturePath, shader, Vector2.one, color, 2000 + renderPrecedence); if (shader == ShaderDatabase.TerrainFadeRough || shader == ShaderDatabase.TerrainWater) { graphic.MatSingle.SetTexture("_AlphaAddTex", TexGame.AlphaAddTex); } if (!waterDepthShader.NullOrEmpty()) { waterDepthMaterial = MaterialAllocator.Create(ShaderDatabase.LoadShader(waterDepthShader)); waterDepthMaterial.renderQueue = 2000 + renderPrecedence; waterDepthMaterial.SetTexture("_AlphaAddTex", TexGame.AlphaAddTex); if (waterDepthShaderParameters != null) { for (int j = 0; j < waterDepthShaderParameters.Count; j++) { waterDepthShaderParameters[j].Apply(waterDepthMaterial); } } } }); if (tools != null) { for (int i = 0; i < tools.Count; i++) { tools[i].id = i.ToString(); } } base.PostLoad(); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { if (this.def.IsEdifice()) { map.edificeGrid.Register(this); } base.SpawnSetup(map, respawningAfterLoad); base.Map.listerBuildings.Add(this); if (this.def.coversFloor) { base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Terrain, true, false); } CellRect cellRect = this.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { IntVec3 intVec = new IntVec3(j, 0, i); base.Map.mapDrawer.MapMeshDirty(intVec, MapMeshFlag.Buildings); base.Map.glowGrid.MarkGlowGridDirty(intVec); if (!SnowGrid.CanCoexistWithSnow(this.def)) { base.Map.snowGrid.SetDepth(intVec, 0f); } } } if (base.Faction == Faction.OfPlayer) { if (this.def.building != null && this.def.building.spawnedConceptLearnOpportunity != null) { LessonAutoActivator.TeachOpportunity(this.def.building.spawnedConceptLearnOpportunity, OpportunityType.GoodToKnow); } } AutoHomeAreaMaker.Notify_BuildingSpawned(this); if (this.def.building != null && !this.def.building.soundAmbient.NullOrUndefined()) { LongEventHandler.ExecuteWhenFinished(delegate { SoundInfo info = SoundInfo.InMap(this, MaintenanceType.None); this.sustainerAmbient = this.def.building.soundAmbient.TrySpawnSustainer(info); }); } base.Map.listerBuildingsRepairable.Notify_BuildingSpawned(this); if (!this.CanBeSeenOver()) { base.Map.exitMapGrid.Notify_LOSBlockerSpawned(); } SmoothSurfaceDesignatorUtility.Notify_BuildingSpawned(this); }
public void ClearDestroy() { if (typeof(Object).IsAssignableFrom(typeof(T))) { foreach (T value in this.contentList.Values) { T localObj = value; LongEventHandler.ExecuteWhenFinished(delegate { Object.Destroy((Object)(object)localObj); }); } } this.contentList.Clear(); }
public override void PostLoad() { base.PostLoad(); LongEventHandler.ExecuteWhenFinished(delegate { if (!uiIconPath.NullOrEmpty()) { uiIcon = ContentFinder <Texture2D> .Get(uiIconPath); } else { ResolveIcon(); } }); }
public void ClearDestroy() { if (typeof(UnityEngine.Object).IsAssignableFrom(typeof(T))) { foreach (T current in this.contentList.Values) { T localObj = current; LongEventHandler.ExecuteWhenFinished(delegate { UnityEngine.Object.Destroy((UnityEngine.Object)((object)localObj)); }); } } this.contentList.Clear(); }
public void ResolveReferencesSpecial() { LongEventHandler.ExecuteWhenFinished(delegate { if (scratches != null) { scratchMats = new List <Material>(); for (int i = 0; i < scratches.Count; i++) { scratchMats[i] = MaterialPool.MatFrom(scratches[i], ShaderDatabase.Transparent); } } if (cornerTL != null) { cornerTLMat = MaterialPool.MatFrom(cornerTL, ShaderDatabase.Transparent); } if (cornerTR != null) { cornerTRMat = MaterialPool.MatFrom(cornerTR, ShaderDatabase.Transparent); } if (cornerBL != null) { cornerBLMat = MaterialPool.MatFrom(cornerBL, ShaderDatabase.Transparent); } if (cornerBR != null) { cornerBRMat = MaterialPool.MatFrom(cornerBR, ShaderDatabase.Transparent); } if (edgeTop != null) { edgeTopMat = MaterialPool.MatFrom(edgeTop, ShaderDatabase.Transparent); } if (edgeBot != null) { edgeBotMat = MaterialPool.MatFrom(edgeBot, ShaderDatabase.Transparent); } if (edgeLeft != null) { edgeLeftMat = MaterialPool.MatFrom(edgeLeft, ShaderDatabase.Transparent); } if (edgeRight != null) { edgeRightMat = MaterialPool.MatFrom(edgeRight, ShaderDatabase.Transparent); } }); }
public static void FlushToFileAndOpen() { if (messages.Count != 0) { string value = CompiledLog(); string path = GenFilePaths.SaveDataFolderPath + Path.DirectorySeparatorChar + "LogSimple.txt"; using (StreamWriter streamWriter = new StreamWriter(path, append: false)) { streamWriter.Write(value); } LongEventHandler.ExecuteWhenFinished(delegate { Application.OpenURL(path); }); messages.Clear(); } }
public override void PostLoad() { this.placingDraggableDimensions = 2; LongEventHandler.ExecuteWhenFinished(delegate { Shader shader = null; switch (this.edgeType) { case TerrainDef.TerrainEdgeType.Hard: shader = ShaderDatabase.TerrainHard; break; case TerrainDef.TerrainEdgeType.Fade: shader = ShaderDatabase.TerrainFade; break; case TerrainDef.TerrainEdgeType.FadeRough: shader = ShaderDatabase.TerrainFadeRough; break; case TerrainDef.TerrainEdgeType.Water: shader = ShaderDatabase.TerrainWater; break; } this.graphic = GraphicDatabase.Get <Graphic_Terrain>(this.texturePath, shader, Vector2.one, this.color, 2000 + this.renderPrecedence); if (shader == ShaderDatabase.TerrainFadeRough || shader == ShaderDatabase.TerrainWater) { this.graphic.MatSingle.SetTexture("_AlphaAddTex", TexGame.AlphaAddTex); } if (!this.waterDepthShader.NullOrEmpty()) { this.waterDepthMaterial = new Material(ShaderDatabase.LoadShader(this.waterDepthShader)); this.waterDepthMaterial.renderQueue = 2000 + this.renderPrecedence; this.waterDepthMaterial.SetTexture("_AlphaAddTex", TexGame.AlphaAddTex); if (this.waterDepthShaderParameters != null) { for (int i = 0; i < this.waterDepthShaderParameters.Count; i++) { this.waterDepthMaterial.SetFloat(this.waterDepthShaderParameters[i].name, this.waterDepthShaderParameters[i].value); } } } }); base.PostLoad(); }
public override void PostLoad() { base.PostLoad(); LongEventHandler.ExecuteWhenFinished(delegate { if (!this.iconMiss.NullOrEmpty()) { this.iconMissTex = ContentFinder <Texture2D> .Get(this.iconMiss, true); } if (!this.iconDamaged.NullOrEmpty()) { this.iconDamagedTex = ContentFinder <Texture2D> .Get(this.iconDamaged, true); } if (!this.iconDamagedFromInstigator.NullOrEmpty()) { this.iconDamagedFromInstigatorTex = ContentFinder <Texture2D> .Get(this.iconDamagedFromInstigator, true); } }); }
private void RecalculateLifeStageIndex() { int num = -1; List <LifeStageAge> lifeStageAges = this.pawn.RaceProps.lifeStageAges; int num2 = lifeStageAges.Count - 1; while (num2 >= 0) { if (!(lifeStageAges[num2].minAge <= this.AgeBiologicalYearsFloat + 9.9999999747524271E-07)) { num2--; continue; } num = num2; break; } if (num == -1) { num = 0; } bool flag = this.cachedLifeStageIndex != num; this.cachedLifeStageIndex = num; if (flag && !this.pawn.RaceProps.Humanlike) { LongEventHandler.ExecuteWhenFinished(delegate { this.pawn.Drawer.renderer.graphics.ResolveAllGraphics(); }); this.CheckChangePawnKindName(); } if (this.cachedLifeStageIndex < lifeStageAges.Count - 1) { float num3 = lifeStageAges[this.cachedLifeStageIndex + 1].minAge - this.AgeBiologicalYearsFloat; int num4 = (Current.ProgramState == ProgramState.Playing) ? Find.TickManager.TicksGame : 0; this.nextLifeStageChangeTick = num4 + Mathf.CeilToInt((float)(num3 * 3600000.0)); } else { this.nextLifeStageChangeTick = 2147483647; } }
private void Init() { this.meta = DirectXmlLoader.ItemFromXmlFile <ModMetaDataInternal>(this.RootDir.FullName + Path.DirectorySeparatorChar + "About" + Path.DirectorySeparatorChar + "About.xml", true); if (this.meta.name.NullOrEmpty()) { if (this.OnSteamWorkshop) { this.meta.name = "Workshop mod " + this.Identifier; } else { this.meta.name = this.Identifier; } } if (!this.IsCoreMod && !this.OnSteamWorkshop && !VersionControl.IsWellFormattedVersionString(this.meta.targetVersion)) { Log.ErrorOnce("Mod " + this.meta.name + " has incorrectly formatted target version '" + this.meta.targetVersion + "'. For the current version, write: <targetVersion>" + VersionControl.CurrentVersionString + "</targetVersion>", this.Identifier.GetHashCode()); } LongEventHandler.ExecuteWhenFinished(delegate { string url = GenFilePaths.SafeURIForUnityWWWFromPath(this.PreviewImagePath); using (WWW wWW = new WWW(url)) { wWW.threadPriority = UnityEngine.ThreadPriority.High; while (!wWW.isDone) { Thread.Sleep(1); } if (wWW.error == null) { this.previewImage = wWW.textureNonReadable; } } }); string publishedFileIdPath = this.PublishedFileIdPath; if (File.Exists(this.PublishedFileIdPath)) { string s = File.ReadAllText(publishedFileIdPath); this.publishedFileIdInt = new PublishedFileId_t(ulong.Parse(s)); } }
public void ClearDestroy() { if (typeof(UnityEngine.Object).IsAssignableFrom(typeof(T))) { foreach (T value in contentList.Values) { T localObj = value; LongEventHandler.ExecuteWhenFinished(delegate { UnityEngine.Object.Destroy((UnityEngine.Object)(object) localObj); }); } } for (int i = 0; i < extraDisposables.Count; i++) { extraDisposables[i].Dispose(); } extraDisposables.Clear(); contentList.Clear(); }
private void RecalculateLifeStageIndex() { int num = -1; List <LifeStageAge> lifeStageAges = pawn.RaceProps.lifeStageAges; for (int num2 = lifeStageAges.Count - 1; num2 >= 0; num2--) { if (lifeStageAges[num2].minAge <= AgeBiologicalYearsFloat + 1E-06f) { num = num2; break; } } if (num == -1) { num = 0; } bool num3 = cachedLifeStageIndex != num; cachedLifeStageIndex = num; if (num3 && !pawn.RaceProps.Humanlike) { LongEventHandler.ExecuteWhenFinished(delegate { pawn.Drawer.renderer.graphics.SetAllGraphicsDirty(); }); CheckChangePawnKindName(); } if (cachedLifeStageIndex < lifeStageAges.Count - 1) { float num4 = lifeStageAges[cachedLifeStageIndex + 1].minAge - AgeBiologicalYearsFloat; int num5 = ((Current.ProgramState == ProgramState.Playing) ? Find.TickManager.TicksGame : 0); nextLifeStageChangeTick = num5 + (long)Mathf.Ceil(num4 * 3600000f); } else { nextLifeStageChangeTick = long.MaxValue; } }
private void RecalculateLifeStageIndex() { int num = -1; List <LifeStageAge> lifeStageAges = this.pawn.RaceProps.lifeStageAges; for (int i = lifeStageAges.Count - 1; i >= 0; i--) { if (lifeStageAges[i].minAge <= this.AgeBiologicalYearsFloat + 1E-06f) { num = i; break; } } if (num == -1) { num = 0; } bool flag = this.cachedLifeStageIndex != num; this.cachedLifeStageIndex = num; if (flag && !this.pawn.RaceProps.Humanlike) { LongEventHandler.ExecuteWhenFinished(delegate { this.pawn.Drawer.renderer.graphics.ResolveAllGraphics(); }); this.CheckChangePawnKindName(); } if (this.cachedLifeStageIndex < lifeStageAges.Count - 1) { float num2 = lifeStageAges[this.cachedLifeStageIndex + 1].minAge - this.AgeBiologicalYearsFloat; int num3 = (Current.ProgramState != ProgramState.Playing) ? 0 : Find.TickManager.TicksGame; this.nextLifeStageChangeTick = (long)num3 + (long)Mathf.Ceil(num2 * 3600000f); } else { this.nextLifeStageChangeTick = 9223372036854775807L; } }
public static void LoadModContent() { LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("LoadModContent"); }); for (int i = 0; i < runningMods.Count; i++) { ModContentPack modContentPack = runningMods[i]; DeepProfiler.Start("Loading " + modContentPack + " content"); try { modContentPack.ReloadContent(); } catch (Exception ex) { Log.Error("Could not reload mod content for mod " + modContentPack.PackageIdPlayerFacing + ": " + ex); } finally { DeepProfiler.End(); } } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.End(); for (int j = 0; j < runningMods.Count; j++) { ModContentPack modContentPack2 = runningMods[j]; if (!modContentPack2.AnyContentLoaded()) { Log.Error("Mod " + modContentPack2.Name + " did not load any content. Following load folders were used:\n" + modContentPack2.foldersToLoadDescendingOrder.ToLineList(" - ")); } } }); }
public void LoadGame() { if (this.maps.Any <Map>()) { Log.Error("Called LoadGame() but there already is a map. There should be 0 maps...", false); return; } MemoryUtility.UnloadUnusedUnityAssets(); Current.ProgramState = ProgramState.MapInitializing; this.ExposeSmallComponents(); LongEventHandler.SetCurrentEventText("LoadingWorld".Translate()); if (Scribe.EnterNode("world")) { try { this.World = new World(); this.World.ExposeData(); } finally { Scribe.ExitNode(); } this.World.FinalizeInit(); LongEventHandler.SetCurrentEventText("LoadingMap".Translate()); Scribe_Collections.Look <Map>(ref this.maps, "maps", LookMode.Deep, new object[0]); if (this.maps.RemoveAll((Map x) => x == null) != 0) { Log.Warning("Some maps were null after loading.", false); } int num = -1; Scribe_Values.Look <int>(ref num, "currentMapIndex", -1, false); if (num < 0 && this.maps.Any <Map>()) { Log.Error("Current map is null after loading but there are maps available. Setting current map to [0].", false); num = 0; } if (num >= this.maps.Count) { Log.Error("Current map index out of bounds after loading.", false); if (this.maps.Any <Map>()) { num = 0; } else { num = -1; } } this.currentMapIndex = -128; this.CurrentMap = ((num < 0) ? null : this.maps[num]); LongEventHandler.SetCurrentEventText("InitializingGame".Translate()); Find.CameraDriver.Expose(); DeepProfiler.Start("FinalizeLoading"); Scribe.loader.FinalizeLoading(); DeepProfiler.End(); LongEventHandler.SetCurrentEventText("SpawningAllThings".Translate()); for (int i = 0; i < this.maps.Count; i++) { try { this.maps[i].FinalizeLoading(); } catch (Exception arg) { Log.Error("Error in Map.FinalizeLoading(): " + arg, false); } try { this.maps[i].Parent.FinalizeLoading(); } catch (Exception arg2) { Log.Error("Error in MapParent.FinalizeLoading(): " + arg2, false); } } this.FinalizeInit(); if (Prefs.PauseOnLoad) { LongEventHandler.ExecuteWhenFinished(delegate { Find.TickManager.DoSingleTick(); Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; }); } GameComponentUtility.LoadedGame(); return; } Log.Error("Could not find world XML node.", false); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { //Before base.SpawnSetup() so when regions are rebuilt this building can be accessed via edificeGrid if (def.IsEdifice()) { map.edificeGrid.Register(this); } base.SpawnSetup(map, respawningAfterLoad); Map.listerBuildings.Add(this); //Remake terrain meshes with new underwall under me if (def.coversFloor) { Map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Terrain, true, false); } var occRect = this.OccupiedRect(); for (int z = occRect.minZ; z <= occRect.maxZ; z++) { for (int x = occRect.minX; x <= occRect.maxX; x++) { var c = new IntVec3(x, 0, z); Map.mapDrawer.MapMeshDirty(c, MapMeshFlag.Buildings); Map.glowGrid.MarkGlowGridDirty(c); if (!SnowGrid.CanCoexistWithSnow(def)) { Map.snowGrid.SetDepth(c, 0); } } } if (Faction == Faction.OfPlayer) { if (def.building != null && def.building.spawnedConceptLearnOpportunity != null) { LessonAutoActivator.TeachOpportunity(def.building.spawnedConceptLearnOpportunity, OpportunityType.GoodToKnow); } } AutoHomeAreaMaker.Notify_BuildingSpawned(this); if (def.building != null && !def.building.soundAmbient.NullOrUndefined()) { LongEventHandler.ExecuteWhenFinished(() => { SoundInfo info = SoundInfo.InMap(this, MaintenanceType.None); sustainerAmbient = SoundStarter.TrySpawnSustainer(def.building.soundAmbient, info); }); } Map.listerBuildingsRepairable.Notify_BuildingSpawned(this); if (!this.CanBeSeenOver()) { Map.exitMapGrid.Notify_LOSBlockerSpawned(); } SmoothSurfaceDesignatorUtility.Notify_BuildingSpawned(this); //Must go after adding to buildings list map.avoidGrid.Notify_BuildingSpawned(this); }
private static void DoPlayLoad() { DeepProfiler.Start("GraphicDatabase.Clear()"); try { GraphicDatabase.Clear(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load all active mods."); try { LoadedModManager.LoadAllActiveMods(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load language metadata."); try { LanguageDatabase.InitAllMetadata(); } finally { DeepProfiler.End(); } LongEventHandler.SetCurrentEventText("LoadingDefs".Translate()); DeepProfiler.Start("Copy all Defs from mods to global databases."); try { foreach (Type item in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods"); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between non-implied Defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind defs (early)."); try { DefOfHelper.RebindAllDefOfs(earlyTryMode: true); } finally { DeepProfiler.End(); } DeepProfiler.Start("TKeySystem.BuildMappings()"); try { TKeySystem.BuildMappings(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Inject selected language data into game data (early pass)."); try { LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (pre-resolve)."); try { DefGenerator.GenerateImpliedDefs_PreResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors); } finally { DirectXmlCrossRefLoader.Clear(); DeepProfiler.End(); } DeepProfiler.Start("Rebind DefOfs (final)."); try { DefOfHelper.RebindAllDefOfs(earlyTryMode: false); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve)."); try { PlayerKnowledgeDatabase.ReloadAndRebind(); LessonAutoActivator.Reset(); CostListCalculator.Reset(); Pawn.ResetStaticData(); PawnApparelGenerator.Reset(); RestUtility.Reset(); ThoughtUtility.Reset(); ThinkTreeKeyAssigner.Reset(); ThingCategoryNodeDatabase.FinalizeInit(); TrainableUtility.Reset(); HaulAIUtility.Reset(); GenConstruct.Reset(); MedicalCareUtility.Reset(); InspectPaneUtility.Reset(); GraphicDatabaseHeadRecords.Reset(); DateReadout.Reset(); ResearchProjectDef.GenerateNonOverlappingCoordinates(); BaseGen.Reset(); ResourceCounter.ResetDefs(); ApparelProperties.ResetStaticData(); WildPlantSpawner.ResetStaticData(); PawnGenerator.Reset(); TunnelHiveSpawner.ResetStaticData(); Hive.ResetStaticData(); ExpectationsUtility.Reset(); WealthWatcher.ResetStaticData(); SkillUI.Reset(); QuestNode_GetThingPlayerCanProduce.ResetStaticData(); Pawn_PsychicEntropyTracker.ResetStaticData(); ColoredText.ResetStaticData(); QuestNode_GetRandomNegativeGameCondition.ResetStaticData(); RoyalTitleUtility.ResetStaticData(); RewardsGenerator.ResetStaticData(); WorkGiver_FillFermentingBarrel.ResetStaticData(); WorkGiver_DoBill.ResetStaticData(); WorkGiver_InteractAnimal.ResetStaticData(); WorkGiver_Warden_DoExecution.ResetStaticData(); WorkGiver_GrowerSow.ResetStaticData(); WorkGiver_Miner.ResetStaticData(); WorkGiver_FixBrokenDownBuilding.ResetStaticData(); WorkGiver_ConstructDeliverResources.ResetStaticData(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve references."); try { DeepProfiler.Start("ThingCategoryDef resolver"); try { DefDatabase <ThingCategoryDef> .ResolveAllReferences(); } finally { DeepProfiler.End(); } DeepProfiler.Start("RecipeDef resolver"); try { DeepProfiler.enabled = false; DefDatabase <RecipeDef> .ResolveAllReferences(onlyExactlyMyType : true, parallel : true); DeepProfiler.enabled = true; } finally { DeepProfiler.End(); } DeepProfiler.Start("Static resolver calls"); try { foreach (Type item2 in typeof(Def).AllSubclasses()) { if (!(item2 == typeof(ThingDef)) && !(item2 == typeof(ThingCategoryDef)) && !(item2 == typeof(RecipeDef))) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true, false); } } } finally { DeepProfiler.End(); } DeepProfiler.Start("ThingDef resolver"); try { DefDatabase <ThingDef> .ResolveAllReferences(); } finally { DeepProfiler.End(); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (post-resolve)."); try { DefGenerator.GenerateImpliedDefs_PostResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve)."); try { PawnWeaponGenerator.Reset(); BuildingProperties.FinalizeInit(); ThingSetMakerUtility.Reset(); } finally { DeepProfiler.End(); } if (Prefs.DevMode) { DeepProfiler.Start("Error check all defs."); try { foreach (Type item3 in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs"); } } finally { DeepProfiler.End(); } } LongEventHandler.SetCurrentEventText("Initializing".Translate()); DeepProfiler.Start("Load keyboard preferences."); try { KeyPrefs.Init(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Short hash giving."); try { ShortHashGiver.GiveAllShortHashes(); } finally { DeepProfiler.End(); } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Load backstories."); try { BackstoryDatabase.ReloadAllBackstories(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Inject selected language data into game data."); try { LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs(); GenLabel.ClearCache(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Static constructor calls"); try { StaticConstructorOnStartupUtility.CallAll(); if (Prefs.DevMode) { StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes(); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Garbage Collection"); try { AbstractFilesystem.ClearAllCache(); GC.Collect(int.MaxValue, GCCollectionMode.Forced); } finally { DeepProfiler.End(); } }); }
public void LoadData() { if (this.dataIsLoaded) { return; } this.dataIsLoaded = true; DeepProfiler.Start("Loading language data: " + this.folderName); try { foreach (string current in this.FolderPaths) { string localFolderPath = current; LongEventHandler.ExecuteWhenFinished(delegate { if (this.icon == BaseContent.BadTex) { FileInfo fileInfo = new FileInfo(Path.Combine(localFolderPath.ToString(), "LangIcon.png")); if (fileInfo.Exists) { this.icon = ModContentLoader <Texture2D> .LoadItem(fileInfo.FullName, null).contentItem; } } }); DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(current.ToString(), "CodeLinked")); if (directoryInfo.Exists) { this.loadErrors.Add("Translations aren't called CodeLinked any more. Please rename to Keyed: " + directoryInfo); } else { directoryInfo = new DirectoryInfo(Path.Combine(current.ToString(), "Keyed")); } if (directoryInfo.Exists) { FileInfo[] files = directoryInfo.GetFiles("*.xml", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i]; this.LoadFromFile_Keyed(file); } } DirectoryInfo directoryInfo2 = new DirectoryInfo(Path.Combine(current.ToString(), "DefLinked")); if (directoryInfo2.Exists) { this.loadErrors.Add("Translations aren't called DefLinked any more. Please rename to DefInjected: " + directoryInfo2); } else { directoryInfo2 = new DirectoryInfo(Path.Combine(current.ToString(), "DefInjected")); } if (directoryInfo2.Exists) { DirectoryInfo[] directories = directoryInfo2.GetDirectories("*", SearchOption.TopDirectoryOnly); for (int j = 0; j < directories.Length; j++) { DirectoryInfo directoryInfo3 = directories[j]; string name = directoryInfo3.Name; Type typeInAnyAssembly = GenTypes.GetTypeInAnyAssembly(name); if (typeInAnyAssembly == null && name.Length > 3) { typeInAnyAssembly = GenTypes.GetTypeInAnyAssembly(name.Substring(0, name.Length - 1)); } if (typeInAnyAssembly == null) { this.loadErrors.Add(string.Concat(new string[] { "Error loading language from ", current, ": dir ", directoryInfo3.Name, " doesn't correspond to any def type. Skipping..." })); } else { FileInfo[] files2 = directoryInfo3.GetFiles("*.xml", SearchOption.AllDirectories); for (int k = 0; k < files2.Length; k++) { FileInfo file2 = files2[k]; this.LoadFromFile_DefInject(file2, typeInAnyAssembly); } } } } this.EnsureAllDefTypesHaveDefInjectionPackage(); DirectoryInfo directoryInfo4 = new DirectoryInfo(Path.Combine(current.ToString(), "Strings")); if (directoryInfo4.Exists) { DirectoryInfo[] directories2 = directoryInfo4.GetDirectories("*", SearchOption.TopDirectoryOnly); for (int l = 0; l < directories2.Length; l++) { DirectoryInfo directoryInfo5 = directories2[l]; FileInfo[] files3 = directoryInfo5.GetFiles("*.txt", SearchOption.AllDirectories); for (int m = 0; m < files3.Length; m++) { FileInfo file3 = files3[m]; this.LoadFromFile_Strings(file3, directoryInfo4); } } } this.wordInfo.LoadFrom(current); } } catch (Exception arg) { Log.Error("Exception loading language data. Rethrowing. Exception: " + arg, false); throw; } finally { DeepProfiler.End(); } }
public void LoadGame() { if (maps.Any()) { Log.Error("Called LoadGame() but there already is a map. There should be 0 maps..."); } else { MemoryUtility.UnloadUnusedUnityAssets(); Current.ProgramState = ProgramState.MapInitializing; ExposeSmallComponents(); LongEventHandler.SetCurrentEventText("LoadingWorld".Translate()); if (!Scribe.EnterNode("world")) { Log.Error("Could not find world XML node."); } else { try { World = new World(); World.ExposeData(); } finally { Scribe.ExitNode(); } World.FinalizeInit(); LongEventHandler.SetCurrentEventText("LoadingMap".Translate()); Scribe_Collections.Look(ref maps, "maps", LookMode.Deep); if (maps.RemoveAll((Map x) => x == null) != 0) { Log.Warning("Some maps were null after loading."); } int value = -1; Scribe_Values.Look(ref value, "currentMapIndex", -1); if (value < 0 && maps.Any()) { Log.Error("Current map is null after loading but there are maps available. Setting current map to [0]."); value = 0; } if (value >= maps.Count) { Log.Error("Current map index out of bounds after loading."); value = ((!maps.Any()) ? (-1) : 0); } currentMapIndex = sbyte.MinValue; CurrentMap = ((value < 0) ? null : maps[value]); LongEventHandler.SetCurrentEventText("InitializingGame".Translate()); Find.CameraDriver.Expose(); DeepProfiler.Start("FinalizeLoading"); Scribe.loader.FinalizeLoading(); DeepProfiler.End(); LongEventHandler.SetCurrentEventText("SpawningAllThings".Translate()); for (int i = 0; i < maps.Count; i++) { try { maps[i].FinalizeLoading(); } catch (Exception arg) { Log.Error("Error in Map.FinalizeLoading(): " + arg); } try { maps[i].Parent.FinalizeLoading(); } catch (Exception arg2) { Log.Error("Error in MapParent.FinalizeLoading(): " + arg2); } } FinalizeInit(); if (Prefs.PauseOnLoad) { LongEventHandler.ExecuteWhenFinished(delegate { Find.TickManager.DoSingleTick(); Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; }); } GameComponentUtility.LoadedGame(); } } }
public void ReloadContent() { LongEventHandler.ExecuteWhenFinished(ReloadContentInt); assemblies.ReloadAll(); }
public void LoadData() { if (dataIsLoaded) { return; } dataIsLoaded = true; DeepProfiler.Start("Loading language data: " + folderName); try { tmpAlreadyLoadedFiles.Clear(); foreach (Tuple <VirtualDirectory, ModContentPack, string> allDirectory in AllDirectories) { Tuple <VirtualDirectory, ModContentPack, string> localDirectory = allDirectory; if (!tmpAlreadyLoadedFiles.ContainsKey(localDirectory.Item2)) { tmpAlreadyLoadedFiles[localDirectory.Item2] = new HashSet <string>(); } LongEventHandler.ExecuteWhenFinished(delegate { if (icon == BaseContent.BadTex) { VirtualFile file = localDirectory.Item1.GetFile("LangIcon.png"); if (file.Exists) { icon = ModContentLoader <Texture2D> .LoadItem(file).contentItem; } } }); VirtualDirectory directory = localDirectory.Item1.GetDirectory("CodeLinked"); if (directory.Exists) { loadErrors.Add("Translations aren't called CodeLinked any more. Please rename to Keyed: " + directory); } else { directory = localDirectory.Item1.GetDirectory("Keyed"); } if (directory.Exists) { foreach (VirtualFile file2 in directory.GetFiles("*.xml", SearchOption.AllDirectories)) { if (TryRegisterFileIfNew(localDirectory, file2.FullPath)) { LoadFromFile_Keyed(file2); } } } VirtualDirectory directory2 = localDirectory.Item1.GetDirectory("DefLinked"); if (directory2.Exists) { loadErrors.Add("Translations aren't called DefLinked any more. Please rename to DefInjected: " + directory2); } else { directory2 = localDirectory.Item1.GetDirectory("DefInjected"); } if (directory2.Exists) { foreach (VirtualDirectory directory4 in directory2.GetDirectories("*", SearchOption.TopDirectoryOnly)) { string name = directory4.Name; Type typeInAnyAssembly = GenTypes.GetTypeInAnyAssembly(name); if (typeInAnyAssembly == null && name.Length > 3) { typeInAnyAssembly = GenTypes.GetTypeInAnyAssembly(name.Substring(0, name.Length - 1)); } if (typeInAnyAssembly == null) { loadErrors.Add(string.Concat("Error loading language from ", allDirectory, ": dir ", directory4.Name, " doesn't correspond to any def type. Skipping...")); continue; } foreach (VirtualFile file3 in directory4.GetFiles("*.xml", SearchOption.AllDirectories)) { if (TryRegisterFileIfNew(localDirectory, file3.FullPath)) { LoadFromFile_DefInject(file3, typeInAnyAssembly); } } } } EnsureAllDefTypesHaveDefInjectionPackage(); VirtualDirectory directory3 = localDirectory.Item1.GetDirectory("Strings"); if (directory3.Exists) { foreach (VirtualDirectory directory5 in directory3.GetDirectories("*", SearchOption.TopDirectoryOnly)) { foreach (VirtualFile file4 in directory5.GetFiles("*.txt", SearchOption.AllDirectories)) { if (TryRegisterFileIfNew(localDirectory, file4.FullPath)) { LoadFromFile_Strings(file4, directory3); } } } } wordInfo.LoadFrom(localDirectory, this); } } catch (Exception arg) { Log.Error("Exception loading language data. Rethrowing. Exception: " + arg); throw; } finally { DeepProfiler.End(); } }
public void InitNewGame() { string str = (from mod in LoadedModManager.RunningMods select mod.ToString()).ToCommaList(false); Log.Message("Initializing new game with mods " + str, false); if (this.maps.Any <Map>()) { Log.Error("Called InitNewGame() but there already is a map. There should be 0 maps...", false); return; } if (this.initData == null) { Log.Error("Called InitNewGame() but init data is null. Create it first.", false); return; } MemoryUtility.UnloadUnusedUnityAssets(); DeepProfiler.Start("InitNewGame"); try { Current.ProgramState = ProgramState.MapInitializing; IntVec3 intVec = new IntVec3(this.initData.mapSize, 1, this.initData.mapSize); Settlement settlement = null; List <Settlement> settlements = Find.WorldObjects.Settlements; for (int i = 0; i < settlements.Count; i++) { if (settlements[i].Faction == Faction.OfPlayer) { settlement = settlements[i]; break; } } if (settlement == null) { Log.Error("Could not generate starting map because there is no any player faction base.", false); } this.tickManager.gameStartAbsTick = GenTicks.ConfiguredTicksAbsAtGameStart; Map currentMap = MapGenerator.GenerateMap(intVec, settlement, settlement.MapGeneratorDef, settlement.ExtraGenStepDefs, null); this.worldInt.info.initialMapSize = intVec; if (this.initData.permadeath) { this.info.permadeathMode = true; this.info.permadeathModeUniqueName = PermadeathModeUtility.GeneratePermadeathSaveName(); } PawnUtility.GiveAllStartingPlayerPawnsThought(ThoughtDefOf.NewColonyOptimism); this.FinalizeInit(); Current.Game.CurrentMap = currentMap; Find.CameraDriver.JumpToCurrentMapLoc(MapGenerator.PlayerStartSpot); Find.CameraDriver.ResetSize(); if (Prefs.PauseOnLoad && this.initData.startedFromEntry) { LongEventHandler.ExecuteWhenFinished(delegate { this.tickManager.DoSingleTick(); this.tickManager.CurTimeSpeed = TimeSpeed.Paused; }); } Find.Scenario.PostGameStart(); if (Faction.OfPlayer.def.startingResearchTags != null) { foreach (ResearchProjectTagDef current in Faction.OfPlayer.def.startingResearchTags) { foreach (ResearchProjectDef current2 in DefDatabase <ResearchProjectDef> .AllDefs) { if (current2.HasTag(current)) { this.researchManager.FinishProject(current2, false, null); } } } } GameComponentUtility.StartedNewGame(); this.initData = null; } finally { DeepProfiler.End(); } }
public void LoadData() { if (!this.dataIsLoaded) { this.dataIsLoaded = true; DeepProfiler.Start("Loading language data: " + this.folderName); foreach (string folderPath in this.FolderPaths) { string localFolderPath = folderPath; LongEventHandler.ExecuteWhenFinished(delegate { if ((UnityEngine.Object) this.icon == (UnityEngine.Object)BaseContent.BadTex) { FileInfo fileInfo = new FileInfo(Path.Combine(localFolderPath.ToString(), "LangIcon.png")); if (fileInfo.Exists) { this.icon = ModContentLoader <Texture2D> .LoadItem(fileInfo.FullName, null).contentItem; } } }); DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(folderPath.ToString(), "CodeLinked")); if (directoryInfo.Exists) { Log.Warning("Translations aren't called CodeLinked any more. Please rename to Keyed: " + directoryInfo); } else { directoryInfo = new DirectoryInfo(Path.Combine(folderPath.ToString(), "Keyed")); } if (directoryInfo.Exists) { FileInfo[] files = directoryInfo.GetFiles("*.xml", SearchOption.AllDirectories); foreach (FileInfo file in files) { this.LoadFromFile_Keyed(file); } } DirectoryInfo directoryInfo2 = new DirectoryInfo(Path.Combine(folderPath.ToString(), "DefLinked")); if (directoryInfo2.Exists) { Log.Warning("Translations aren't called DefLinked any more. Please rename to DefInjected: " + directoryInfo2); } else { directoryInfo2 = new DirectoryInfo(Path.Combine(folderPath.ToString(), "DefInjected")); } if (directoryInfo2.Exists) { DirectoryInfo[] directories = directoryInfo2.GetDirectories("*", SearchOption.TopDirectoryOnly); foreach (DirectoryInfo directoryInfo3 in directories) { string name = directoryInfo3.Name; Type typeInAnyAssembly = GenTypes.GetTypeInAnyAssembly(name); if (typeInAnyAssembly == null && name.Length > 3) { typeInAnyAssembly = GenTypes.GetTypeInAnyAssembly(name.Substring(0, name.Length - 1)); } if (typeInAnyAssembly == null) { Log.Warning("Error loading language from " + folderPath + ": dir " + directoryInfo3.Name + " doesn't correspond to any def type. Skipping..."); } else { FileInfo[] files2 = directoryInfo3.GetFiles("*.xml", SearchOption.AllDirectories); foreach (FileInfo file2 in files2) { this.LoadFromFile_DefInject(file2, typeInAnyAssembly); } } } } DirectoryInfo directoryInfo4 = new DirectoryInfo(Path.Combine(folderPath.ToString(), "Strings")); if (directoryInfo4.Exists) { DirectoryInfo[] directories2 = directoryInfo4.GetDirectories("*", SearchOption.TopDirectoryOnly); foreach (DirectoryInfo directoryInfo5 in directories2) { FileInfo[] files3 = directoryInfo5.GetFiles("*.txt", SearchOption.AllDirectories); foreach (FileInfo file3 in files3) { this.LoadFromFile_Strings(file3, directoryInfo4); } } } } DeepProfiler.End(); } }
private static void DoPlayLoad() { GraphicDatabase.Clear(); DeepProfiler.Start("Load all active mods."); try { LoadedModManager.LoadAllActiveMods(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load language metadata."); try { LanguageDatabase.LoadAllMetadata(); } finally { DeepProfiler.End(); } LongEventHandler.SetCurrentEventText("LoadingDefs".Translate()); DeepProfiler.Start("Copy all Defs from mods to global databases."); try { foreach (Type item in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods"); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between non-implied Defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind defs (early)."); try { DefOfHelper.RebindAllDefOfs(true); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (pre-resolve)."); try { DefGenerator.GenerateImpliedDefs_PreResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind DefOfs (final)."); try { DefOfHelper.RebindAllDefOfs(false); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations."); try { PlayerKnowledgeDatabase.ReloadAndRebind(); LessonAutoActivator.Reset(); CostListCalculator.Reset(); PawnApparelGenerator.Reset(); RestUtility.Reset(); ThoughtUtility.Reset(); PawnWeaponGenerator.Reset(); ThinkTreeKeyAssigner.Reset(); ThingCategoryNodeDatabase.FinalizeInit(); TrainableUtility.Reset(); HaulAIUtility.Reset(); GenConstruct.Reset(); WorkGiver_FillFermentingBarrel.Reset(); WorkGiver_DoBill.Reset(); Pawn.Reset(); WorkGiver_InteractAnimal.Reset(); WorkGiver_Warden_DoExecution.Reset(); WorkGiver_GrowerSow.Reset(); WorkGiver_Miner.Reset(); MedicalCareUtility.Reset(); InspectPaneUtility.Reset(); GraphicDatabaseHeadRecords.Reset(); DateReadout.Reset(); ResearchProjectDef.GenerateNonOverlappingCoordinates(); WorkGiver_FixBrokenDownBuilding.CacheTranslations(); ItemCollectionGeneratorUtility.Reset(); BaseGen.Reset(); HealthUtility.Reset(); ResourceCounter.ResetDefs(); WildSpawner.Reset(); ApparelProperties.Reset(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve references."); try { foreach (Type item2 in typeof(Def).AllSubclasses()) { if (item2 != typeof(ThingDef)) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true); } } DefDatabase <ThingDef> .ResolveAllReferences(true); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (post-resolve)."); try { DefGenerator.GenerateImpliedDefs_PostResolve(); } finally { DeepProfiler.End(); } if (Prefs.DevMode) { DeepProfiler.Start("Error check all defs."); try { foreach (Type item3 in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs"); } } finally { DeepProfiler.End(); } } LongEventHandler.SetCurrentEventText("Initializing".Translate()); DeepProfiler.Start("Load keyboard preferences."); try { KeyPrefs.Init(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Short hash giving."); try { ShortHashGiver.GiveAllShortHashes(); } finally { DeepProfiler.End(); } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Load backstories."); try { BackstoryDatabase.ReloadAllBackstories(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Inject selected language data into game data."); try { LanguageDatabase.activeLanguage.InjectIntoData(); GenLabel.ClearCache(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { StaticConstructorOnStartupUtility.CallAll(); if (Prefs.DevMode) { StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes(); } }); }