コード例 #1
0
 void update_state()
 {
     try
     {
         //get asteroid hatch
         var hatch = entrance.ConnectedPartWithModule <SingleUseGrappleNode>();
         grapple_node = hatch.Modules.GetModule <SingleUseGrappleNode>();
         storage      = hatch.Modules.GetModule <HangarStorageDynamic>();
         if (grapple_node == null || storage == null)
         {
             throw new Exception();
         }
         //get asteroid
         asteroid      = hatch.GetModuleInAttachedPart <ModuleAsteroid>();
         asteroid_info = asteroid.part.Modules.GetModule <ModuleAsteroidInfo>();
         EnableModule();
     }
     catch
     {
         asteroid      = null;
         asteroid_info = null;
         grapple_node  = null;
         storage       = null;
         DisableModule();
     }
     IsActivated &= can_convert();
 }
コード例 #2
0
 void update_state()
 {
     try
     {
         //get asteroid hatch
         var hatch = entrance.ConnectedPartWithModule<SingleUseGrappleNode>();
         grapple_node = hatch.GetModule<SingleUseGrappleNode>();
         storage = hatch.GetModule<HangarStorageDynamic>();
         if(grapple_node == null || storage == null) throw new Exception();
         //get asteroid
         asteroid = hatch.AttachedPartWithModule<ModuleAsteroid>();
         asteroid_info = asteroid.GetModule<AsteroidInfo>();
         if(!asteroid_info.AsteroidIsUsable)
         {
             ScreenMessager.showMessage(6, "This asteroid is used by Asteroid Recycling machinery.\n" +
                 "Mining it is prohibited for safety reasons.");
             throw new Exception();
         }
     }
     catch
     {
         asteroid = null;
         asteroid_info = null;
         grapple_node = null;
         storage = null;
         dM_buffer = 0;
         if(pump != null)
             pump.Clear();
     }
     Converting &= can_convert();
     update_events();
 }