public void TryPlant(bool allow_plant_from_storage = false) { timeUntilSelfPlant = Util.RandomVariance(2400f, 600f); if (!allow_plant_from_storage && base.gameObject.HasTag(GameTags.Stored)) { return; } int cell = Grid.PosToCell(base.gameObject); if (!TestSuitableGround(cell)) { return; } Vector3 position = Grid.CellToPosCBC(cell, Grid.SceneLayer.BuildingFront); GameObject gameObject = GameUtil.KInstantiate(Assets.GetPrefab(PlantID), position, Grid.SceneLayer.BuildingFront, null, 0); gameObject.SetActive(true); Pickupable component = GetComponent <Pickupable>(); Pickupable pickupable = component.Take(1f); if (!((Object)pickupable != (Object)null)) { KCrashReporter.Assert(false, "Seed has fractional total amount < 1f"); return; } Crop component2 = gameObject.GetComponent <Crop>(); if (!((Object)component2 != (Object)null)) { goto IL_00a5; } goto IL_00a5; IL_00a5: Util.KDestroyGameObject(pickupable.gameObject); }
public void OnLand(object data) { SpaceDestination spacecraftDestination = SpacecraftManager.instance.GetSpacecraftDestination(SpacecraftManager.instance.GetSpacecraftID(GetComponent <RocketModule>().conditionManager.GetComponent <LaunchableRocket>())); SpaceDestination.ResearchOpportunity researchOpportunity = spacecraftDestination.TryCompleteResearchOpportunity(); if (researchOpportunity != null) { GameObject gameObject = GameUtil.KInstantiate(Assets.GetPrefab("ResearchDatabank"), base.gameObject.transform.GetPosition(), Grid.SceneLayer.Ore, null, 0); gameObject.SetActive(true); gameObject.GetComponent <PrimaryElement>().Mass = (float)researchOpportunity.dataValue; if (!string.IsNullOrEmpty(researchOpportunity.discoveredRareItem)) { GameObject prefab = Assets.GetPrefab(researchOpportunity.discoveredRareItem); if ((Object)prefab == (Object)null) { KCrashReporter.Assert(false, "Missing prefab: " + researchOpportunity.discoveredRareItem); } else { GameObject gameObject2 = GameUtil.KInstantiate(prefab, base.gameObject.transform.GetPosition(), Grid.SceneLayer.Ore, null, 0); gameObject2.SetActive(true); } } } GameObject gameObject3 = GameUtil.KInstantiate(Assets.GetPrefab("ResearchDatabank"), base.gameObject.transform.GetPosition(), Grid.SceneLayer.Ore, null, 0); gameObject3.SetActive(true); gameObject3.GetComponent <PrimaryElement>().Mass = (float)ROCKETRY.DESTINATION_RESEARCH.EVERGREEN; }
private unsafe void OnSimRegistered(int handle) { if ((UnityEngine.Object) this != (UnityEngine.Object)null && simHandle == -2) { simHandle = handle; int handleIndex = Sim.GetHandleIndex(handle); float temperature = Game.Instance.simData.elementChunks[handleIndex].temperature; if (temperature <= 0f) { KCrashReporter.Assert(false, "Bad temperature"); } handleInstanceMap[simHandle] = this; if (pendingEnergyModifications > 0f) { ModifyEnergy(pendingEnergyModifications); pendingEnergyModifications = 0f; } if (onSimRegistered != null) { onSimRegistered(this); } } else { SimMessages.RemoveElementChunk(handle, -1); } }
public void SpawnResources(object data) { SpaceDestination spacecraftDestination = SpacecraftManager.instance.GetSpacecraftDestination(SpacecraftManager.instance.GetSpacecraftID(GetComponent <RocketModule>().conditionManager.GetComponent <LaunchableRocket>())); int rootCell = Grid.PosToCell(base.gameObject); foreach (KeyValuePair <SimHashes, float> item in spacecraftDestination.GetMissionResourceResult(storage.RemainingCapacity(), storageType == CargoType.solids, storageType == CargoType.liquids, storageType == CargoType.gasses)) { Element element = ElementLoader.FindElementByHash(item.Key); if (storageType == CargoType.solids && element.IsSolid) { GameObject gameObject = Scenario.SpawnPrefab(rootCell, 0, 0, element.tag.Name, Grid.SceneLayer.Ore); gameObject.GetComponent <PrimaryElement>().Mass = item.Value; gameObject.GetComponent <PrimaryElement>().Temperature = ElementLoader.FindElementByHash(item.Key).defaultValues.temperature; gameObject.SetActive(true); storage.Store(gameObject, false, false, true, false); } else if (storageType == CargoType.liquids && element.IsLiquid) { storage.AddLiquid(item.Key, item.Value, ElementLoader.FindElementByHash(item.Key).defaultValues.temperature, byte.MaxValue, 0, false, true); } else if (storageType == CargoType.gasses && element.IsGas) { storage.AddGasChunk(item.Key, item.Value, ElementLoader.FindElementByHash(item.Key).defaultValues.temperature, byte.MaxValue, 0, false, true); } } if (storageType == CargoType.entities) { foreach (KeyValuePair <Tag, int> item2 in spacecraftDestination.GetMissionEntityResult()) { GameObject prefab = Assets.GetPrefab(item2.Key); if ((UnityEngine.Object)prefab == (UnityEngine.Object)null) { KCrashReporter.Assert(false, "Missing prefab: " + item2.Key.Name); } else { for (int i = 0; i < item2.Value; i++) { GameObject gameObject2 = Util.KInstantiate(prefab, base.transform.position); gameObject2.SetActive(true); storage.Store(gameObject2, false, false, true, false); Baggable component = gameObject2.GetComponent <Baggable>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.SetWrangled(); } } } } } }
private void SetTemperature(float temperature) { if (float.IsNaN(temperature) || float.IsInfinity(temperature)) { DebugUtil.LogErrorArgs(base.gameObject, "Invalid temperature [" + temperature + "]"); } else { if (temperature <= 0f) { KCrashReporter.Assert(false, "Tried to set PrimaryElement.Temperature to a value <= 0"); } setTemperatureCallback(this, temperature); } }
private Action <InfoDialogScreen> OpenCodex(string key) { return(delegate(InfoDialogScreen dialog) { dialog.Deactivate(); string entryForLock = CodexCache.GetEntryForLock(key); if (entryForLock == null) { KCrashReporter.Assert(false, "Missing codex entry: " + key); } else { ManagementMenu.Instance.OpenCodexToEntry(entryForLock); } }); }
public override void Begin(Precondition.Context context) { if ((UnityEngine.Object)context.consumerState.consumer == (UnityEngine.Object)null) { Debug.LogError("EATCHORE null context.consumer"); } else { RationMonitor.Instance sMI = context.consumerState.consumer.GetSMI <RationMonitor.Instance>(); if (sMI == null) { Debug.LogError("EATCHORE null RationMonitor.Instance"); } else { Edible edible = sMI.GetEdible(); if ((UnityEngine.Object)edible.gameObject == (UnityEngine.Object)null) { Debug.LogError("EATCHORE null edible.gameObject"); } else if (base.smi == null) { Debug.LogError("EATCHORE null smi"); } else if (base.smi.sm == null) { Debug.LogError("EATCHORE null smi.sm"); } else if (base.smi.sm.ediblesource == null) { Debug.LogError("EATCHORE null smi.sm.ediblesource"); } else { base.smi.sm.ediblesource.Set(edible.gameObject, base.smi); KCrashReporter.Assert(edible.FoodInfo.CaloriesPerUnit > 0f, edible.GetProperName() + " has invalid calories per unit. Will result in NaNs"); AmountInstance amountInstance = Db.Get().Amounts.Calories.Lookup(gameObject); float num = (amountInstance.GetMax() - amountInstance.value) / edible.FoodInfo.CaloriesPerUnit; KCrashReporter.Assert(num > 0f, "EatChore is requesting an invalid amount of food"); base.smi.sm.requestedfoodunits.Set(num, base.smi); base.smi.sm.eater.Set(context.consumerState.gameObject, base.smi); base.Begin(context); } } } }
private void StopConsuming(Worker worker) { DebugUtil.DevAssert(isBeingConsumed, "StopConsuming() called without StartConsuming()"); isBeingConsumed = false; if (float.IsNaN(consumptionTime)) { DebugUtil.DevAssert(false, "consumptionTime NaN in StopConsuming()"); } else { PrimaryElement component = base.gameObject.GetComponent <PrimaryElement>(); if ((Object)component != (Object)null && component.DiseaseCount > 0) { new EmoteChore(worker.GetComponent <ChoreProvider>(), Db.Get().ChoreTypes.EmoteHighPriority, "anim_react_contaminated_food_kanim", new HashedString[1] { "react" }, null); } float num = Mathf.Clamp01(consumptionTime / GetFeedingTime(worker)); unitsConsumed = Units * num; if (float.IsNaN(unitsConsumed)) { KCrashReporter.Assert(false, "Why is unitsConsumed NaN?"); unitsConsumed = Units; } caloriesConsumed = unitsConsumed * foodInfo.CaloriesPerUnit; Units -= unitsConsumed; for (int i = 0; i < foodInfo.Effects.Count; i++) { worker.GetComponent <Effects>().Add(foodInfo.Effects[i], true); } ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, 0f - caloriesConsumed, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.EATEN, "{0}", this.GetProperName()), worker.GetProperName()); AddQualityEffects(worker); worker.Trigger(1121894420, this); Trigger(-10536414, worker.gameObject); unitsConsumed = float.NaN; caloriesConsumed = float.NaN; consumptionTime = float.NaN; if (Units <= 0f) { base.gameObject.DeleteObject(); } } }
public float Open() { if (openCount == 0 && DisplacesGas(doorType)) { StructureTemperatureComponents structureTemperatures = GameComps.StructureTemperatures; HandleVector <int> .Handle handle = structureTemperatures.GetHandle(base.gameObject); if (handle.IsValid() && structureTemperatures.IsBypassed(handle)) { int[] placementCells = building.PlacementCells; float num = 0f; int num2 = 0; foreach (int i2 in placementCells) { if (Grid.Mass[i2] > 0f) { num2++; num += Grid.Temperature[i2]; } } if (num2 > 0) { num /= (float)placementCells.Length; PrimaryElement component = GetComponent <PrimaryElement>(); KCrashReporter.Assert(num > 0f, "Door has calculated an invalid temperature"); component.Temperature = num; } } } openCount++; float result = 1f; if ((Object)consumer != (Object)null) { result = ((!consumer.IsPowered) ? 0.5f : 1f); } switch (controlState) { case ControlState.Auto: case ControlState.Opened: controller.sm.isOpen.Set(true, controller); break; } return(result); }
private void DoSave(string filename) { try { SaveLoader.Instance.Save(filename, false, true); ReportErrorDialog.MOST_RECENT_SAVEFILE = filename; } catch (IOException ex) { IOException e; IOException ex2 = e = ex; ConfirmDialogScreen component = Util.KInstantiateUI(ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject, base.transform.parent.gameObject, true).GetComponent <ConfirmDialogScreen>(); component.PopupConfirmDialog(string.Format(UI.FRONTEND.SAVESCREEN.IO_ERROR, e.ToString()), delegate { Deactivate(); }, null, UI.FRONTEND.SAVESCREEN.REPORT_BUG, delegate { KCrashReporter.ReportError(e.Message, e.StackTrace.ToString(), null, null, string.Empty); }, null, null, null, null, true); } }
private unsafe static void OnSetTemperature(PrimaryElement primary_element, float temperature) { if (temperature <= 0f) { KCrashReporter.Assert(false, "STT.OnSetTemperature - Tried to set <= 0 degree temperature"); temperature = 293f; } SimTemperatureTransfer component = primary_element.GetComponent <SimTemperatureTransfer>(); if (Sim.IsValidHandle(component.simHandle)) { float mass = primary_element.Mass; float heat_capacity = (!(mass >= 0.01f)) ? 0f : (mass * primary_element.Element.specificHeatCapacity); SimMessages.SetElementChunkData(component.simHandle, temperature, heat_capacity); int handleIndex = Sim.GetHandleIndex(component.simHandle); Game.Instance.simData.elementChunks[handleIndex].temperature = temperature; } else { primary_element.InternalTemperature = temperature; } }
public unsafe static int DLL_MessageHandler(int message_id, IntPtr data) { switch (message_id) { case 1: { DLLReportMessageMessage *ptr2 = (DLLReportMessageMessage *)(void *)data; string msg = "SimMessage: " + Marshal.PtrToStringAnsi(ptr2->message); string stack_trace2; if (ptr2->callstack != IntPtr.Zero) { stack_trace2 = Marshal.PtrToStringAnsi(ptr2->callstack); } else { string arg = Marshal.PtrToStringAnsi(ptr2->file); int line = ptr2->line; stack_trace2 = arg + ":" + line; } KCrashReporter.ReportSimDLLCrash(msg, stack_trace2, null); return(0); } case 0: { DLLExceptionHandlerMessage *ptr = (DLLExceptionHandlerMessage *)(void *)data; string stack_trace = Marshal.PtrToStringAnsi(ptr->callstack); string dmp_filename = Marshal.PtrToStringAnsi(ptr->dmpFilename); KCrashReporter.ReportSimDLLCrash("SimDLL Crash Dump", stack_trace, dmp_filename); return(0); } default: return(-1); } }
public void OnKeyDown(KButtonEvent e) { if (!enabled) { return; } if (e.TryConsume(Action.DebugSpawnMinion)) { SpawnMinion(); } else if (e.TryConsume(Action.DebugSpawnStressTest)) { for (int i = 0; i < 60; i++) { SpawnMinion(); } } else if (e.TryConsume(Action.DebugSuperTestMode)) { if (!superTestMode) { Time.timeScale = 15f; superTestMode = true; } else { Time.timeScale = 1f; superTestMode = false; } } else if (e.TryConsume(Action.DebugUltraTestMode)) { if (!ultraTestMode) { Time.timeScale = 30f; ultraTestMode = true; } else { Time.timeScale = 1f; ultraTestMode = false; } } else if (e.TryConsume(Action.DebugSlowTestMode)) { if (!slowTestMode) { Time.timeScale = 0.06f; slowTestMode = true; } else { Time.timeScale = 1f; slowTestMode = false; } } else if (e.TryConsume(Action.DebugDig)) { int mouseCell = GetMouseCell(); SimMessages.Dig(mouseCell, -1); } else if (e.TryConsume(Action.DebugInstantBuildMode)) { InstantBuildMode = !InstantBuildMode; if ((UnityEngine.Object)Game.Instance == (UnityEngine.Object)null) { return; } if ((UnityEngine.Object)PlanScreen.Instance != (UnityEngine.Object)null) { PlanScreen.Instance.Refresh(); } if ((UnityEngine.Object)BuildMenu.Instance != (UnityEngine.Object)null) { BuildMenu.Instance.Refresh(); } if ((UnityEngine.Object)OverlayMenu.Instance != (UnityEngine.Object)null) { OverlayMenu.Instance.Refresh(); } if ((UnityEngine.Object)ConsumerManager.instance != (UnityEngine.Object)null) { ConsumerManager.instance.RefreshDiscovered(null); } if ((UnityEngine.Object)ManagementMenu.Instance != (UnityEngine.Object)null) { ManagementMenu.Instance.CheckResearch(null); ManagementMenu.Instance.CheckSkills(null); ManagementMenu.Instance.CheckStarmap(null); } Game.Instance.Trigger(1594320620, "all_the_things"); } else if (e.TryConsume(Action.DebugExplosion)) { Vector3 mousePos = KInputManager.GetMousePos(); Vector3 position = Camera.main.transform.GetPosition(); mousePos.z = 0f - position.z - Grid.CellSizeInMeters; Vector3 explosion_pos = Camera.main.ScreenToWorldPoint(mousePos); GameUtil.CreateExplosion(explosion_pos); } else if (e.TryConsume(Action.DebugLockCursor)) { if (GenericGameSettings.instance.developerDebugEnable) { KInputManager.isMousePosLocked = !KInputManager.isMousePosLocked; KInputManager.lockedMousePos = KInputManager.GetMousePos(); } } else if (e.TryConsume(Action.DebugDiscoverAllElements)) { if ((UnityEngine.Object)WorldInventory.Instance != (UnityEngine.Object)null) { foreach (Element element in ElementLoader.elements) { WorldInventory.Instance.Discover(element.tag, element.GetMaterialCategoryTag()); } } } else if (e.TryConsume(Action.DebugToggleUI)) { ToggleScreenshotMode(); } else if (e.TryConsume(Action.SreenShot1x)) { string filename = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png"); ScreenCapture.CaptureScreenshot(filename, 1); } else if (e.TryConsume(Action.SreenShot2x)) { string filename2 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png"); ScreenCapture.CaptureScreenshot(filename2, 2); } else if (e.TryConsume(Action.SreenShot8x)) { string filename3 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png"); ScreenCapture.CaptureScreenshot(filename3, 8); } else if (e.TryConsume(Action.SreenShot32x)) { string filename4 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png"); ScreenCapture.CaptureScreenshot(filename4, 32); } else if (e.TryConsume(Action.DebugCellInfo)) { DebugCellInfo = !DebugCellInfo; } else if (e.TryConsume(Action.DebugToggle)) { if ((UnityEngine.Object)Game.Instance != (UnityEngine.Object)null) { Game.Instance.UpdateGameActiveRegion(0, 0, Grid.WidthInCells, Grid.HeightInCells); SaveGame.Instance.worldGenSpawner.SpawnEverything(); } if ((UnityEngine.Object)DebugPaintElementScreen.Instance != (UnityEngine.Object)null) { bool activeSelf = DebugPaintElementScreen.Instance.gameObject.activeSelf; DebugPaintElementScreen.Instance.gameObject.SetActive(!activeSelf); if ((bool)DebugElementMenu.Instance && DebugElementMenu.Instance.root.activeSelf) { DebugElementMenu.Instance.root.SetActive(false); } DebugBaseTemplateButton.Instance.gameObject.SetActive(!activeSelf); PropertyTextures.FogOfWarScale = (float)((!activeSelf) ? 1 : 0); if ((UnityEngine.Object)CameraController.Instance != (UnityEngine.Object)null) { CameraController.Instance.EnableFreeCamera(!activeSelf); } } } else if (e.TryConsume(Action.DebugCollectGarbage)) { GC.Collect(); } else if (e.TryConsume(Action.DebugInvincible)) { InvincibleMode = !InvincibleMode; } else if (e.TryConsume(Action.DebugVisualTest)) { Scenario.Instance.SetupVisualTest(); } else if (e.TryConsume(Action.DebugGameplayTest)) { Scenario.Instance.SetupGameplayTest(); } else if (e.TryConsume(Action.DebugElementTest)) { Scenario.Instance.SetupElementTest(); } else if (e.TryConsume(Action.ToggleProfiler)) { Sim.SIM_HandleMessage(-409964931, 0, null); } else if (e.TryConsume(Action.DebugRefreshNavCell)) { Pathfinding.Instance.RefreshNavCell(GetMouseCell()); } else if (e.TryConsume(Action.DebugToggleSelectInEditor)) { SetSelectInEditor(!SelectInEditor); } else if (e.TryConsume(Action.DebugGotoTarget)) { Debug.Log("Debug GoTo"); Game.Instance.Trigger(775300118, null); foreach (Brain item in Components.Brains.Items) { item.GetSMI <DebugGoToMonitor.Instance>()?.GoToCursor(); item.GetSMI <CreatureDebugGoToMonitor.Instance>()?.GoToCursor(); } } else if (e.TryConsume(Action.DebugTeleport)) { if ((UnityEngine.Object)SelectTool.Instance == (UnityEngine.Object)null) { return; } KSelectable selected = SelectTool.Instance.selected; if ((UnityEngine.Object)selected != (UnityEngine.Object)null) { int mouseCell2 = GetMouseCell(); if (!Grid.IsValidBuildingCell(mouseCell2)) { PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Negative, UI.DEBUG_TOOLS.INVALID_LOCATION, null, GetMousePos(), 1.5f, false, true); return; } selected.transform.SetPosition(Grid.CellToPosCBC(mouseCell2, Grid.SceneLayer.Move)); } } else if (!e.TryConsume(Action.DebugPlace) && !e.TryConsume(Action.DebugSelectMaterial)) { if (e.TryConsume(Action.DebugNotification)) { if (GenericGameSettings.instance.developerDebugEnable) { Tutorial.Instance.DebugNotification(); } } else if (e.TryConsume(Action.DebugNotificationMessage)) { if (GenericGameSettings.instance.developerDebugEnable) { Tutorial.Instance.DebugNotificationMessage(); } } else if (e.TryConsume(Action.DebugSuperSpeed)) { if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null) { SpeedControlScreen.Instance.ToggleRidiculousSpeed(); } } else if (e.TryConsume(Action.DebugGameStep)) { if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null) { SpeedControlScreen.Instance.DebugStepFrame(); } } else if (e.TryConsume(Action.DebugSimStep)) { Game.Instance.ForceSimStep(); } else if (e.TryConsume(Action.DebugToggleMusic)) { AudioDebug.Get().ToggleMusic(); } else if (e.TryConsume(Action.DebugRiverTest)) { Scenario.Instance.SetupRiverTest(); } else if (e.TryConsume(Action.DebugTileTest)) { Scenario.Instance.SetupTileTest(); } else if (e.TryConsume(Action.DebugForceLightEverywhere)) { PropertyTextures.instance.ForceLightEverywhere = !PropertyTextures.instance.ForceLightEverywhere; } else if (e.TryConsume(Action.DebugPathFinding)) { DebugPathFinding = !DebugPathFinding; Debug.Log("DebugPathFinding=" + DebugPathFinding); } else if (!e.TryConsume(Action.DebugFocus)) { if (e.TryConsume(Action.DebugReportBug)) { if (GenericGameSettings.instance.developerDebugEnable) { int num = 0; string validSaveFilename; while (true) { validSaveFilename = SaveScreen.GetValidSaveFilename("bug_report_savefile_" + num.ToString()); if (!File.Exists(validSaveFilename)) { break; } num++; } string save_file = "No save file (front end)"; if ((UnityEngine.Object)SaveLoader.Instance != (UnityEngine.Object)null) { save_file = SaveLoader.Instance.Save(validSaveFilename, false, false); } KCrashReporter.ReportBug("Bug Report", save_file); } else { Debug.Log("Debug crash keys are not enabled."); } } else if (e.TryConsume(Action.DebugTriggerException)) { if (GenericGameSettings.instance.developerDebugEnable) { string str = Guid.NewGuid().ToString(); StackTrace stackTrace = new StackTrace(1, true); str = str + "\n" + stackTrace.ToString(); KCrashReporter.ReportError("Debug crash with random stack", str, null, ScreenPrefabs.Instance.ConfirmDialogScreen, string.Empty); } } else if (e.TryConsume(Action.DebugTriggerError)) { if (GenericGameSettings.instance.developerDebugEnable) { Debug.LogError("Oooops! Testing error!"); } } else if (e.TryConsume(Action.DebugDumpGCRoots)) { GarbageProfiler.DebugDumpRootItems(); } else if (e.TryConsume(Action.DebugDumpGarbageReferences)) { GarbageProfiler.DebugDumpGarbageStats(); } else if (e.TryConsume(Action.DebugDumpEventData)) { if (GenericGameSettings.instance.developerDebugEnable) { KObjectManager.Instance.DumpEventData(); } } else if (e.TryConsume(Action.DebugDumpSceneParitionerLeakData)) { if (!GenericGameSettings.instance.developerDebugEnable) { goto IL_0b5e; } } else if (e.TryConsume(Action.DebugCrashSim)) { if (GenericGameSettings.instance.developerDebugEnable) { Sim.SIM_DebugCrash(); } } else if (e.TryConsume(Action.DebugNextCall)) { DebugNextCall = true; } else if (e.TryConsume(Action.DebugTogglePersonalPriorityComparison)) { Chore.ENABLE_PERSONAL_PRIORITIES = !Chore.ENABLE_PERSONAL_PRIORITIES; } } } goto IL_0b5e; IL_0b5e: if (e.Consumed && (UnityEngine.Object)Game.Instance != (UnityEngine.Object)null) { Game.Instance.debugWasUsed = true; KCrashReporter.debugWasUsed = true; } }
public void AddParticle(Vector2 root_pos, byte elementIdx, float base_mass, float temperature, byte disease_idx, int base_disease_count, bool skip_sound = false, bool skip_decor = false, bool debug_track = false, bool disable_randomness = false) { int num = Grid.PosToCell(root_pos); if (!Grid.IsValidCell(num)) { KCrashReporter.Assert(false, "Trying to add falling water outside of the scene"); } else { if (temperature <= 0f || base_mass <= 0f) { Debug.LogError($"Unexpected water mass/temperature values added to the falling water manager T({temperature}) M({base_mass})"); } float time = GetTime(); if (!skip_sound) { if (!topSounds.TryGetValue(num, out SoundInfo value)) { value = default(SoundInfo); value.handle = LoopingSoundManager.StartSound(liquid_top_loop, root_pos, true, true); } value.startTime = time; LoopingSoundManager.Get().UpdateSecondParameter(value.handle, HASH_LIQUIDVOLUME, SoundUtil.GetLiquidVolume(base_mass)); topSounds[num] = value; } while (base_mass > 0f) { float num2 = UnityEngine.Random.value * 2f * particleMassVariation - particleMassVariation; float num3 = Mathf.Max(0f, Mathf.Min(base_mass, particleMassToSplit + num2)); float num4 = num3 / base_mass; base_mass -= num3; int disease_count = (int)(num4 * (float)base_disease_count); int frame = UnityEngine.Random.Range(0, numFrames); Vector2 b = (!disable_randomness) ? new Vector2(jitterStep * Mathf.Sin(offset), jitterStep * Mathf.Sin(offset + 17f)) : Vector2.zero; Vector2 b2 = (!disable_randomness) ? new Vector2(UnityEngine.Random.Range(0f - multipleOffsetRange.x, multipleOffsetRange.x), UnityEngine.Random.Range(0f - multipleOffsetRange.y, multipleOffsetRange.y)) : Vector2.zero; Element element = ElementLoader.elements[elementIdx]; Vector2 vector = root_pos; bool flag = !skip_decor && SpawnLiquidTopDecor(time, Grid.CellLeft(num), false, element); bool flag2 = !skip_decor && SpawnLiquidTopDecor(time, Grid.CellRight(num), true, element); Vector2 b3 = Vector2.ClampMagnitude(initialOffset + b + b2, 1f); if (flag || flag2) { if (flag && flag2) { vector += b3; vector.x += 0.5f; } else if (flag) { vector += b3; } else { vector.x += 1f - b3.x; vector.y += b3.y; } } else { vector += b3; vector.x += 0.5f; } int num5 = Grid.PosToCell(vector); Element element2 = Grid.Element[num5]; Element.State state = element2.state & Element.State.Solid; if (state == Element.State.Solid || (Grid.Properties[num5] & 2) != 0) { vector.y = Mathf.Floor(vector.y + 1f); } physics.Add(new ParticlePhysics(vector, Vector2.zero, frame, elementIdx)); particleProperties.Add(new ParticleProperties(elementIdx, num3, temperature, disease_idx, disease_count, debug_track)); } } }
public static void ReportError(string msg, string stack_trace, string save_file_hash, ConfirmDialogScreen confirm_prefab, string userMessage = "") { if (!ignoreAll) { Debug.Log("Reporting error.\n"); if (msg != null) { Debug.Log(msg); } if (stack_trace != null) { Debug.Log(stack_trace); } hasReportedError = true; if (!KPrivacyPrefs.instance.disableDataCollection) { string obj2 = default(string); using (WebClient webClient = new WebClient()) { webClient.Encoding = Encoding.UTF8; if (string.IsNullOrEmpty(msg)) { msg = "No message"; } Match match = failedToLoadModuleRegEx.Match(msg); if (match.Success) { string path = match.Groups[1].ToString(); string text = match.Groups[2].ToString(); string fileName = Path.GetFileName(path); msg = "Failed to load '" + fileName + "' with error '" + text + "'."; } if (string.IsNullOrEmpty(stack_trace)) { string arg = "LU-" + 365655.ToString(); stack_trace = $"No stack trace {arg}\n\n{msg}"; } List <string> list = new List <string>(); if (debugWasUsed) { list.Add("(Debug Used)"); } if (haveActiveMods) { list.Add("(Mods Active)"); } list.Add(msg); string[] array = new string[8] { "Debug:LogError", "UnityEngine.Debug", "Output:LogError", "DebugUtil:Assert", "System.Array", "System.Collections", "KCrashReporter.Assert", "No stack trace." }; string[] array2 = stack_trace.Split('\n'); foreach (string text2 in array2) { if (list.Count >= 5) { break; } if (!string.IsNullOrEmpty(text2)) { bool flag = false; string[] array3 = array; foreach (string value in array3) { if (text2.StartsWith(value)) { flag = true; break; } } if (!flag) { list.Add(text2); } } } if (userMessage == UI.CRASHSCREEN.BODY.text) { userMessage = string.Empty; } Error error = new Error(); error.user = GetUserID(); error.callstack = stack_trace; if (disableDeduping) { error.callstack = error.callstack + "\n" + Guid.NewGuid().ToString(); } error.fullstack = $"{msg}\n\n{stack_trace}"; error.build = 365655; error.log = GetLogContents(); error.summaryline = string.Join("\n", list.ToArray()); error.user_message = userMessage; if (!string.IsNullOrEmpty(save_file_hash)) { error.save_hash = save_file_hash; } if (DistributionPlatform.Initialized) { error.steam64_verified = DistributionPlatform.Inst.LocalUser.Id.ToInt64(); } string data = JsonConvert.SerializeObject(error); string empty = string.Empty; Uri address = new Uri("http://crashes.klei.ca/submitCrash"); Debug.Log("Submitting crash:"); try { webClient.UploadStringAsync(address, data); } catch (Exception obj) { Debug.Log(obj); } if ((UnityEngine.Object)confirm_prefab != (UnityEngine.Object)null) { ConfirmDialogScreen confirmDialogScreen = (ConfirmDialogScreen)KScreenManager.Instance.StartScreen(confirm_prefab.gameObject, null); confirmDialogScreen.PopupConfirmDialog("Reported Error", null, null, null, null, null, null, null, null, true); } obj2 = empty; } if (KCrashReporter.onCrashReported != null) { KCrashReporter.onCrashReported(obj2); } } } }
private void Awake() { KCrashReporter crash_reporter = GetComponent <KCrashReporter>(); if (((UnityEngine.Object)crash_reporter != (UnityEngine.Object)null) & (SceneInitializerLoader.ReportDeferredError == null)) { SceneInitializerLoader.ReportDeferredError = delegate(SceneInitializerLoader.DeferredError deferred_error) { crash_reporter.ShowDialog(deferred_error.msg, deferred_error.stack_trace); }; } globalCanvas = GameObject.Find("Canvas"); UnityEngine.Object.DontDestroyOnLoad(globalCanvas.gameObject); OutputSystemInfo(); Debug.Assert((UnityEngine.Object)Instance == (UnityEngine.Object)null); Instance = this; Debug.Log("Initializing at " + System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff")); Debug.Log("Save path: " + Util.RootFolder()); if (forcedAtlasInitializationList != null) { SpriteAtlas[] array = forcedAtlasInitializationList; foreach (SpriteAtlas spriteAtlas in array) { int spriteCount = spriteAtlas.spriteCount; Sprite[] array2 = new Sprite[spriteCount]; spriteAtlas.GetSprites(array2); Sprite[] array3 = array2; foreach (Sprite sprite in array3) { Texture2D texture = sprite.texture; if ((UnityEngine.Object)texture != (UnityEngine.Object)null) { texture.filterMode = FilterMode.Bilinear; texture.anisoLevel = 4; texture.mipMapBias = 0f; } } } } FileSystem.Initialize(); Singleton <StateMachineUpdater> .CreateInstance(); Singleton <StateMachineManager> .CreateInstance(); Localization.RegisterForTranslation(typeof(UI)); modManager = new KMod.Manager(); modManager.Load(Content.DLL); modManager.Load(Content.Strings); KSerialization.Manager.Initialize(); mInputManager = new GameInputManager(GenerateDefaultBindings()); Audio.Get(); KAnimBatchManager.CreateInstance(); Singleton <SoundEventVolumeCache> .CreateInstance(); mAnimEventManager = new AnimEventManager(); Singleton <KBatchedAnimUpdater> .CreateInstance(); DistributionPlatform.Initialize(); Localization.Initialize(false); modManager.Load(Content.Translation); modManager.distribution_platforms.Add(new Local("Local", Label.DistributionPlatform.Local)); modManager.distribution_platforms.Add(new Local("Dev", Label.DistributionPlatform.Dev)); mainThread = Thread.CurrentThread; KProfiler.main_thread = Thread.CurrentThread; RestoreLegacyMetricsSetting(); if (DistributionPlatform.Initialized) { if (!KPrivacyPrefs.instance.disableDataCollection) { Debug.Log("Logged into " + DistributionPlatform.Inst.Name + " with ID:" + DistributionPlatform.Inst.LocalUser.Id + ", NAME:" + DistributionPlatform.Inst.LocalUser.Name); ThreadedHttps <KleiAccount> .Instance.AuthenticateUser(OnGetUserIdKey); } } else { Debug.LogWarning("Can't init " + DistributionPlatform.Inst.Name + " distribution platform..."); OnGetUserIdKey(); } modManager.Load(Content.LayerableFiles); GlobalResources.Instance(); }