/// <summary> /// Gets the thermal conductivity text for the details screen. /// </summary> /// <param name="element">The selected element.</param> /// <param name="building">The building use to build this element, if any.</param> /// <param name="tempUnits">The temperature units to use for formatting.</param> /// <param name="tcInfo">The thermal conductivity information.</returns> /// <returns>Whether the insulated tooltip should appear.</param> private static bool GetTCText(Element element, Building building, string tempUnits, out InfoLine tcInfo) { float tc = element.thermalConductivity; var text = CACHED_BUILDER; bool insulator = false; if (building != null) { float tcModifier = building.Def.ThermalConductivity; tc *= tcModifier; insulator = tcModifier < 1.0f; } tc = GameUtil.GetDisplayThermalConductivity(tc); // Pass 1: float to string using Ryu text.Clear(); tc.ToRyuHardString(text, 3); string shcValue = text.ToString(); // Pass 2: Format into TC header string tcText = text.Clear().Append(ELEMENTAL.THERMALCONDUCTIVITY.NAME).Replace( "{0}", shcValue).Append(" (DTU/(m*s))/").Append(GameUtil. GetTemperatureUnitSuffix()).ToString(); // Pass 3: Final format into tooltip text.Clear().Append(ELEMENTAL.THERMALCONDUCTIVITY.TOOLTIP).Replace( "{THERMAL_CONDUCTIVITY}", shcValue).Replace("{TEMPERATURE_UNIT}", tempUnits); tcInfo = new InfoLine(tcText, text.ToString()); return(insulator); }
/// <summary> /// Populates the element phase change information. /// </summary> /// <param name="element">The selected element.</param> /// <param name="boil">The boiling/melting point information.</param> /// <param name="freeze">The freezing/condensation point information.</param> /// <param name="overheat">The overheat temperature information.</param> private static void PopulatePhase(Element element, out InfoLine boil, out InfoLine freeze, out InfoLine overheat) { string htc = GameUtil.GetFormattedTemperature(element.highTemp), ltc = GameUtil.GetFormattedTemperature(element.lowTemp); if (element.IsSolid) { string oh = GetOverheatModifier(element); boil = new InfoLine(ELEMENTAL.MELTINGPOINT.NAME.Format(htc), ELEMENTAL.MELTINGPOINT.TOOLTIP.Format(htc)); freeze = default; if (oh != null) { overheat = new InfoLine(ELEMENTAL.OVERHEATPOINT.NAME.Format(oh), ELEMENTAL.OVERHEATPOINT.TOOLTIP.Format(oh)); } else { overheat = default; } } else if (element.IsLiquid) { freeze = new InfoLine(ELEMENTAL.FREEZEPOINT.NAME.Format(ltc), ELEMENTAL.FREEZEPOINT.TOOLTIP.Format(ltc)); boil = new InfoLine(ELEMENTAL.VAPOURIZATIONPOINT.NAME.Format(htc), ELEMENTAL.VAPOURIZATIONPOINT.TOOLTIP.Format(htc)); overheat = default; } else if (element.IsGas) { boil = default; freeze = new InfoLine(ELEMENTAL.DEWPOINT.NAME.Format(ltc), ELEMENTAL.DEWPOINT.TOOLTIP.Format(ltc)); overheat = default; } else { boil = default; freeze = default; overheat = default; } }
/// <summary> /// Gets the specific heat text for the details screen. /// </summary> /// <param name="element">The selected element.</param> /// <param name="tempUnits">The temperature units to use for formatting.</param> /// <param name="shcInfo">The specific heat information.</returns> private static void GetSHCText(Element element, string tempUnits, out InfoLine shcInfo) { float shc = GameUtil.GetDisplaySHC(element.specificHeatCapacity); var text = CACHED_BUILDER; // Pass 1: float to string using Ryu text.Clear(); shc.ToRyuHardString(text, 3); string shcValue = text.ToString(); // Pass 2: Format into SHC header string shcText = text.Clear().Append(ELEMENTAL.SHC.NAME).Replace("{0}", shcValue). Append(" (DTU/g)/").Append(GameUtil.GetTemperatureUnitSuffix()).ToString(); // Pass 3: Final format into tooltip text.Clear().Append(ELEMENTAL.SHC.TOOLTIP).Replace("{SPECIFIC_HEAT_CAPACITY}", shcValue).Replace("{TEMPERATURE_UNIT}", tempUnits); shcInfo = new InfoLine(shcText, text.ToString()); }
internal LastSelectionDetails(GameObject go) { string tempUnits = GameUtil.GetTemperatureUnitSuffix(); if (go.TryGetComponent(out BuildingComplete bc)) { building = bc; } else { go.TryGetComponent(out building); } buildingComplete = bc; creationTimeCached = null; go.TryGetComponent(out operational); // Use primary element by default, but allow CellSelectionObject to stand in if (go.TryGetComponent(out PrimaryElement pe)) { element = pe.Element; cso = null; } else if (go.TryGetComponent(out cso)) { element = cso.element; } else { element = null; } primaryElement = pe; // Why these in particular? Clay please showUptime = go.TryGetComponent(out LogicPorts _) || go.TryGetComponent( out EnergyConsumer _) || go.TryGetComponent(out Battery _); target = go; uptimeCached = null; if (element != null) { string name = element.name; elementName = new InfoLine(ELEMENTAL.PRIMARYELEMENT.NAME.Format(name), ELEMENTAL.PRIMARYELEMENT.TOOLTIP.Format(name)); insulator = GetTCText(element, building, tempUnits, out thermalConductivity); GetSHCText(element, tempUnits, out specificHeat); if (DlcManager.FeatureRadiationEnabled()) { int cell = Grid.PosToCell(go.transform.position); radiationAbsorption = GameUtil.GetFormattedPercent(GameUtil. GetRadiationAbsorptionPercentage(cell) * 100.0f); } else { radiationAbsorption = null; } PopulatePhase(element, out boil, out freeze, out overheat); } else { boil = default; elementName = default; freeze = default; overheat = default; insulator = false; radiationAbsorption = null; specificHeat = default; thermalConductivity = default; } }