Skip to content

Commit

Permalink
Merge pull request #102 from post-kerbin-mining-corporation/dev
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
ChrisAdderley authored Nov 21, 2024
2 parents 07d5327 + 30a5d33 commit cd02bd9
Show file tree
Hide file tree
Showing 44 changed files with 1,311 additions and 1,684 deletions.
27 changes: 25 additions & 2 deletions GameData/DynamicBatteryStorage/DynamicBatteryStorageSettings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,37 @@ DYNAMICBATTERYSTORAGE
simulated = true
continuous = true
}

PARTMODULEHANDLER
{
name = ModuleRadioisotopeGenerator
handlerModuleName = ModuleRadioisotopeGeneratorPowerHandler
// The name of the module
name = ModuleRadioisotopeGeneratorPowerHandler
// The type of handler - can be Power or Heat
type = Power
// The name of the handler to use
handlerModuleName = GenericFieldDataHandler
// Is this shown in the UI at all?
visible = true
// Do we use solar distance attenuation?
solarEfficiencyEffects = false
// Is this module a producer by default?
producer = true
// Is this module a consumer by default?
consumer = false
// Does this item start off as active in the UI? Should canonically be true for constant sources/draws
simulated = true
// Does this item count as a continuous power source for the purpose of the UI?
continuous = true
HANDLER_CONFIG
{
// Field to poll in editor
editorFieldName = BasePower
// Field to poll in flight
flightFieldName = ActualPower
// Multiply the output by these if you need to. Convention is that a consumer is negative.
editorValueScalar = -1.0
flightValueScalar = -1.0
}
}
PARTMODULEHANDLER
{
Expand Down Expand Up @@ -429,6 +449,9 @@ DYNAMICBATTERYSTORAGE
simulated = false
continuous = false
}



PARTMODULEHANDLER
{
name = ModuleLight
Expand Down
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":3,
"PATCH":4,
"BUILD":0
},
"KSP_VERSION":
Expand Down
74 changes: 29 additions & 45 deletions Source/DynamicBatteryStorage/Data/VABVesselDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public class EditorVesselDataManager : MonoBehaviour

public static EditorVesselDataManager Instance { get; private set; }
public VesselElectricalData ElectricalData { get { return electricalData; } }
public VesselThermalData HeatData { get { return heatData; } }

public bool Ready { get { return dataReady; } }

#endregion
Expand All @@ -26,43 +24,35 @@ public class EditorVesselDataManager : MonoBehaviour
bool dataReady = false;

VesselElectricalData electricalData;
VesselThermalData heatData;
#endregion

protected void Awake()
{
enabled = Settings.Enabled;
Instance = this;
}
protected void Start()
{
SetupEditorCallbacks();
}

