@@ -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 ;
0 commit comments