IEnumerator<YieldInstruction> FirstTimeUpdateNodes()
 {
     for(int i = 0; i < skip_fixed_frames; i++)
     {
         yield return new WaitForFixedUpdate();
         UpdatePart();
     }
     if(State == AnimatorState.Opened) EnableModules(true);
     if(gui_state == null) gui_state = this.SaveGUIState();
     this.ActivateGUI(gui_state);
 }
Exemple #2
0
 public void Enable(bool enable)
 {
     if(enable)
     {
         if(gui_state == null) gui_state = this.SaveGUIState();
         this.ActivateGUI(gui_state);
         Setup();
         enabled = true;
     }
     else
     {
         gui_state = this.DeactivateGUI();
         enabled = false;
     }
 }
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     if(state == StartState.None) return;
     //get controlled modules
     foreach(string module_name in ControlledModules.Split(' '))
     {
         if(!part.Modules.Contains(module_name))
         {
             Utils.Log("HangarGenericInflatable.OnStart: {0} does not contain {1} module.", part.name, module_name);
             continue;
         }
         List<IControllableModule> modules = new List<IControllableModule>();
         foreach(PartModule pm in part.Modules)
         {
             if(pm.moduleName == module_name)
             {
                 var controllableModule = pm as IControllableModule;
                 if(controllableModule != null)
                 {
                     modules.Add(controllableModule);
                     if(State != AnimatorState.Opened)
                         controllableModule.Enable(false);
                 }
                 else Utils.Log("HangarGenericInflatable.OnStart: {0} is not a ControllableModule. Skipping it.", pm.moduleName);
             }
         }
         controlled_modules.AddRange(modules);
     }
     //get animated nodes
     foreach(string node_name in AnimatedNodes.Split(' '))
     {
         Transform node_transform = part.FindModelTransform(node_name);
         if(node_transform == null)
         {
             Utils.Log("HangarGenericInflatable.OnStart: no transform '{0}' in {1}", node_name, part.name);
             continue;
         }
         AttachNode node = part.findAttachNode(node_name);
         if(node == null) node = part.srfAttachNode.id == node_name? part.srfAttachNode : null;
         if(node == null)
         {
             Utils.Log("HangarGenericInflatable.OnStart: no node '{0}' in {1}", node_name, part.name);
             continue;
         }
         var a_node = new AnimatedNode(node, node_transform, part);
         animated_nodes.Add(a_node);
     }
     //calculate prefab metric
     prefab = part.partInfo.partPrefab;
     prefab_metric = new Metric(prefab);
     //get compressed gas for the first time
     if(CompressedGas < 0) CompressedGas = InflatableVolume;
     //load compressor
     if(CompressorConfig != null)
     {
         compressor = new GasCompressor(part);
         compressor.Load(CompressorConfig);
     }
     //forbid surface attachment for the inflatable
     part.attachRules.allowSrfAttach = false;
     UpdatePart();
     //update GUI and set the flag
     ToggleEvents();
     StartCoroutine(UpdateStatus());
     gui_state = this.DeactivateGUI();
     just_loaded = true;
 }