Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if BDArmory is installed before trying to find its partmodule #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FerramAerospaceResearch/FARAeroComponents/FARVesselAero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ private int VoxelCountFromType()
public override void OnLoadVessel()
{
if (vessel.loaded)
if (vessel.rootPart.Modules.Contains("MissileLauncher") && vessel.parts.Count == 1)
if (ModUtils.IsBDArmoryInstalled && vessel.rootPart.Modules.Contains("MissileLauncher") &&
vessel.parts.Count == 1)
{
vessel.rootPart.dragModel = Part.DragModel.CUBE;
enabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ private static void UpdateThermodynamicsPre(ModularFlightIntegrator fi)
private static void UpdateAerodynamics(ModularFlightIntegrator fi, Part part)
{
//FIXME Proper model for airbrakes
if (part.Modules.Contains<ModuleAeroSurface>() ||
part.Modules.Contains("MissileLauncher") && part.vessel.rootPart == part)
if (part.vessel.rootPart == part &&
part.Modules.Contains<ModuleAeroSurface>() ||
ModUtils.IsBDArmoryInstalled && part.Modules.Contains("MissileLauncher"))
{
fi.BaseFIUpdateAerodynamics(part);
}
Expand Down
5 changes: 1 addition & 4 deletions FerramAerospaceResearch/FARAeroUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,7 @@ public static void LoadAeroDataFromConfig()
if (loaded)
return;

foreach (AssemblyLoader.LoadedAssembly assembly in AssemblyLoader.loadedAssemblies)
if (assembly.assembly.GetName().Name == "AJE")
AJELoaded = true;

AJELoaded = ModUtils.IsAJEInstalled;
SetDefaultValuesIfNoValuesLoaded();

loaded = true;
Expand Down
1 change: 1 addition & 0 deletions FerramAerospaceResearch/FerramAerospaceResearch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
<Compile Include="Utils\GameDatabaseTextureLoader.cs" />
<Compile Include="Utils\KSPUtils.cs" />
<Compile Include="Utils\ModuleControlSurfaceUpgradeFix.cs" />
<Compile Include="Utils\ModUtils.cs" />
<Compile Include="Utils\Serialization.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
41 changes: 41 additions & 0 deletions FerramAerospaceResearch/Utils/ModUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Linq;

namespace FerramAerospaceResearch
{
public static class ModUtils
{
private static bool ajeInstalled = false;
private static bool needFindAJE = true;
private static bool bdArmoryInstalled = false;
private static bool needFindBDArmory = true;

public static bool IsAJEInstalled
{
get
{
if (needFindAJE)
{
needFindAJE = false;
ajeInstalled = AssemblyLoader.loadedAssemblies.Any(a => a.name.Equals("AJE", StringComparison.OrdinalIgnoreCase));
}

return ajeInstalled;
}
}

public static bool IsBDArmoryInstalled
{
get
{
if (needFindBDArmory)
{
needFindBDArmory = false;
bdArmoryInstalled = AssemblyLoader.loadedAssemblies.Any(a => a.name.Equals("BDArmory", StringComparison.OrdinalIgnoreCase));
}

return bdArmoryInstalled;
}
}
}
}