protected virtual void Cooling() { if (!HasEnoughCoolant() || primary.Temperature <= LowTemperature) { return; } PrimaryElement compo; float forchange = GameUtil.CalculateEnergyDeltaForElementChange(primary.Element.specificHeatCapacity, primary.Mass, primary.Temperature, primary.Temperature - CoolingPerSecond); List <GameObject> plist = new List <GameObject>(); storage.Find(CoolantTag, plist); float fmass, total = 0; for (int a = 0, max = plist.Count; a < max; a++) { compo = plist[a].GetComponent <PrimaryElement>(); total += compo.Mass * compo.Element.specificHeatCapacity; } compo = plist[0].GetComponent <PrimaryElement>(); fmass = compo.Mass * compo.Element.specificHeatCapacity / total; compo.Temperature += GameUtil.CalculateTemperatureChange(compo.Element.specificHeatCapacity, compo.Mass, -forchange * fmass * ThermalFudge);; primary.Temperature -= CoolingPerSecond; storage.Transfer(plist[0], OutStorage, false, true); }
// формулы расчета тепла и прироста температуры для порции хладагента массой minCoolantMass // для правильности расчета должны быть аналогичны формулам внутри LiquidCooledRefinery.SpawnOrderProduct public static float CalculateEnergyDelta(this LiquidCooledRefinery @this, ComplexRecipe recipe) { var firstresult = recipe.results[0]; var element = ElementLoader.GetElement(firstresult.material); return(GameUtil.CalculateEnergyDeltaForElementChange(firstresult.amount, element.specificHeatCapacity, element.highTemp, @this.outputTemperature) * @this.thermalFudge); }
public override List <Descriptor> AdditionalEffectsForRecipe(ComplexRecipe recipe) { List <Descriptor> list = base.AdditionalEffectsForRecipe(recipe); GameObject prefab = Assets.GetPrefab(recipe.results[0].material); PrimaryElement component = prefab.GetComponent <PrimaryElement>(); PrimaryElement primaryElement = inStorage.FindFirstWithMass(coolantTag); string format = UI.BUILDINGEFFECTS.TOOLTIPS.REFINEMENT_ENERGY_HAS_COOLANT; if ((Object)primaryElement == (Object)null) { GameObject prefab2 = Assets.GetPrefab(GameTags.Water); primaryElement = prefab2.GetComponent <PrimaryElement>(); format = UI.BUILDINGEFFECTS.TOOLTIPS.REFINEMENT_ENERGY_NO_COOLANT; } float num = 0f - GameUtil.CalculateEnergyDeltaForElementChange(component.Element.specificHeatCapacity, recipe.results[0].amount, component.Element.highTemp, outputTemperature); float temp = GameUtil.CalculateTemperatureChange(primaryElement.Element.specificHeatCapacity, minCoolantMass, num * thermalFudge); list.Add(new Descriptor(string.Format(UI.BUILDINGEFFECTS.REFINEMENT_ENERGY, GameUtil.GetFormattedJoules(num, "F1", GameUtil.TimeSlice.None)), string.Format(format, GameUtil.GetFormattedJoules(num, "F1", GameUtil.TimeSlice.None), primaryElement.GetProperName(), GameUtil.GetFormattedTemperature(temp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Relative, true, false)), Descriptor.DescriptorType.Effect, false)); return(list); }
protected override List <GameObject> SpawnOrderProduct(ComplexRecipe recipe) { List <GameObject> list = base.SpawnOrderProduct(recipe); PrimaryElement component = list[0].GetComponent <PrimaryElement>(); component.Temperature = outputTemperature; float num = GameUtil.CalculateEnergyDeltaForElementChange(component.Element.specificHeatCapacity, component.Mass, component.Element.highTemp, outputTemperature); ListPool <GameObject, LiquidCooledRefinery> .PooledList pooledList = ListPool <GameObject, LiquidCooledRefinery> .Allocate(); buildStorage.Find(coolantTag, pooledList); float num2 = 0f; foreach (GameObject item in pooledList) { PrimaryElement component2 = item.GetComponent <PrimaryElement>(); if (component2.Mass != 0f) { num2 += component2.Mass * component2.Element.specificHeatCapacity; } } foreach (GameObject item2 in pooledList) { PrimaryElement component3 = item2.GetComponent <PrimaryElement>(); if (component3.Mass != 0f) { float num3 = component3.Mass * component3.Element.specificHeatCapacity / num2; float kilowatts = (0f - num) * num3 * thermalFudge; float num4 = GameUtil.CalculateTemperatureChange(component3.Element.specificHeatCapacity, component3.Mass, kilowatts); float temperature = component3.Temperature; component3.Temperature += num4; } } buildStorage.Transfer(outStorage, coolantTag, 3.40282347E+38f, false, true); pooledList.Recycle(); return(list); }