diff --git a/Distribution/GameData/HullBreach/Plugins/HullBreach.dll b/Distribution/GameData/HullBreach/Plugins/HullBreach.dll
index fb0074a..8e7de62 100644
Binary files a/Distribution/GameData/HullBreach/Plugins/HullBreach.dll and b/Distribution/GameData/HullBreach/Plugins/HullBreach.dll differ
diff --git a/Distribution/GameData/HullBreach/settings.cfg b/Distribution/GameData/HullBreach/settings.cfg
new file mode 100644
index 0000000..67560a3
--- /dev/null
+++ b/Distribution/GameData/HullBreach/settings.cfg
@@ -0,0 +1,10 @@
+HullBreachSettings
+{
+ CrushDepth = 20
+ flowRate = 0.5
+ critFlowRate = 0.90000000000000002
+ breachTemp = 0.59999999999999998
+ critBreachTemp = 0.90000000000000002
+ ecDrain = True
+ isHullBreachEnabled = False
+}
diff --git a/HullBreach.csproj b/HullBreach.csproj
index c63b8c7..221842c 100644
--- a/HullBreach.csproj
+++ b/HullBreach.csproj
@@ -30,30 +30,22 @@
4
-
- False
- ..\..\..\..\..\..\Games\KSP\KSP_x64_Data\Managed\Assembly-CSharp.dll
- False
+
+ ..\KSP\1.3\Assembly-CSharp.dll
-
- False
- ..\..\..\..\..\..\Games\KSP\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll
- False
+
+ ..\KSP\1.3\Assembly-CSharp-firstpass.dll
-
- False
- ..\..\..\..\..\..\Games\KSP\KSP_x64_Data\Managed\UnityEngine.dll
- False
+
+ ..\KSP\1.3\UnityEngine.dll
-
- False
- ..\..\..\..\..\..\Games\KSP\KSP_x64_Data\Managed\UnityEngine.UI.dll
- False
+
+ ..\KSP\1.3\UnityEngine.UI.dll
-
+
diff --git a/HullBreachConfig.cs b/HullBreachConfig.cs
new file mode 100644
index 0000000..bd6cfc1
--- /dev/null
+++ b/HullBreachConfig.cs
@@ -0,0 +1,84 @@
+using System;
+using KSP.UI.Screens;
+using UnityEngine;
+
+namespace HullBreach
+{
+ [KSPAddon(KSPAddon.Startup.EveryScene, false)]
+ public class config : MonoBehaviour
+ {
+
+ public static string SettingsConfigUrl = "GameData/HullBreach/settings.cfg";
+
+ public static double flowRate { get; set; }
+ public static double critFlowRate { get; set; }
+ public static double breachTemp { get; set; }
+ public static double critBreachTemp { get; set; }
+
+ public static bool ecDrain { get; set; }
+ public static bool isHullBreachEnabled { get; set; }
+
+ public ModuleHullBreach vesselHullBreach = null;
+ public static config Instance;
+
+ void Awake()
+ {
+ LoadConfig();
+ Instance = this;
+ }
+
+ public static void LoadConfig()
+ {
+ try
+ {
+ Debug.Log("[HullBreach]: Loading settings.cfg ");
+
+ ConfigNode fileNode = ConfigNode.Load(SettingsConfigUrl);
+ if (!fileNode.HasNode("HullBreachSettings")) return;
+
+ ConfigNode settings = fileNode.GetNode("HullBreachSettings");
+
+ flowRate = double.Parse(settings.GetValue("flowRate"));
+ critFlowRate = double.Parse(settings.GetValue("critFlowRate"));
+ breachTemp = double.Parse(settings.GetValue("breachTemp"));
+ critBreachTemp = double.Parse(settings.GetValue("critBreachTemp"));
+
+ ecDrain = bool.Parse(settings.GetValue("ecDrain"));
+ isHullBreachEnabled = bool.Parse(settings.GetValue("isHullBreachEnabled"));
+
+ }
+ catch (Exception ex)
+ {
+ Debug.Log("[HullBreach]: Failed to load settings config:" + ex.Message);
+ }
+ }
+
+ public static void SaveConfig()
+ {
+ try
+ {
+ Debug.Log("[HullBreach]: Saving settings.cfg ==");
+ ConfigNode fileNode = ConfigNode.Load(SettingsConfigUrl);
+
+ if (!fileNode.HasNode("HullBreachSettings")) return;
+
+ ConfigNode settings = fileNode.GetNode("HullBreachSettings");
+
+ settings.SetValue("flowRate", flowRate);
+ settings.SetValue("critFlowRate", critBreachTemp);
+ settings.SetValue("breachTemp", breachTemp);
+ settings.SetValue("critBreachTemp", critBreachTemp);
+ settings.SetValue("ecDrain", ecDrain);
+ settings.SetValue("isHullBreachEnabled", isHullBreachEnabled);
+
+ fileNode.Save(SettingsConfigUrl);
+ }
+ catch (Exception ex)
+ {
+ Debug.Log("[HullBreach]: Failed to save settings config:" + ex.Message); throw;
+ }
+ }
+
+ }
+}
+
diff --git a/HullBreachToolBar.cs b/HullBreachToolBar.cs
index 875b4ae..469c4c6 100644
--- a/HullBreachToolBar.cs
+++ b/HullBreachToolBar.cs
@@ -55,21 +55,23 @@ void ToolbarWindow(int windowID)
if (!FlightGlobals.ActiveVessel) { return; }
- if (ModuleHullBreach.Instance)
+ if (config.Instance.vesselHullBreach != null)
{
- if (ModuleHullBreach.ecDrain)
+ if (config.ecDrain)
{
if (GUI.Button(LineRect(ref line, 1.5f), "EC Drain ON", HighLogic.Skin.button))
{
//ModuleHullBreach.Instance.ToggleHullBreach();
- ModuleHullBreach.ecDrain = false;
+ config.ecDrain = false;
+ config.SaveConfig();
}
}
else
{
if (GUI.Button(LineRect(ref line, 2), "EC Drain OFF", HighLogic.Skin.button))
{
- ModuleHullBreach.ecDrain = true;
+ config.ecDrain = true;
+ config.SaveConfig();
}
}
diff --git a/LocalDev/ksp_dir.txt b/LocalDev/ksp_dir.txt
index 4bb2f0f..9093325 100644
--- a/LocalDev/ksp_dir.txt
+++ b/LocalDev/ksp_dir.txt
@@ -1 +1 @@
-C:\Games\KSP_Debug
\ No newline at end of file
+S:\Games\KSP_1.3_Debug
\ No newline at end of file
diff --git a/ModuleHullBreach.cs b/ModuleHullBreach.cs
index d1c531d..429fbda 100644
--- a/ModuleHullBreach.cs
+++ b/ModuleHullBreach.cs
@@ -8,15 +8,6 @@ public class ModuleHullBreach : PartModule
static ModuleHullBreach instance;
public static ModuleHullBreach Instance => instance;
- public static bool _ecDrain = true;
-
- public static bool ecDrain
- {
- get { return _ecDrain; }
- set { _ecDrain = value; }
-
- }
-
#region KSP Fields
public bool isHullBreached;
@@ -91,6 +82,8 @@ public override void OnStart(StartState state)
{
part.force_activate();
instance = this;
+ if(part.FindModulesImplementing().Count !=0)
+ config.Instance.vesselHullBreach = this;
}
//if (state != StartState.Editor & vessel != null & partDebug == false)
@@ -126,10 +119,14 @@ public void CheckCatastrophicBreach(PartJoint partJoint, float breakForce)
public void FixedUpdate()
{
- //if (vessel == null || !vessel.FindPartModuleImplementing())
- //{
- // return;
- //}
+ try
+ {
+ if (vessel == null || !vessel.FindPartModuleImplementing())
+ return;
+ }
+ catch (Exception e)
+ { }
+
part.rigidAttachment = true;
if (vessel.situation != Vessel.Situations.SPLASHED) return;
@@ -165,7 +162,7 @@ public void FixedUpdate()
else if (crushable && part.submergedPortion == 1.00 && !part.localRoot.name.StartsWith("Sub"))
{
- if(_ecDrain)
+ if(config.ecDrain)
part.RequestResource("ElectricCharge", 1000); //kill EC if sumberged
if (crushable) part.buoyancy = -1.0f; // trying to kill floaty bits that never sink
@@ -188,11 +185,14 @@ public void FixedUpdate()
public void LateUpdate()
{
- //if (vessel == null || !vessel.FindPartModuleImplementing())
- //{
- // return;
- //}
-
+ try
+ {
+ if (vessel == null || !vessel.FindPartModuleImplementing())
+ return;
+ }
+ catch (Exception e)
+ { }
+
//vesselSituation = vessel.situation.ToString();
//currentAlt = Math.Round(TrueAlt(),2);
pctHeat = Math.Round((part.temperature/part.maxTemp)*100);
diff --git a/PreSettings.cs b/PreSettings.cs
deleted file mode 100644
index 9cd7f6d..0000000
--- a/PreSettings.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//using System;
-//using UnityEngine;
-
-//namespace HullBreach
-//{
-// [KSPAddon(KSPAddon.Startup.EveryScene, false)]
-// public class HullBreachSettings : MonoBehaviour
-// {
-// public static string SettingsConfigUrl = "GameData/HullBreach/settings.cfg";
-
-// public static double _flowRate { get; set; }
-// public static double _critFlowRate { get; set; }
-// public static double _breachTemp { get; set; }
-// public static double _critBreachTemp { get; set; }
-
-// public static bool _ecDrain { get; set; }
-// public static bool _isHullBreachEnabled { get; set; }
-
-
-// void Awake()
-// {
-// LoadConfig();
-// }
-
-// public static void LoadConfig()
-// {
-// try
-// {
-// Debug.Log("[HullBreach]: Loading settings.cfg ");
-
-// ConfigNode fileNode = ConfigNode.Load(SettingsConfigUrl);
-// if (!fileNode.HasNode("HullBreachSettings")) return;
-
-// ConfigNode settings = fileNode.GetNode("HullBreachSettings");
-
-// _flowRate = double.Parse(settings.GetValue("flowRate"));
-// _critFlowRate = double.Parse(settings.GetValue("critFlowRate"));
-// _breachTemp = double.Parse(settings.GetValue("breachTemp"));
-// _critBreachTemp = double.Parse(settings.GetValue("critBreachTemp"));
-
-// _ecDrain = bool.Parse(settings.GetValue("ecDrain"));
-// _isHullBreachEnabled = bool.Parse(settings.GetValue("isHullBreachEnabled"));
-
-// }
-// catch (Exception ex)
-// {
-// Debug.Log("[HullBreach]: Failed to load settings config:" + ex.Message);
-// }
-// }
-
-// public static void SaveConfig()
-// {
-// try
-// {
-// Debug.Log("[HullBreach]: Saving settings.cfg ==");
-// ConfigNode fileNode = ConfigNode.Load(SettingsConfigUrl);
-
-// if (!fileNode.HasNode("HullBreachSettings")) return;
-
-// ConfigNode settings = fileNode.GetNode("PreSettings");
-
-// settings.SetValue("flowRate", _flowRate);
-// settings.SetValue("critFlowRate", _critBreachTemp);
-// settings.SetValue("breachTemp", _breachTemp);
-// settings.SetValue("critBreachTemp", _critBreachTemp);
-// settings.SetValue("ecDrain", _flowRate, _ecDrain);
-// settings.SetValue("isHullBreachEnabled", _isHullBreachEnabled);
-
-// fileNode.Save(SettingsConfigUrl);
-// }
-// catch (Exception ex)
-// {
-// Debug.Log("[HullBreach]: Failed to save settings config:" + ex.Message); throw;
-// }
-// }
-
-
-// }
-//}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index c966157..c504311 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.1.5.6")]
-[assembly: AssemblyFileVersion("0.1.5.6")]
+[assembly: AssemblyVersion("0.1.6.0")]
+[assembly: AssemblyFileVersion("0.1.6.0")]