Skip to content

Commit

Permalink
Merge pull request #40 from post-kerbin-mining-corporation/dev
Browse files Browse the repository at this point in the history
Release 0.3.3
  • Loading branch information
ChrisAdderley authored Dec 30, 2020
2 parents e0785aa + 6c861db commit 365508c
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 29 deletions.
4 changes: 4 additions & 0 deletions GameData/SystemHeat/Localization/en-us.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ Localization
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_Enable_Title = Enable Reactor
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_DisableManual_Title = Disable Manual Control
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_EnableManual_Title = Enable Manual Control
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_EnableHibernate_Title = Enable Hibernation
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_DisableHibernate_Title = Disable Hibernation
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_ShowReactorControl = Toggle Reactor Control
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_RepairReactor = Repair Reactor
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_EmergencyShutdown = Emergency shutdown temperature of <<1>> was exceeded on <<2>>! Emergency SCRAM!
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_RepairSuccess = Reactor repaired to <<1>>%!
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_CoreTooDamaged = Reactor is too damaged to repair
#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_CoreAlreadyRepaired = Reactor core is already at maximum field repairable integrity (<<1>>%)
Expand Down
39 changes: 37 additions & 2 deletions GameData/SystemHeat/Localization/zh-cn.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Localization
/// ModuleSystemHeatConverter
/// =================================

#LOC_SystemHeat_ModuleSystemHeatConverter_PartInfoAdd = \n\n<color=#ff730d>热量参数:</color>\n<b> - 产热:</b> <<1>> kW\n<b> - 输出温度:</b> <<2>> K\n<b> - 最大温度:</b> <<3>> // \n\n<color=#ff730d>Thermal Parameters:</color>\n<b> - Heat Generated:</b> <<1>> kW\n<b> - Outlet Temperature:</b> <<2>> K\n<b> - Max. Temperature:</b> <<3>>
#LOC_SystemHeat_ModuleSystemHeatConverter_PartInfoAdd = \n\n<color=#ff730d>热量参数:</color>\n<b> - 产热:</b> <<1>> kW\n<b> - 输出温度:</b> <<2>> K\n<b> - 最大温度:</b> <<3>> 开尔文 // \n\n<color=#ff730d>Thermal Parameters:</color>\n<b> - Heat Generated:</b> <<1>> kW\n<b> - Outlet Temperature:</b> <<2>> K\n<b> - Max. Temperature:</b> <<3>>

#LOC_SystemHeat_ModuleSystemHeatConverter_Field_Efficiency = 效率 [<<1>>]//Efficiency [<<1>>]
#LOC_SystemHeat_ModuleSystemHeatConverter_Field_Efficiency_Value = <<1>>% //<<1>>%
Expand All @@ -205,7 +205,7 @@ Localization
/// ModuleSystemHeatHarvester
/// =================================

#LOC_SystemHeat_ModuleSystemHeatHarvester_PartInfoAdd = \n\n<color=#ff730d>热量参数:</color>\n<b> - 产热:</b> <<1>> kW\n<b> - 输出热量:</b> <<2>> K\n<b> - Max. Temperature:</b> <<3>>
#LOC_SystemHeat_ModuleSystemHeatHarvester_PartInfoAdd = \n\n<color=#ff730d>热量参数:</color>\n<b> - 产热:</b> <<1>> kW\n<b> - 输出热量:</b> <<2>> K\n<b> - Max. Temperature:</b> <<3>> 开尔文//\n\n<color=#ff730d>Thermal Parameters:</color>\n<b> - Heat Generated:</b> <<1>> kW\n<b> - Outlet Temperature:</b> <<2>> K\n<b> - Max. Temperature:</b> <<3>> K

#LOC_SystemHeat_ModuleSystemHeatHarvester_Field_Efficiency = 效率 //Efficiency
#LOC_SystemHeat_ModuleSystemHeatHarvester_Field_Efficiency_Value = <<1>>% //<<1>>%
Expand All @@ -227,5 +227,40 @@ Localization
#LOC_SystemHeat_systemheat-sink-1_title = PSK-200 热储罐 //PSK-200 Heat Sink
#LOC_SystemHeat_systemheat-sink-1_description = 这是一个沉重,沉重的水箱,里面装有一些听起来听起来很科学的材料,可以在饱和之前吸收一些热能。 如果您确实需要在某个地方存储一段时间热量,则很有用。//This is a hefty, heavy tank of some sciencey-sounding material that can absorb a fair bit of thermal energy before getting saturated. Useful if you really need somewhere to store some heat for a while.
#LOC_SystemHeat_systemheat-sink-1_tags = systemheat

// CARGO
// ---------------
#LOC_SystemHeat_systemheat-nuclear-container-1_title = EVA核燃料转移罐//Nuclear Fuel Cylinder
#LOC_SystemHeat_systemheat-nuclear-container-1_description = 用于让小绿人通过舱外活动在部件之间转移核燃料 // EVA part to allow Kerbals to collect nuclear materials and transfer them betwen relevant parts.
#LOC_SystemHeat_systemheat-nuclear-container-1_tags = cargo fix refuel fuel transfer nuclear waste uranium

// RADIATORS
// PARTS
// Curved Radiators
#LOC_SystemHeat_radiator-surface-125-1_title = YF-7 "以西结" 高温散热器 // YF-7 'Ezikiel' High Temperature Heat Radiator
#LOC_SystemHeat_radiator-surface-25-1_title = YF-15 "伏打" 高温散热器 // YF-15 'Volta' High Temperature Heat Radiator
#LOC_SystemHeat_radiator-surface-375-1_title = YF-25 "阿摩司" 高温散热器 // YF-25 'Amos' High Temperature Heat Radiator

// Fixed radiators
#LOC_SystemHeat_radiator-fixed-1_title = VF-60 "贝塔" 高温散热器 // VF-60 'Beta' High Temperature Heat Radiator
#LOC_SystemHeat_radiator-fixed-2_title = VF-8 "阿尔法" 高温散热鳍片 // VF-8 'Alpha' High Temperature Radiator Fin
#LOC_SystemHeat_radiator-fixed-3_title = VF-325 "伽马" 高温散热器 // VF-325 'Gamma' High Temperature Heat Radiator
#LOC_SystemHeat_radiator-fixed-4_title = VF-1250 "德尔塔" 高温散热器 // VF-1250 'Delta' High Temperature Heat Radiator

// Conformal Radiators
#LOC_SystemHeat_radiator-conformal-1_title = GR-25 高温散热器 // GR-25 High Temperature Heat Radiator
#LOC_SystemHeat_radiator-conformal-2_title = GR-50 高温散热器 // GR-50 High Temperature Heat Radiator
#LOC_SystemHeat_radiator-conformal-3_title = GR-1125 高温散热器 // GR-1125 High Temperature Heat Radiator

// Deployable radiators
#LOC_SystemHeat_radiator-universal-1_title = XR-175 高温散热器 // XR-175 High Temperature Heat Radiator
#LOC_SystemHeat_radiator-universal-2_title = XR-500 高温散热器 // XR-500 High Temperature Heat Radiator
#LOC_SystemHeat_radiator-universal-3_title = XR-600 高温散热器 // XR-600 High Temperature Heat Radiator

// Microchannel Radiators
#LOC_SystemHeat_radiator-microchannel-1_title = DF-3.25K 石墨烯微管散热器 // DF-3.25K Microchannel Graphene Heat Radiator
#LOC_SystemHeat_radiator-microchannel-2_title = DF-6.5K 石墨烯微管散热器 // DF-6.5K Microchannel Graphene Heat Radiator
#LOC_SystemHeat_radiator-microchannel-fixed-1_title = EF-2K 石墨烯微管散热器 // EF-2K Microchannel Graphene Heat Radiator Panel
#LOC_SystemHeat_radiator-microchannel-fixed-2_title = EF-1K 石墨烯微管散热器 // EF-1K Microchannel Graphene Heat Radiator Panel
}
}
Binary file modified GameData/SystemHeat/Plugin/SystemHeat.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion GameData/SystemHeat/Versioning/SystemHeat.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"MAJOR":0,
"MINOR":3,
"PATCH":2,
"PATCH":3,
"BUILD":0
},
"KSP_VERSION":
Expand Down
1 change: 1 addition & 0 deletions SystemHeat/SystemHeat/HeatLoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ void SimulateIteration(float simTimeStep)
float deltaTemperatureIdeal = NetFlux*1000f / (Volume * CoolantType.Density * CoolantType.HeatCapacity) * simTimeStep;



// Flux has be be higher than a tolerance threshold in order to do things
if (absFlux > SystemHeatSettings.AbsFluxThreshold)
{
Expand Down
116 changes: 99 additions & 17 deletions SystemHeat/SystemHeat/Modules/ModuleSystemHeatFissionReactor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public class ModuleSystemHeatFissionReactor : PartModule
[KSPField(isPersistant = true)]
public bool Enabled = false;

[KSPField(isPersistant = true)]
public bool HibernateOnWarp = false;

[KSPField(isPersistant = true)]
public bool Hibernating = false;


// Sets user control to manual
[KSPField(isPersistant = true)]
public bool ManualControl = false;
Expand Down Expand Up @@ -163,18 +170,26 @@ public void EnableManual()
{
SetManualControl(true);
}
[KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_DisableManual_Title", active = true, groupName = "fissionreactor", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_UIGroup_Title", groupStartCollapsed = false)]
[KSPEvent(guiActive = false, guiActiveEditor = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_DisableManual_Title", active = true, groupName = "fissionreactor", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_UIGroup_Title", groupStartCollapsed = false)]
public void DisableManual()
{
SetManualControl(false);
}
/// Toggle control panel
[KSPEvent(guiActive = false, guiName = "Toggle Reactor Control", active = true, groupName = "fissionreactor", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_UIGroup_Title")]
public void ShowReactorControl()
[KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_EnableHibernate_Title", active = true, groupName = "fissionreactor", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_UIGroup_Title", groupStartCollapsed = false)]
public void EnableHibernate()
{
HibernateOnWarp = true;
GameEvents.onPartPack.Add(new EventData<Part>.OnEvent(GoOnRails));
GameEvents.onPartUnpack.Add(new EventData<Part>.OnEvent(GoOffRails));
}
[KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_DisableHibernate_Title", active = true, groupName = "fissionreactor", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatFissionReactor_UIGroup_Title", groupStartCollapsed = false)]
public void DisableHibernate()
{
/// TODO: UI DAMN
//ReactorUI.ToggleReactorWindow();
HibernateOnWarp = false;
GameEvents.onPartPack.Remove(GoOnRails);
GameEvents.onPartUnpack.Remove(GoOffRails);
}

// Try to fix the reactor
[KSPEvent(externalToEVAOnly = true, guiActiveUnfocused = true, unfocusedRange = 3.5f, guiName = "Repair Reactor")]
public void RepairReactor()
Expand All @@ -186,6 +201,11 @@ public void RepairReactor()
}
/// KSPACTIONS
/// ----------------------

[KSPAction("Toggle Hibernate")]
public void ToggleHibernateAction(KSPActionParam param)
{
}

[KSPAction("Enable Reactor")]
public void EnableAction(KSPActionParam param)
Expand All @@ -206,11 +226,6 @@ public void ToggleAction(KSPActionParam param)
else DisableReactor();
}

[KSPAction("Toggle Reactor Panel")]
public void TogglePanelAction(KSPActionParam param)
{
ShowReactorControl();
}

protected ModuleSystemHeat heatModule;
protected List<ResourceRatio> inputs;
Expand Down Expand Up @@ -243,6 +258,29 @@ public override string GetInfo()

}

