Exemplo n.º 1
0
        public void Start()
        {
            IEnumerable <AvailablePart> pl = PartLoader.LoadedPartsList.Where(part => part.partPrefab.Modules != null && part.partPrefab.Modules.Contains <ModuleBdbBoiloff>());

            foreach (AvailablePart p in pl)
            {
                for (int i = 0; i < p.moduleInfos.Count; i++)
                {
                    AvailablePart.ModuleInfo mi = p.moduleInfos[i];
                    if (mi.moduleName == "Bdb Boiloff")
                    {
                        string           s  = "";
                        ModuleBdbBoiloff pm = p.partPrefab.GetComponent <ModuleBdbBoiloff>();
                        if (pm != null)
                        {
                            s = pm.GetInfoEditor();
                        }

                        if (s != "")
                        {
                            mi.info = s;
                        }
                        else
                        {
                            p.moduleInfos.Remove(mi);
                        }

                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public override void OnLoad(ConfigNode node)
 {
     if (part.partInfo == null || part.partInfo.partPrefab == null)
     {
         cryoResources.Clear();
         ConfigNode[] cryoResourceNodes = node.GetNodes(CryoResourceItem.itemName);
         //Debug.Log("[ModuleBdbBoiloff] Found " + cryoResourceNodes.Count() + " " + CryoResourceItem.itemName + " nodes");
         foreach (ConfigNode cryoResourceNode in cryoResourceNodes)
         {
             CryoResourceItem newItem = new CryoResourceItem(cryoResourceNode);
             Debug.Log("[ModuleBdbBoiloff] Adding " + newItem.name + ", " + newItem.boiloffRate);
             if (PartResourceLibrary.Instance.GetDefinition(newItem.name) != null)
             {
                 cryoResources.Add(newItem);
             }
             else
             {
                 Debug.Log("[ModuleBdbBoiloff] Resource " + newItem.name + " not found");
             }
         }
     }
     else
     {
         if (part.partInfo.partPrefab.Modules.Contains("ModuleBdbBoiloff"))
         {
             ModuleBdbBoiloff prefab = (ModuleBdbBoiloff)part.partInfo.partPrefab.Modules["ModuleBdbBoiloff"];
             //Debug.Log("[ModuleBdbBoiloff] Loading " + prefab.cryoResources.Count() + " resources from prefab part.");
             foreach (CryoResourceItem item in prefab.cryoResources)
             {
                 CryoResourceItem newItem = new CryoResourceItem(item);
                 cryoResources.Add(newItem);
             }
         }
         else
         {
             Debug.Log("[ModuleBdbBoiloff] ModuleCryoResource not found on prefab part.");
         }
     }
 }