Beispiel #1
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("COMPRESSOR"))
     {
         CompressorConfig = node.GetNode("COMPRESSOR");
         //for part info only
         compressor = new GasCompressor(part);
         compressor.Load(CompressorConfig);
     }
     if (!node.HasValue("SavedState"))
     {
         State = PackedByDefault? AnimatorState.Closed : AnimatorState.Opened;
     }
 }
 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;
 }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if(node.HasNode("COMPRESSOR"))
     {
         CompressorConfig = node.GetNode("COMPRESSOR");
         //for part info only
         compressor = new GasCompressor(part);
         compressor.Load(CompressorConfig);
     }
     if(!node.HasValue("SavedState"))
         State = PackedByDefault? AnimatorState.Closed : AnimatorState.Opened;
 }
Beispiel #4
0
 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;
 }
 bool init_compressor()
 {
     Compressor = null;
     if(ModuleConfig.HasNode(GasCompressor.NODE_NAME))
     {
         Compressor = new GasCompressor(part);
         Compressor.Load(ModuleConfig.GetNode(GasCompressor.NODE_NAME));
         return true;
     }
     return false;
 }