public virtual void GoOnRails(Part p)
{

if (HibernateOnWarp && Enabled)
{
Hibernating = true;
ReactorDeactivated();
Utils.Log($"[ModuleSystemHeatFissionReactor] Reactor was on: Going on rails and hibernating reactor");
}
}
public virtual void GoOffRails(Part p)
{

if (HibernateOnWarp)
{
if (Hibernating)
{
ReactorActivated();
Hibernating = false;
Utils.Log($"[ModuleSystemHeatFissionReactor] Going off rails and resuming reactor");
}
}
}
public virtual void SetManualControl(bool state)
{
ManualControl = state;
Expand All @@ -269,7 +307,7 @@ public virtual void Start()
{
ConfigNode node = ModuleUtils.GetModuleConfigNode(part, moduleName);
if (node != null)
OnLoad(node);
OnLoad(node);
}

heatModule = ModuleUtils.FindHeatModule(this.part, systemHeatModuleID);
Expand Down Expand Up @@ -313,6 +351,12 @@ public virtual void Start()
if (HighLogic.LoadedSceneIsFlight)
{
GameEvents.OnVesselRollout.Add(new EventData<ShipConstruct>.OnEvent(OnVesselRollout));
if (HibernateOnWarp)
{
GameEvents.onPartPack.Add(new EventData<Part>.OnEvent(GoOnRails));
GameEvents.onPartUnpack.Add(new EventData<Part>.OnEvent(GoOffRails));
}

DoCatchup();
SetManualControl(ManualControl);

Expand All @@ -323,6 +367,9 @@ void OnDestroy()
{
// Clean up events when the item is destroyed
GameEvents.OnVesselRollout.Remove(OnVesselRollout);

GameEvents.onPartPack.Remove(GoOnRails);
GameEvents.onPartUnpack.Remove(GoOffRails);
}
/// <summary>
///
Expand Down Expand Up @@ -393,6 +440,11 @@ public void Update()
Events["DisableReactor"].active = Enabled;
Events["EnableReactor"].active = !Enabled;
}
if (Events["EnableHibernate"].active == HibernateOnWarp || Events["DisableHibernate"].active != HibernateOnWarp)
{
Events["DisableHibernate"].active = HibernateOnWarp;
Events["EnableHibernate"].active = !HibernateOnWarp;
}
}
}

Expand Down Expand Up @@ -428,6 +480,9 @@ public virtual void FixedUpdate()
HandleResourceActivities(TimeWarp.fixedDeltaTime);
if (heatModule.currentLoopTemperature > CurrentSafetyOverride)
{
ScreenMessages.PostScreenMessage(new ScreenMessage(
Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_EmergencyShutdown", CurrentSafetyOverride.ToString("F0"), part.partInfo.title
), 5.0f, ScreenMessageStyle.UPPER_CENTER));
ReactorDeactivated();
}
}
Expand Down Expand Up @@ -532,6 +587,18 @@ private void HandleResourceActivities(float timeStep)
float fuelThrottle = CurrentReactorThrottle / 100f;

bool fuelCheckPassed = true;

// Check for full-ness
foreach (ResourceRatio ratio in outputs)
{
if (CheckFull(ratio.ResourceName, fuelThrottle * ratio.Ratio * timeStep))
{
ReactorDeactivated();
return;
}

}
// CHeck for fuel and consume
foreach (ResourceRatio ratio in inputs)
{
double amt = this.part.RequestResource(ratio.ResourceName, fuelThrottle * ratio.Ratio * timeStep, ratio.FlowMode);
Expand All @@ -543,18 +610,21 @@ private void HandleResourceActivities(float timeStep)
if (ratio.ResourceName == FuelName)
burnRate = ratio.Ratio;
}
// If fuel consumed, add waste
if (fuelCheckPassed)
{
foreach (ResourceRatio ratio in outputs)
{
double amt = this.part.RequestResource(ratio.ResourceName, -fuelThrottle * ratio.Ratio * timeStep, ratio.FlowMode);
}
}

