Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: Klei.SimUtil
- // Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: EFEF928C-40DE-4FF3-B604-02066AAF1D84
- // Assembly location: G:\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\Assembly-CSharp.dll
- using System;
- using System.Diagnostics;
- using UnityEngine;
- namespace Klei
- {
- public static class SimUtil
- {
- public static float CalculateEnergyFlow(float source_temp, float source_thermal_conductivity, float dest_temp, float dest_thermal_conductivity, float surface_area = 1f, float thickness = 1f)
- {
- return (float) ((double) (source_temp - dest_temp) * (double) Math.Min(source_thermal_conductivity, dest_thermal_conductivity) * ((double) surface_area / (double) thickness));
- }
- public static float CalculateEnergyFlow(int cell, float dest_temp, float dest_specific_heat_capacity, float dest_thermal_conductivity, float surface_area = 1f, float thickness = 1f)
- {
- if ((double) Grid.Cell[cell].mass <= 0.0)
- return 0.0f;
- Element element = Grid.Element[cell];
- if (element.IsVacuum)
- return 0.0f;
- return SimUtil.CalculateEnergyFlow(Grid.Temperature[cell], element.thermalConductivity, dest_temp, dest_thermal_conductivity, surface_area, thickness) * (1f / 1000f);
- }
- public static float ClampEnergyTransfer(float dt, float source_temp, float source_mass, float source_specific_heat_capacity, float dest_temp, float dest_mass, float dest_specific_heat_capacity, float max_watts_transferred)
- {
- return SimUtil.ClampEnergyTransfer(dt, source_temp, source_mass * source_specific_heat_capacity, dest_temp, dest_mass * dest_specific_heat_capacity, max_watts_transferred);
- }
- public static float ClampEnergyTransfer(float dt, float source_temp, float source_heat_capacity, float dest_temp, float dest_heat_capacity, float max_watts_transferred)
- {
- float num1 = (float) ((double) max_watts_transferred * (double) dt / 1000.0);
- SimUtil.CheckValidValue(num1);
- float min = Math.Min(source_temp, dest_temp);
- float max = Math.Max(source_temp, dest_temp);
- float num2 = source_temp - num1 / source_heat_capacity;
- float num3 = dest_temp + num1 / dest_heat_capacity;
- SimUtil.CheckValidValue(num2);
- SimUtil.CheckValidValue(num3);
- float num4 = Mathf.Clamp(num2, min, max);
- float num5 = Mathf.Clamp(num3, min, max);
- float num6 = Math.Abs(num4 - source_temp);
- float num7 = Math.Abs(num5 - dest_temp);
- float num8 = Math.Min(num6 * source_heat_capacity, num7 * dest_heat_capacity) * ((double) max_watts_transferred >= 0.0 ? 1f : -1f);
- SimUtil.CheckValidValue(num8);
- return num8;
- }
- private static float GetMassAreaScale(Element element)
- {
- return element.IsGas ? 10f : 0.01f;
- }
- public static float CalculateEnergyFlowCreatures(int cell, float creature_temperature, float creature_shc, float creature_thermal_conductivity, float creature_surface_area = 1f, float creature_surface_thickness = 1f)
- {
- return SimUtil.CalculateEnergyFlow(cell, creature_temperature, creature_shc, creature_thermal_conductivity, creature_surface_area, creature_surface_thickness);
- }
- public static float EnergyFlowToTemperatureDelta(float kilojoules, float specific_heat_capacity, float mass)
- {
- if ((double) kilojoules * (double) specific_heat_capacity * (double) mass == 0.0)
- return 0.0f;
- return kilojoules / (specific_heat_capacity * mass);
- }
- public static float CalculateFinalTemperature(float mass1, float temp1, float mass2, float temp2)
- {
- float val2 = (mass1 * temp1 + mass2 * temp2) / (mass1 + mass2);
- float val1_1;
- float val1_2;
- if ((double) temp1 > (double) temp2)
- {
- val1_1 = temp2;
- val1_2 = temp1;
- }
- else
- {
- val1_1 = temp1;
- val1_2 = temp2;
- }
- return Math.Max(val1_1, Math.Min(val1_2, val2));
- }
- [Conditional("STRICT_CHECKING")]
- public static void CheckValidValue(float value)
- {
- if (!float.IsNaN(value) && !float.IsInfinity(value))
- return;
- UnityEngine.Assertions.Assert.IsTrue(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement