Skip to content

Commit

Permalink
Merge pull request #100 from post-kerbin-mining-corporation/dev
Browse files Browse the repository at this point in the history
Release 2.3.3
  • Loading branch information
ChrisAdderley authored Sep 1, 2024
2 parents d7210ac + 76498d7 commit 07d5327
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 14 deletions.
17 changes: 15 additions & 2 deletions GameData/DynamicBatteryStorage/DynamicBatteryStorageSettings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ DYNAMICBATTERYSTORAGE
module = KopernicusSolarPanel
module = ModuleCurvedSolarPanel
module = ModuleDeployableSolarPanel
module = weatherDrivenSolarPanel
}
HANDLERCATEGORY
{
Expand All @@ -45,7 +46,7 @@ DYNAMICBATTERYSTORAGE
title = #LOC_DynamicBatteryStorage_UI_Category_Radiators
module = ModuleActiveRadiator
module = ModuleSystemHeatRadiator
module = ModuleSystemHeatTemperatureAdjuster
module = ModuleSystemHeatExchanger
}
HANDLERCATEGORY
{
Expand Down Expand Up @@ -202,6 +203,18 @@ DYNAMICBATTERYSTORAGE
continuous = true
}
PARTMODULEHANDLER
{
name = weatherDrivenSolarPanel
handlerModuleName = WDSPPowerHandlers
type = Power
visible = true
solarEfficiencyEffects = true
producer = true
consumer = false
simulated = true
continuous = true
}
PARTMODULEHANDLER
{
name = ModuleGenerator
handlerModuleName = ModuleGeneratorPowerHandler
Expand Down Expand Up @@ -998,7 +1011,7 @@ DYNAMICBATTERYSTORAGE
}
PARTMODULEHANDLER
{
name = ModuleSystemHeatTemperatureAdjuster
name = ModuleSystemHeatExchanger
type = Power
handlerModuleName = GenericFieldDataHandler
// Is this shown in the UI at all?
Expand Down
Binary file modified GameData/DynamicBatteryStorage/Plugins/DynamicBatteryStorage.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"MAJOR":2,
"MINOR":3,
"PATCH":2,
"PATCH":3,
"BUILD":0
},
"KSP_VERSION":
Expand Down
16 changes: 11 additions & 5 deletions Source/DynamicBatteryStorage/Data/VesselDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,30 @@ void FixedUpdate()
/// </summary>
protected void RefreshVesselData(Vessel eventVessel)
{
Utils.Log(String.Format("[{0}]: Refreshing VesselData from Vessel event", this.GetType().Name), Utils.LogType.VesselData);
RefreshVesselData();
if (vessel != null && vessel.loaded)
{
Utils.Log(String.Format("[{0}]: Refreshing VesselData from Vessel event", this.GetType().Name), Utils.LogType.VesselData);
RefreshVesselData();
}
}
/// <summary>
/// Referesh the data, given a ConfigNode event
/// </summary>
protected void RefreshVesselData(ConfigNode node)
{
Utils.Log(String.Format("[{0}]: Refreshing VesselData from save node event", this.GetType().Name), Utils.LogType.VesselData);
RefreshVesselData();
if (vessel != null && vessel.loaded)
{
Utils.Log(String.Format("[{0}]: Refreshing VesselData from save node event", this.GetType().Name), Utils.LogType.VesselData);
RefreshVesselData();
}
}

/// <summary>
/// Referesh the data classes
/// </summary>
protected void RefreshVesselData()
{
if (vessel == null || vessel.Parts == null)
if (vessel == null || vessel.Parts == null || !vessel.loaded)
return;

electricalData = new VesselElectricalData(vessel.Parts);
Expand Down
2 changes: 1 addition & 1 deletion Source/DynamicBatteryStorage/Data/VesselThermalData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override void SetupDataHandler(PartModule pm)
if (Settings.IsSupportedPartModule(pm.moduleName, ResourcesSupported.Heat))
{
HandlerModuleData data = Settings.GetPartModuleData(pm.moduleName, ResourcesSupported.Heat);
Utils.Log(String.Format("[{0}]: Detected supported heat handler for {1}: {2}", this.GetType().Name, pm.moduleName, data.handlerModuleName), Utils.LogType.VesselData);
//Utils.Log(String.Format("[{0}]: Detected supported heat handler for {1}: {2}", this.GetType().Name, pm.moduleName, data.handlerModuleName), Utils.LogType.VesselData);

string typeName = this.GetType().AssemblyQualifiedName;
typeName = typeName.Replace("VesselThermalData", data.handlerModuleName);
Expand Down
12 changes: 8 additions & 4 deletions Source/DynamicBatteryStorage/DynamicBatteryStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ protected override void OnStart()
GameEvents.onVesselWasModified.Add(new EventData<Vessel>.OnEvent(CalculateElectricalData));

FindDataManager();

Utils.Log(String.Format("[DynamicStorage] Initialization completed with buffer scale {0} and timewarp limit {1}", bufferScale, timeWarpLimit), Utils.LogType.DynamicStorage);
}

protected override void OnSave(ConfigNode node)
Expand Down Expand Up @@ -207,11 +205,17 @@ protected void CalculateElectricalData()

protected void CalculateElectricalData(Vessel eventVessel)
{
CalculateElectricalData();
if (vessel != null && vessel.loaded)
{
CalculateElectricalData();
}
}
protected void CalculateElectricalData(ConfigNode node)
{
CalculateElectricalData();
if (vessel != null && vessel.loaded)
{
CalculateElectricalData();
}
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Source/DynamicBatteryStorage/DynamicBatteryStorage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<Compile Include="UI\ToolbarSituation.cs" />
<Compile Include="UI\Tooltips.cs" />
<Compile Include="Utils.cs" />
<Compile Include="Handlers\Power\WDSPPowerHandlers.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
Expand Down
43 changes: 43 additions & 0 deletions Source/DynamicBatteryStorage/Handlers/Power/WDSPPowerHandlers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;

namespace DynamicBatteryStorage
{

/// <summary>
/// Handler for Weather Driven Solar Panel
/// </summary>
public class WDSPPowerHandlers : ModuleDataHandler
{
public WDSPPowerHandlers(HandlerModuleData moduleData) : base(moduleData)
{ }

public override bool Initialize(PartModule pm)
{
base.Initialize(pm);
/// If kopernicus is using the multistar settings, we need to only show this thing in flight as the new handler wipes the data in editor
/// We need to rely on the
if (Settings.KopernicusMultiStar)
{
return HighLogic.LoadedSceneIsFlight;
}
return true;
}

protected override double GetValueEditor()
{
/// Invalid in editor
return 0f;
}
protected override double GetValueFlight()
{
double results = 0d;
if (double.TryParse(pm.Fields.GetValue("currentOutput").ToString(), out results))
{
return results;
}
return results;

}
}

}
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v2.3.3
------
- Fixed SystemHeat heat exchangers not being detected correctly
- Changes to debug logging to make it less verbose and easier to find problems
- Added user-contibuted support for Weather Dependent Solar Panel

v2.3.2
------
- Fixed an issue in the Kerbalism disabler patch causing the mod to be disabled all the time :D
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==============================
Dynamic Battery Storage v2.3.2
Dynamic Battery Storage v2.3.3
==============================

A small utility mod for Kerbal Space Program, intended to support my other projects. Effectively required by Near Future Electrical, CryoEngines, KerballAtomics and CryoTanks.
Expand Down

0 comments on commit 07d5327

Please sign in to comment.