if (GeneratesElectricity)
{
if (HighLogic.LoadedSceneIsEditor)
CurrentElectricalGeneration = ElectricalGeneration.Evaluate(CurrentReactorThrottle);
if (fuelCheckPassed)
{
foreach (ResourceRatio ratio in outputs)
{
double amt = this.part.RequestResource(ratio.ResourceName, -fuelThrottle * ratio.Ratio * timeStep, ratio.FlowMode);
}

CurrentElectricalGeneration = ElectricalGeneration.Evaluate(CurrentThrottle);
this.part.RequestResource(PartResourceLibrary.ElectricityHashcode, -CurrentElectricalGeneration * timeStep, ResourceFlowMode.ALL_VESSEL);

Expand All @@ -572,8 +642,20 @@ private void HandleResourceActivities(float timeStep)
burnRate);

}
public bool CheckFull(string nm, double eps)
{

if (this.part.Resources.Get(PartResourceLibrary.Instance.GetDefinition(nm).id) != null)
if (this.part.Resources.Get(PartResourceLibrary.Instance.GetDefinition(nm).id).amount + eps >=
this.part.Resources.Get(PartResourceLibrary.Instance.GetDefinition(nm).id).maxAmount)
return true;
else
return false;


return false;
}

#region Repair
public bool TryRepairReactor()
{
Expand Down
22 changes: 14 additions & 8 deletions SystemHeat/SystemHeat/Modules/ModuleSystemHeatRadiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace SystemHeat
/// <summary>
/// The connection between a stock ModuleActiveRadiator and the SystemHeat system
/// </summary>
public class ModuleSystemHeatRadiator: ModuleActiveRadiator
public class ModuleSystemHeatRadiator : ModuleActiveRadiator
{
// This should be unique on the part and identifies the module
[KSPField(isPersistant = false)]
Expand Down Expand Up @@ -52,11 +52,11 @@ public override string GetModuleDisplayName()
public override string GetInfo()
{
// Need to update this to strip the CoreHeat stuff from it
string message = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo",
temperatureCurve.Curve.keys[0].time.ToString("F0"),
string message = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo",
temperatureCurve.Curve.keys[0].time.ToString("F0"),
temperatureCurve.Evaluate(temperatureCurve.Curve.keys[0].time).ToString("F0"),
temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time).ToString("F0"),
temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length-1].time.ToString("F0")
temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time.ToString("F0")
);
message += base.GetInfo();
return message;
Expand All @@ -74,8 +74,11 @@ public override void FixedUpdate()
if (base.IsCooling)
{
float flux = -temperatureCurve.Evaluate(heatModule.LoopTemperature);
heatModule.AddFlux(moduleID, 0f, flux);
RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
if (heatModule.LoopTemperature >= heatModule.nominalLoopTemperature)
heatModule.AddFlux(moduleID, 0f, flux);
else
heatModule.AddFlux(moduleID, 0f, 0f);
RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
(-flux / temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time) * 100f).ToString("F0"));
}
else
Expand All @@ -89,10 +92,13 @@ public override void FixedUpdate()
if (HighLogic.LoadedSceneIsEditor)
{
float flux = -1.0f * temperatureCurve.Evaluate(heatModule.LoopTemperature);
heatModule.AddFlux(moduleID, 0f, flux);
if (heatModule.LoopTemperature >= heatModule.nominalLoopTemperature)
heatModule.AddFlux(moduleID, 0f, flux);
else
heatModule.AddFlux(moduleID, 0f, 0f);

//Utils.Log($"BLAH {heatModule.LoopTemperature} {flux} {temperatureCurve.Evaluate(heatModule.LoopTemperature)}");
RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
((-temperatureCurve.Evaluate(heatModule.LoopTemperature) / temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time)) * 100f).ToString("F0"));
}
}
Expand Down
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v0.3.3
------
- Fixed fission reactor Manual mode showing both on and off buttons at game start
- Fixed fission reactors still generating power/working when they were full of waste
- Fixed fission reactors that didn't generate electricity not generating waste
- Added emergency shutdown message to fission reactors when safety temp is exceeded.
- Added Hibernate On Warp control to fission reactors: if activated, an enabled reactor will turn off when the ship goes on rails. It will reactivate when the ship goes off rails.
- Fixed a bug in loop integration that could cause strange behaviour below norminal temperatures

v0.3.2
------
- Heat Control radiator names are now adjusted when installed to match their SystemHeat capacities
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
================
SystemHeat 0.3.2
SystemHeat 0.3.3
================

A mod for Kerbal Space Program, intended to provide a better experience for heat management, particularly geared towards resource extraction, high energy engines, and nuclear reactors.
Expand Down

0 comments on commit 365508c

Please sign in to comment.