Skip to content
Merged
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
57 changes: 31 additions & 26 deletions MechJeb2/ComputerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class ComputerModule : IComparable<ComputerModule>

[UsedImplicitly]
[Persistent(pass = (int)Pass.LOCAL)]
public readonly string UnlockParts = "";
public string unlockParts = "";

[UsedImplicitly]
[Persistent(pass = (int)Pass.LOCAL)]
public readonly string UnlockTechs = "";
public string unlockTechs = "";

public bool UnlockChecked;

Expand Down Expand Up @@ -190,47 +190,52 @@ public virtual void UnlockCheck()
{
if (UnlockChecked) return;

// Bypass check for Sandbox mode
if (HighLogic.CurrentGame != null && HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX)
{
UnlockChecked = true;
return;
}

if (ResearchAndDevelopment.Instance == null) return;

bool unlock = true;

if (ResearchAndDevelopment.Instance != null)
string[] parts = unlockParts.Split(new[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length > 0)
{
string[] parts = UnlockParts.Split(new[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length > 0)
unlock = false;
foreach (string p in parts)
{
unlock = false;
foreach (string p in parts)
if (PartLoader.LoadedPartsList.Count(a => a.name == p) > 0 &&
ResearchAndDevelopment.PartModelPurchased(PartLoader.LoadedPartsList.First(a => a.name == p)))
{
if (PartLoader.LoadedPartsList.Count(a => a.name == p) > 0 &&
ResearchAndDevelopment.PartModelPurchased(PartLoader.LoadedPartsList.First(a => a.name == p)))
{
unlock = true;
break;
}
unlock = true;
break;
}
}
}

string[] techs = UnlockTechs.Split(new[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (techs.Length > 0)
string[] techs = unlockTechs.Split(new[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (techs.Length > 0)
{
if (parts.Length == 0)
{
if (parts.Length == 0)
{
unlock = false;
}
unlock = false;
}

foreach (string t in techs)
foreach (string t in techs)
{
if (ResearchAndDevelopment.GetTechnologyState(t) == RDTech.State.Available)
{
if (ResearchAndDevelopment.GetTechnologyState(t) == RDTech.State.Available)
{
unlock = true;
break;
}
unlock = true;
break;
}
}
}

unlock = unlock && IsSpaceCenterUpgradeUnlocked();

UnlockChecked = true;
if (!unlock)
{
Enabled = false;
Expand Down
2 changes: 1 addition & 1 deletion MechJeb2/DisplayModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public override void UnlockCheck()
bool prevEn = Enabled;
Enabled = true;
base.UnlockCheck();
if (UnlockParts.Trim().Length > 0 || UnlockTechs.Trim().Length > 0 || !IsSpaceCenterUpgradeUnlocked())
if (unlockParts.Trim().Length > 0 || unlockTechs.Trim().Length > 0 || !IsSpaceCenterUpgradeUnlocked())
{
Hidden = !Enabled;
if (Hidden)
Expand Down
2 changes: 1 addition & 1 deletion Parts/MechJeb2_AR202/part.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ PART {
MechJebModuleThrustWindow { unlockTechs = advFlightControl }
MechJebModuleRCSBalancerWindow { unlockTechs = advFlightControl }
MechJebModuleRoverWindow { unlockTechs = fieldScience }
MechJebModuleAscentGuidance { unlockTechs = unmannedTech }
MechJebModuleAscentMenu { unlockTechs = unmannedTech }
MechJebModuleLandingGuidance { unlockTechs = unmannedTech }
MechJebModuleSpaceplaneGuidance { unlockTechs = unmannedTech }
MechJebModuleDockingGuidance { unlockTechs = advUnmanned }
Expand Down