public Radiator(GameContext context, RadiatorData data, Entity entity, Gear item) { Context = context; _data = data; Entity = entity; Item = item; }
public Radiator(RadiatorData data, ConsumableItemEffect item) : base(data, item) { _data = data; }
protected override void InternalCooling(RadiatorData thisRadiator, int radCount) { if (!base.vessel.IsFirstFrame()) { // TODO hard coding this for ElectricCharge but I may do something like this for all resource inputs IF there are likely to be other resource inputs // and IF those other inputs are likely to need scaling... double coolingEfficiency = 1; double refrigerationCost = 0; if (this.Dfld_RadCount.guiActive) { this.D_RadCount = radCount.ToString(); } this.coolParts.Clear(); this.hotParts.Clear(); int count = this.nonRadiatorParts.Count; while (count-- > 0) { Part part = this.nonRadiatorParts[count]; if (part.temperature > part.maxTemp * part.radiatorMax) { this.hotParts.Add(part); } } int count2 = this.hotParts.Count; for (int i = 0; i < count2; i++) { Part part2 = this.hotParts[i]; bool flag = true; if (this.parentCoolingOnly) { flag = this.IsSibling(part2); } if (flag) { RadiatorData thermalData = RadiatorUtilities.GetThermalData(part2); double energyDifference = thermalData.Energy - thermalData.MaxEnergy; if (energyDifference > 0.0) { this.coolParts.Add(thermalData); } } } int cooledParts = this.coolParts.Count; // Would have liked to do this part as coolParts was being built so the list doesn't have to be walked through twice // but I don't know the amount of flux until after it's done being built - so if I want to throttle refrigeration I have to do this. for (int i = 0; i < cooledParts; i++) { if (coolParts[i].Part.temperature < base.part.temperature) { RadiatorData partThermalData = this.coolParts[i]; coolingEfficiency = CoolingEfficiency(coolParts[i].Part.temperature, base.part.temperature); double _maxCryoEnergyTransfer = maxCryoElectricCost * coolingEfficiency; double excessHeat = (partThermalData.Energy - partThermalData.MaxEnergy); excessHeat /= (double)(radCount + cooledParts); double val = Math.Min(Math.Max(0, thisRadiator.EnergyCap - thisRadiator.Energy), _maxCryoEnergyTransfer); double liftedHeatFlux = Math.Min(val, excessHeat) * Math.Min(1.0, cryoEnergyTransferScale) * refrigerationThrottle; refrigerationCost += Math.Min(maxCryoElectricCost, liftedHeatFlux / coolingEfficiency); } } for (int i = 0; i < this.compensatedParts.Count; i++) { Part part = compensatedParts[i]; if (!(part.temperature < part.maxTemp * part.radiatorMax)) { double conductionFlux = part.thermalConductionFlux + part.skinToInternalFlux; if (conductionFlux > 0 && part.temperature < base.part.temperature) { coolingEfficiency = CoolingEfficiency(part.temperature, base.part.temperature); conductionFlux = Math.Min(conductionFlux, maxCryoElectricCost * coolingEfficiency); conductionFlux *= refrigerationThrottle; refrigerationCost += conductionFlux / coolingEfficiency; } } } if (electricResourceIndex >= 0) { this.resHandler.inputResources[electricResourceIndex].rate = baseElectricRate + refrigerationCost; //double powerAvailability = this.resHandler.UpdateModuleResourceInputs(ref this.status, radCount, 0.9, false, false, true); double ECAmount, ECMaxAmount; this.part.GetConnectedResourceTotals(ECID, PartResourceLibrary.GetDefaultFlowMode(ECID), out ECAmount, out ECMaxAmount, true); // if the craft has mixed radiator types then availability calculation may be wrong double powerAvailability = ECAmount / ((refrigerationCost * radCount) + 0.1); if (powerAvailability < 1.0) { // Looks like radiator count can include inactive radiators so this could throttle cooling down more than intended. refrigerationThrottle = powerAvailability * 0.75 / radCount; refrigerationCost *= refrigerationThrottle; this.resHandler.inputResources[electricResourceIndex].rate = baseElectricRate + (refrigerationCost); } else if (refrigerationThrottle < 1.0) { // Try to increase the throttle if power reserves have increased to more than 10x what would be required. if (powerAvailability >= 10 * refrigerationCost) { refrigerationThrottle += 0.001; refrigerationCost *= refrigerationThrottle; this.resHandler.inputResources[electricResourceIndex].rate = baseElectricRate + (refrigerationCost); } } //this.resHandler.UpdateModuleResourceInputs(ref this.status, 1, 0.9, false, false, true); refrigerationThrottle = Math.Min(refrigerationThrottle, 1); if (this.Dfld_RefrCost.guiActive) { this.D_RefrCost = refrigerationCost.ToString("F4") + " (throttle = " + refrigerationThrottle.ToString("P0") + ")"; } } if (this.Dfld_CoolParts.guiActive) { this.D_CoolParts = StringBuilderCache.Format("{0}/{1}", new object[] { cooledParts, this.hotParts.Count }); } for (int j = 0; j < cooledParts; j++) { RadiatorData radiatorData = this.coolParts[j]; bool useHeatPump = radiatorData.Part.temperature < base.part.temperature; coolingEfficiency = CoolingEfficiency(coolParts[j].Part.temperature, base.part.temperature); double _maxCryoEnergyTransfer = maxCryoElectricCost * coolingEfficiency; double excessHeat = (radiatorData.Energy - radiatorData.MaxEnergy); excessHeat /= (double)(radCount + cooledParts); double _maxEnergyTransfer = radiatorData.Part.temperature >= base.part.temperature ? this.maxEnergyTransfer : _maxCryoEnergyTransfer; double val = Math.Min(Math.Max(0, thisRadiator.EnergyCap - thisRadiator.Energy), _maxEnergyTransfer); double liftedHeatFlux = Math.Min(val, excessHeat); if (this.Dfld_XferBase.guiActive) { this.D_XferBase = liftedHeatFlux.ToString(); } liftedHeatFlux *= Math.Min(1.0, useHeatPump ? cryoEnergyTransferScale : this.energyTransferScale); if (useHeatPump) { liftedHeatFlux *= refrigerationThrottle; } if (liftedHeatFlux > 0.0) { radiatorData.Part.AddThermalFlux(-liftedHeatFlux); base.part.AddThermalFlux(liftedHeatFlux); } if (this.Dfld_Excess.guiActive) { this.D_Excess = excessHeat.ToString(); } if (this.Dfld_HeadRoom.guiActive) { this.D_HeadRoom = val.ToString(); } if (this.Dfld_XferFin.guiActive) { this.D_XferFin = liftedHeatFlux.ToString(); } } for (int i = 0; i < this.compensatedParts.Count; i++) { Part part = this.compensatedParts[i]; if (!(part.temperature < Math.Round(part.maxTemp * part.radiatorMax, 4))) { double conductionFlux = part.thermalConductionFlux + part.skinToInternalFlux; if (conductionFlux > 0) { double compensatedFlux = Math.Min(conductionFlux, CoolingEfficiency(part.temperature, this.part.temperature) * maxCryoElectricCost) * refrigerationThrottle / radCount; part.AddThermalFlux(-compensatedFlux); base.part.AddThermalFlux(compensatedFlux); } } } } }
public Radiator(RadiatorData data, EquippedItem item) : base(data, item) { _data = data; }