#region Editor
protected void SetupEditorCallbacks()
{
/// Add events for editor modifications
if (HighLogic.LoadedSceneIsEditor)
{
GameEvents.onEditorShipModified.Add(new EventData<ShipConstruct>.OnEvent(onEditorVesselModified));
GameEvents.onEditorRestart.Add(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorStarted.Add(new EventVoid.OnEvent(onEditorVesselStart));
GameEvents.onEditorPartDeleted.Add(new EventData<Part>.OnEvent(onEditorPartDeleted));
GameEvents.onEditorPodDeleted.Add(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorLoad.Add(new EventData<ShipConstruct, KSP.UI.Screens.CraftBrowserDialog.LoadType>.OnEvent(onEditorVesselLoad));
GameEvents.onPartRemove.Add(new EventData<GameEvents.HostTargetAction<Part, Part>>.OnEvent(onEditorVesselPartRemoved));
}
else
{
GameEvents.onEditorShipModified.Remove(new EventData<ShipConstruct>.OnEvent(onEditorVesselModified));
GameEvents.onEditorRestart.Remove(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorStarted.Remove(new EventVoid.OnEvent(onEditorVesselStart));
GameEvents.onEditorPodDeleted.Remove(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorPartDeleted.Remove(new EventData<Part>.OnEvent(onEditorPartDeleted));
GameEvents.onEditorLoad.Remove(new EventData<ShipConstruct, KSP.UI.Screens.CraftBrowserDialog.LoadType>.OnEvent(onEditorVesselLoad));
GameEvents.onPartRemove.Remove(new EventData<GameEvents.HostTargetAction<Part, Part>>.OnEvent(onEditorVesselPartRemoved));
}
GameEvents.onEditorShipModified.Add(new EventData<ShipConstruct>.OnEvent(onEditorVesselModified));
GameEvents.onEditorRestart.Add(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorStarted.Add(new EventVoid.OnEvent(onEditorVesselStart));
GameEvents.onEditorPartDeleted.Add(new EventData<Part>.OnEvent(onEditorPartDeleted));
GameEvents.onEditorPodDeleted.Add(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorLoad.Add(new EventData<ShipConstruct, KSP.UI.Screens.CraftBrowserDialog.LoadType>.OnEvent(onEditorVesselLoad));
GameEvents.onPartRemove.Add(new EventData<GameEvents.HostTargetAction<Part, Part>>.OnEvent(onEditorVesselPartRemoved));
}

void OnDestroy()
{
GameEvents.onEditorShipModified.Remove(new EventData<ShipConstruct>.OnEvent(onEditorVesselModified));
GameEvents.onEditorRestart.Remove(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorStarted.Remove(new EventVoid.OnEvent(onEditorVesselStart));
GameEvents.onEditorPodDeleted.Remove(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorPartDeleted.Remove(new EventData<Part>.OnEvent(onEditorPartDeleted));
GameEvents.onEditorLoad.Remove(new EventData<ShipConstruct, KSP.UI.Screens.CraftBrowserDialog.LoadType>.OnEvent(onEditorVesselLoad));
GameEvents.onPartRemove.Remove(new EventData<GameEvents.HostTargetAction<Part, Part>>.OnEvent(onEditorVesselPartRemoved));
}

protected void InitializeEditorConstruct(ShipConstruct ship, bool forceReset)
Expand All @@ -75,39 +65,27 @@ protected void InitializeEditorConstruct(ShipConstruct ship, bool forceReset)
else
electricalData.RefreshData(false, ship.Parts);

if (heatData == null || forceReset)
heatData = new VesselThermalData(ship.Parts);
else
heatData.RefreshData(false, ship.Parts);


Utils.Log(String.Format("Dumping electrical database: \n{0}", electricalData.ToString()), Utils.LogType.VesselData);
Utils.Log(String.Format("Dumping thermal database: \n{0}", heatData.ToString()), Utils.LogType.VesselData);

dataReady = true;
}
else
{
Utils.Log(String.Format("Ship is null"), Utils.LogType.VesselData);
electricalData = new VesselElectricalData(new List<Part>());
heatData = new VesselThermalData(new List<Part>());
}
}

protected void RemovePart(Part p)
{

electricalData.RemoveHandlersForPart(p);
heatData.RemoveHandlersForPart(p);

}
#endregion


#region Game Events
public void onEditorPartDeleted(Part part)
{
Utils.Log("[VAB VesselDataManager][Editor]: Part Delete", Utils.LogType.VesselData);
Utils.Log("[VAB VesselDataManager][Editor]: Part DELETED", Utils.LogType.VesselData);
if (!HighLogic.LoadedSceneIsEditor) { return; }

InitializeEditorConstruct(EditorLogic.fetch.ship, false);
Expand All @@ -120,22 +98,28 @@ public void onEditorVesselReset()
}
public void onEditorVesselStart()
{
Utils.Log("[VAB VesselDataManager]: Vessel START", Utils.LogType.VesselData);
Utils.Log("[VAB VesselDataManager][Editor]: Vessel START", Utils.LogType.VesselData);
if (!HighLogic.LoadedSceneIsEditor) { return; }
InitializeEditorConstruct(EditorLogic.fetch.ship, true);
}
public void onEditorVesselRestore()
{
Utils.Log("[VAB VesselDataManager]: Vessel RESTORE", Utils.LogType.VesselData);
if (!HighLogic.LoadedSceneIsEditor) { return; }
InitializeEditorConstruct(EditorLogic.fetch.ship, true);
}
public void onEditorVesselLoad(ShipConstruct ship, KSP.UI.Screens.CraftBrowserDialog.LoadType type)
{
Utils.Log("[RadioactivitySimulator][Editor]: Vessel LOAD", Utils.LogType.VesselData);
Utils.Log("[VAB VesselDataManager][Editor]: Vessel LOAD", Utils.LogType.VesselData);
if (!HighLogic.LoadedSceneIsEditor) { return; }
InitializeEditorConstruct(ship, true);
}
public void onEditorVesselPartRemoved(GameEvents.HostTargetAction<Part, Part> p)
{
Utils.Log("[VAB VesselDataManager][Editor]: Vessel PART REMOVE", Utils.LogType.VesselData);
Utils.Log("[VAB VesselDataManager][Editor]: Vessel PART REMOVED", Utils.LogType.VesselData);
if (!HighLogic.LoadedSceneIsEditor) { return; }

if (electricalData == null || heatData == null)
if (electricalData == null)
InitializeEditorConstruct(EditorLogic.fetch.ship, false);
else
RemovePart(p.target);
Expand Down
8 changes: 0 additions & 8 deletions Source/DynamicBatteryStorage/Data/VesselDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public class VesselDataManager : VesselModule
#region Accessors

public VesselElectricalData ElectricalData { get { return electricalData; } }
public VesselThermalData HeatData { get { return heatData; } }

public bool Ready { get { return dataReady; } }

#endregion
Expand All @@ -22,7 +20,6 @@ public class VesselDataManager : VesselModule
bool vesselLoaded = false;

VesselElectricalData electricalData;
VesselThermalData heatData;
#endregion

protected override void OnStart()
Expand Down Expand Up @@ -89,13 +86,8 @@ protected void RefreshVesselData()
return;

electricalData = new VesselElectricalData(vessel.Parts);
heatData = new VesselThermalData(vessel.Parts);

dataReady = true;

Utils.Log(String.Format("Dumping electrical database: \n{0}", electricalData.ToString()), Utils.LogType.VesselData);
Utils.Log(String.Format("Dumping thermal database: \n{0}", heatData.ToString()), Utils.LogType.VesselData);

}
}
}
63 changes: 0 additions & 63 deletions Source/DynamicBatteryStorage/Data/VesselThermalData.cs

This file was deleted.

33 changes: 23 additions & 10 deletions Source/DynamicBatteryStorage/DynamicBatteryStorage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,34 @@
<Compile Include="Data\VesselData.cs" />
<Compile Include="Data\VesselDataManager.cs" />
<Compile Include="Data\VesselElectricalData.cs" />
<Compile Include="Data\VesselThermalData.cs" />
<Compile Include="DynamicBatteryStorage.cs" />
<Compile Include="FormatUtils.cs" />
<Compile Include="HandlerConfiguration.cs" />
<Compile Include="HandlerModuleData.cs" />
<Compile Include="Handlers\GenericFieldDataHandler.cs" />
<Compile Include="Handlers\Heat\NFTHeatHandlers.cs" />
<Compile Include="Handlers\Heat\StockHeatHandlers.cs" />
<Compile Include="Handlers\ModuleDataHandler.cs" />
<Compile Include="Handlers\Power\KopernicusPowerHandlers.cs" />
<Compile Include="Handlers\Power\NFTPowerHandlers.cs" />
<Compile Include="Handlers\Power\RealBatteryPowerHandlers.cs" />
<Compile Include="Handlers\Power\RemoteTechPowerHandler.cs" />
<Compile Include="Handlers\Power\ScanSatPowerHandler.cs" />
<Compile Include="Handlers\Power\StockPowerHandlers.cs" />
<Compile Include="Handlers\KopernicusPowerHandlers.cs" />
<Compile Include="Handlers\PostKerbin\DischargeCapacitorPowerHandler.cs" />
<Compile Include="Handlers\PostKerbin\FissionGeneratorPowerHandler.cs" />
<Compile Include="Handlers\PostKerbin\ModuleChargeableEnginePowerHandler.cs" />
<Compile Include="Handlers\PostKerbin\ModuleCryoTankPowerHandler.cs" />
<Compile Include="Handlers\PostKerbin\ModuleCurvedSolarPanelPowerHandler.cs" />
<Compile Include="Handlers\PostKerbin\ModuleDeployableCentrifugePowerHandler.cs" />
<Compile Include="Handlers\RealBatteryPowerHandlers.cs" />
<Compile Include="Handlers\RemoteTechPowerHandler.cs" />
<Compile Include="Handlers\ScanSatPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleActiveRadiatorPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleAlternatorPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleCommandPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleDataTransmitterPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleDeployableSolarPanelPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleEnginesPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleGeneratorPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleLightPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleResourceConverterPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleResourceHarvesterPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleScienceConverterPowerHandler.cs" />
<Compile Include="Handlers\Stock\ModuleScienceLabPowerHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
<Compile Include="UI\SystemsMonitorUI.cs" />
Expand All @@ -108,7 +121,7 @@
<Compile Include="UI\ToolbarSituation.cs" />
<Compile Include="UI\Tooltips.cs" />
<Compile Include="Utils.cs" />
<Compile Include="Handlers\Power\WDSPPowerHandlers.cs" />
<Compile Include="Handlers\WDSPPowerHandlers.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
Expand Down
Loading

0 comments on commit cd02bd9

Please sign in to comment.