Exemple #1
0
 // Fetch input/output resources list from reactor ConfigNode
 protected void ParseResourcesList(Part part)
 {
     if (!resourcesListParsed)
     {
         ConfigNode node = ModuleUtils.GetModuleConfigNode(part, engineModuleName);
         if (node != null)
         {
             // Load resource nodes
             ConfigNode[] inNodes = node.GetNodes("INPUT_RESOURCE");
             inputs = new List <ResourceRatio>();
             for (int i = 0; i < inNodes.Length; i++)
             {
                 ResourceRatio p = new ResourceRatio();
                 p.Load(inNodes[i]);
                 inputs.Add(p);
             }
             ConfigNode[] outNodes = node.GetNodes("OUTPUT_RESOURCE");
             outputs = new List <ResourceRatio>();
             for (int i = 0; i < outNodes.Length; i++)
             {
                 ResourceRatio p = new ResourceRatio();
                 p.Load(outNodes[i]);
                 outputs.Add(p);
             }
         }
         resourcesListParsed = true;
     }
 }
Exemple #2
0
 public virtual void Start()
 {
     if (Lib.IsFlight() || Lib.IsEditor())
     {
         if (engineModule == null)
         {
             engineModule = FindEngineModule(part, engineModuleID);
         }
         if (Features.Radiation && emitter == null)
         {
             emitter = FindEmitterModule(part);
         }
         if (FirstLoad)
         {
             if (emitter != null)
             {
                 EmitterMaxRadiation = emitter.radiation;
                 if (EmitterMaxRadiation < 0)
                 {
                     EmitterMaxRadiation = 0d;
                 }
             }
             if (engineModule != null)
             {
                 MaxECGeneration      = engineModule.ElectricalGeneration.Evaluate(100f);
                 MinThrottle          = engineModule.MinimumThrottle / 100f;
                 GeneratesElectricity = engineModule.GeneratesElectricity;
                 LastReactorState     = engineModule.Enabled;
             }
             if (inputs == null || inputs.Count == 0)
             {
                 ConfigNode node = ModuleUtils.GetModuleConfigNode(part, moduleName);
                 if (node != null)
                 {
                     OnLoad(node);
                 }
             }
             FirstLoad = false;
         }
         else
         {
             EmitterRunning = true;
         }
     }
 }