Skip to content

Commit 118652b

Browse files
Merge pull request #2096 from rakkasumi/dev
2 parents c703e2f + 206d7ff commit 118652b

3 files changed

Lines changed: 33 additions & 28 deletions

File tree

MechJeb2/ComputerModule.cs

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public class ComputerModule : IComparable<ComputerModule>
2929

3030
[UsedImplicitly]
3131
[Persistent(pass = (int)Pass.LOCAL)]
32-
public readonly string UnlockParts = "";
32+
public string unlockParts = "";
3333

3434
[UsedImplicitly]
3535
[Persistent(pass = (int)Pass.LOCAL)]
36-
public readonly string UnlockTechs = "";
36+
public string unlockTechs = "";
3737

3838
public bool UnlockChecked;
3939

@@ -190,47 +190,52 @@ public virtual void UnlockCheck()
190190
{
191191
if (UnlockChecked) return;
192192

193+
// Bypass check for Sandbox mode
194+
if (HighLogic.CurrentGame != null && HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX)
195+
{
196+
UnlockChecked = true;
197+
return;
198+
}
199+
200+
if (ResearchAndDevelopment.Instance == null) return;
201+
193202
bool unlock = true;
194203

195-
if (ResearchAndDevelopment.Instance != null)
204+
string[] parts = unlockParts.Split(new[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
205+
if (parts.Length > 0)
196206
{
197-
string[] parts = UnlockParts.Split(new[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
198-
if (parts.Length > 0)
207+
unlock = false;
208+
foreach (string p in parts)
199209
{
200-
unlock = false;
201-
foreach (string p in parts)
210+
if (PartLoader.LoadedPartsList.Count(a => a.name == p) > 0 &&
211+
ResearchAndDevelopment.PartModelPurchased(PartLoader.LoadedPartsList.First(a => a.name == p)))
202212
{
203-
if (PartLoader.LoadedPartsList.Count(a => a.name == p) > 0 &&
204-
ResearchAndDevelopment.PartModelPurchased(PartLoader.LoadedPartsList.First(a => a.name == p)))
205-
{
206-
unlock = true;
207-
break;
208-
}
213+
unlock = true;
214+
break;
209215
}
210216
}
217+
}
211218

212-
string[] techs = UnlockTechs.Split(new[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
213-
if (techs.Length > 0)
219+
string[] techs = unlockTechs.Split(new[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
220+
if (techs.Length > 0)
221+
{
222+
if (parts.Length == 0)
214223
{
215-
if (parts.Length == 0)
216-
{
217-
unlock = false;
218-
}
224+
unlock = false;
225+
}
219226

220-
foreach (string t in techs)
227+
foreach (string t in techs)
228+
{
229+
if (ResearchAndDevelopment.GetTechnologyState(t) == RDTech.State.Available)
221230
{
222-
if (ResearchAndDevelopment.GetTechnologyState(t) == RDTech.State.Available)
223-
{
224-
unlock = true;
225-
break;
226-
}
231+
unlock = true;
232+
break;
227233
}
228234
}
229235
}
230236

231237
unlock = unlock && IsSpaceCenterUpgradeUnlocked();
232238

233-
UnlockChecked = true;
234239
if (!unlock)
235240
{
236241
Enabled = false;

MechJeb2/DisplayModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public override void UnlockCheck()
295295
bool prevEn = Enabled;
296296
Enabled = true;
297297
base.UnlockCheck();
298-
if (UnlockParts.Trim().Length > 0 || UnlockTechs.Trim().Length > 0 || !IsSpaceCenterUpgradeUnlocked())
298+
if (unlockParts.Trim().Length > 0 || unlockTechs.Trim().Length > 0 || !IsSpaceCenterUpgradeUnlocked())
299299
{
300300
Hidden = !Enabled;
301301
if (Hidden)

Parts/MechJeb2_AR202/part.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ PART {
7070
MechJebModuleThrustWindow { unlockTechs = advFlightControl }
7171
MechJebModuleRCSBalancerWindow { unlockTechs = advFlightControl }
7272
MechJebModuleRoverWindow { unlockTechs = fieldScience }
73-
MechJebModuleAscentGuidance { unlockTechs = unmannedTech }
73+
MechJebModuleAscentMenu { unlockTechs = unmannedTech }
7474
MechJebModuleLandingGuidance { unlockTechs = unmannedTech }
7575
MechJebModuleSpaceplaneGuidance { unlockTechs = unmannedTech }
7676
MechJebModuleDockingGuidance { unlockTechs = advUnmanned }

0 commit comments

Comments
 (0)