Active Cooling
Radiators now have a heat pump built into them
This commit is contained in:
parent
a71d01cb78
commit
ee0bba31b1
6 changed files with 70 additions and 30 deletions
|
|
@ -13,21 +13,37 @@ public class RadiatorData : BehaviorData
|
|||
[InspectableField, JsonProperty("emissivity"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Emissivity = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("pumpedHeat"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat PumpedHeat = new PerformanceStat();
|
||||
|
||||
[TemperatureInspectable, JsonProperty("temperatureFloor"), Key(3), RuntimeInspectable]
|
||||
public float TemperatureFloor;
|
||||
|
||||
[InspectableField, JsonProperty("wasteHeat"), Key(4), RuntimeInspectable]
|
||||
public PerformanceStat WasteHeat = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("energyUsage"), Key(5), RuntimeInspectable]
|
||||
public PerformanceStat EnergyUsage = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
{
|
||||
return new Radiator(context, this, entity, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class Radiator : IBehavior
|
||||
public class Radiator : IBehavior, IAlwaysUpdatedBehavior, IInitializableBehavior
|
||||
{
|
||||
public Entity Entity { get; }
|
||||
public EquippedItem Item { get; }
|
||||
public ItemManager Context { get; }
|
||||
public float Temperature { get; private set; }
|
||||
|
||||
public BehaviorData Data => _data;
|
||||
|
||||
public float Emissivity;
|
||||
public float Emissivity { get; private set; }
|
||||
public float PumpedHeat { get; private set; }
|
||||
public float WasteHeat { get; private set; }
|
||||
public float EnergyUsage { get; private set; }
|
||||
|
||||
private RadiatorData _data;
|
||||
|
||||
|
|
@ -41,10 +57,40 @@ public class Radiator : IBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
Emissivity = Context.Evaluate(_data.Emissivity, Item.EquippableItem, Entity);
|
||||
var rad = pow(Item.Temperature, Context.GameplaySettings.HeatRadiationExponent) * Context.GameplaySettings.HeatRadiationMultiplier * Emissivity;
|
||||
Item.AddHeat(-rad * delta);
|
||||
Entity.VisibilitySources[this] = rad;
|
||||
PumpedHeat = Context.Evaluate(_data.PumpedHeat, Item.EquippableItem, Entity);
|
||||
WasteHeat = Context.Evaluate(_data.WasteHeat, Item.EquippableItem, Entity);
|
||||
EnergyUsage = Context.Evaluate(_data.EnergyUsage, Item.EquippableItem, Entity);
|
||||
|
||||
var itemTemperature = Item.Temperature;
|
||||
var tempRatio = max(Temperature / itemTemperature, 1);
|
||||
|
||||
// Temperature ratio would cause more waste heat than pump capacity, stop executing
|
||||
if (tempRatio > PumpedHeat / WasteHeat) return true;
|
||||
|
||||
var pumpedHeat = PumpedHeat * max(itemTemperature - _data.TemperatureFloor, 0);
|
||||
|
||||
// Radiator temperature is below temperature floor, stop executing
|
||||
if (pumpedHeat < 0.01f) return true;
|
||||
|
||||
var wasteHeat = WasteHeat * tempRatio;
|
||||
Entity.Energy -= EnergyUsage * tempRatio * delta;
|
||||
|
||||
Item.AddHeat((wasteHeat - pumpedHeat) * delta);
|
||||
Temperature += pumpedHeat / Context.GetThermalMass(Item.EquippableItem) * delta;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Update(float delta)
|
||||
{
|
||||
Emissivity = Context.Evaluate(_data.Emissivity, Item.EquippableItem, Entity);
|
||||
var rad = pow(Temperature, Context.GameplaySettings.HeatRadiationExponent) * Context.GameplaySettings.HeatRadiationMultiplier * Emissivity;
|
||||
Temperature -= rad * delta;
|
||||
Entity.VisibilitySources[this] = rad;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Temperature = Item.Temperature;
|
||||
}
|
||||
}
|
||||
|
|
@ -719,13 +719,10 @@ public abstract class Entity
|
|||
// For all cells on the border of the entity, radiate some heat into space, increasing the visibility of the ship
|
||||
if (Parent==null && !hullData.InteriorCells[v])
|
||||
{
|
||||
// for(int i = 0; i<4; i++)
|
||||
// {
|
||||
var rad = pow(NewTemperature[v.x, v.y], ItemManager.GameplaySettings.HeatRadiationExponent) *
|
||||
ItemManager.GameplaySettings.HeatRadiationMultiplier;
|
||||
NewTemperature[v.x, v.y] -= rad * delta / 4;
|
||||
r += rad;
|
||||
// }
|
||||
var rad = pow(NewTemperature[v.x, v.y], ItemManager.GameplaySettings.HeatRadiationExponent) *
|
||||
ItemManager.GameplaySettings.HeatRadiationMultiplier;
|
||||
NewTemperature[v.x, v.y] -= rad * delta;
|
||||
r += rad;
|
||||
}
|
||||
|
||||
radiation += r;
|
||||
|
|
|
|||
Loading…
Reference in a new issue