Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Feb 4, 2024
2 parents b81b4e3 + 21b6be4 commit 776c9f3
Show file tree
Hide file tree
Showing 11 changed files with 332 additions and 43 deletions.
33 changes: 33 additions & 0 deletions CachedEngineState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace TestFlight
{
public class CachedEngineState : IConfigNode
{
[Persistent] public bool allowShutdown;
[Persistent] public bool allowRestart;
[Persistent] public int numIgnitions;

public CachedEngineState() { }

public CachedEngineState(ConfigNode node)
{
Load(node);
}

public CachedEngineState(EngineModuleWrapper engine)
{
allowShutdown = engine.allowShutdown;
allowRestart = engine.allowRestart;
numIgnitions = engine.GetIgnitionCount();
}

public void Load(ConfigNode node)
{
ConfigNode.LoadObjectFromConfig(this, node);
}

public void Save(ConfigNode node)
{
ConfigNode.CreateConfigFromObject(this, node);
}
}
}
1 change: 1 addition & 0 deletions TestFlight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CachedEngineState.cs" />
<Compile Include="EngineRunData.cs" />
<Compile Include="Failure Bases\TestFlightFailureBase_Avionics.cs" />
<Compile Include="Failure Bases\TestFlightFailureBase_Docking.cs" />
Expand Down
26 changes: 25 additions & 1 deletion TestFlightAPI/TestFlightAPI/EngineModuleWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;

using KSP.Localization;
using UnityEngine;

using TestFlightAPI;
Expand Down Expand Up @@ -107,6 +108,23 @@ public bool allowShutdown
}
}

public bool allowRestart
{
get
{
if (engineType == EngineModuleType.UNKNOWN)
return false;

return moduleEngine.allowRestart;
}
set
{
if (engineType == EngineModuleType.UNKNOWN)
return;
moduleEngine.allowRestart = value;
}
}

public bool throttleLocked
{
get
Expand Down Expand Up @@ -332,7 +350,7 @@ public void DisableRestart()
return;

// Need to disable this to prevent other mods from restarting the engine.
moduleEngine.allowRestart = false;
allowRestart = false;

// For some reason, need to disable GUI as well
Events["Activate"].active = false;
Expand All @@ -341,6 +359,12 @@ public void DisableRestart()
Events["Shutdown"].guiActive = false;
}

public void ResetStatus()
{
Status = Localizer.Format("#autoLOC_219034");
StatusL2 = string.Empty;
}

// Reduce fuel flow
public void SetFuelFlowMult(float multiplier)
{
Expand Down
10 changes: 9 additions & 1 deletion TestFlightAPI/TestFlightAPI/TestFlightAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,13 @@ string Configuration
/// </summary>
/// <returns>The current burn time for scope or 0 if this module does not track burn time.</returns>
float GetScopedRunTime(RatingScope ratingScope);


/// <summary>
/// Sets the current burn time for the given scope.
/// Does nothing if this module does not track burn time.
/// </summary>
void SetScopedRunTime(RatingScope ratingScope, float time);

/// <summary>
/// Should return a string if the module wants to report any information to the user in the TestFlight Editor window.
/// </summary>
Expand Down Expand Up @@ -959,6 +965,8 @@ bool DebugEnabled

float GetRunTime(RatingScope ratingScope);

void ResetRunTime();

/// <summary>
/// Called whenever an Interop value is added, changed, or removed to allow the modules on the part to update to the proper config
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions TestFlightAPI/TestFlightAPI/TestFlightReliability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ public virtual float GetScopedRunTime(RatingScope ratingScope)
{
return 0f;
}

public virtual void SetScopedRunTime(RatingScope ratingScope, float time)
{
}
}
}

Loading

0 comments on commit 776c9f3

Please sign in to comment.