Skip to content

Commit

Permalink
1.3 recompile
Browse files Browse the repository at this point in the history
  • Loading branch information
gomker committed May 28, 2017
1 parent e006834 commit edd1c07
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 122 deletions.
Binary file modified Distribution/GameData/HullBreach/Plugins/HullBreach.dll
Binary file not shown.
10 changes: 10 additions & 0 deletions Distribution/GameData/HullBreach/settings.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
HullBreachSettings
{
CrushDepth = 20
flowRate = 0.5
critFlowRate = 0.90000000000000002
breachTemp = 0.59999999999999998
critBreachTemp = 0.90000000000000002
ecDrain = True
isHullBreachEnabled = False
}
26 changes: 9 additions & 17 deletions HullBreach.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,22 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Games\KSP\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
<Reference Include="Assembly-CSharp">
<HintPath>..\KSP\1.3\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Games\KSP\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\KSP\1.3\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Games\KSP\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
<Reference Include="UnityEngine">
<HintPath>..\KSP\1.3\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Games\KSP\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
<Reference Include="UnityEngine.UI">
<HintPath>..\KSP\1.3\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PreSettings.cs" />
<Compile Include="HullBreachConfig.cs" />
<Compile Include="Gui.cs" />
<Compile Include="HullBreachToolBar.cs" />
<Compile Include="ModuleHullBreach.cs" />
Expand Down
84 changes: 84 additions & 0 deletions HullBreachConfig.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}

}
}

10 changes: 6 additions & 4 deletions HullBreachToolBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
2 changes: 1 addition & 1 deletion LocalDev/ksp_dir.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:\Games\KSP_Debug
S:\Games\KSP_1.3_Debug
38 changes: 19 additions & 19 deletions ModuleHullBreach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,6 +82,8 @@ public override void OnStart(StartState state)
{
part.force_activate();
instance = this;
if(part.FindModulesImplementing<ModuleHullBreach>().Count !=0)
config.Instance.vesselHullBreach = this;
}

//if (state != StartState.Editor & vessel != null & partDebug == false)
Expand Down Expand Up @@ -126,10 +119,14 @@ public void CheckCatastrophicBreach(PartJoint partJoint, float breakForce)

public void FixedUpdate()
{
//if (vessel == null || !vessel.FindPartModuleImplementing<ModuleHullBreach>())
//{
// return;
//}
try
{
if (vessel == null || !vessel.FindPartModuleImplementing<ModuleHullBreach>())
return;
}
catch (Exception e)
{ }

part.rigidAttachment = true;

if (vessel.situation != Vessel.Situations.SPLASHED) return;
Expand Down Expand Up @@ -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
Expand All @@ -188,11 +185,14 @@ public void FixedUpdate()

public void LateUpdate()
{
//if (vessel == null || !vessel.FindPartModuleImplementing<ModuleHullBreach>())
//{
// return;
//}

try
{
if (vessel == null || !vessel.FindPartModuleImplementing<ModuleHullBreach>())
return;
}
catch (Exception e)
{ }

//vesselSituation = vessel.situation.ToString();
//currentAlt = Math.Round(TrueAlt(),2);
pctHeat = Math.Round((part.temperature/part.maxTemp)*100);
Expand Down
79 changes: 0 additions & 79 deletions PreSettings.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit edd1c07

Please sign in to comment.