Esempio n. 1
0
 internal void installExperiment(ExperimentData exp)
 {
     if (equ != null)
     {
         equ.installExperiment(exp);
     }
 }
Esempio n. 2
0
        public static AvailablePart getPartForExperiment(string type, ExperimentData exp)
        {
            AvailablePart ap = null;

            string[] partsRegistry = null;

            switch (type)
            {
            case OMS_EXPERIMENTS:
                partsRegistry = omsRegistry;
                break;

            case KEMINI_EXPERIMENTS:
                partsRegistry = getKeminiRegister();
                break;
            }
            for (int idx = 0, count = partsRegistry.Length; idx < count; idx++)
            {
                ap = PartLoader.getPartInfoByName(partsRegistry[idx]);
                if (ap != null)
                {
                    NE_ExperimentModule e = ap.partPrefab.GetComponent <NE_ExperimentModule>();
                    if (e.type == exp.getType())
                    {
                        break;
                    }
                }
            }
            return(ap);
        }
        public static LabEquipment getLabEquipmentFromNode(ConfigNode node, Lab lab)
        {
            if (node.name != CONFIG_NODE_NAME)
            {
                NE_Helper.logError("getLabEquipmentFromNode: invalid Node: " + node.name);
                return(getNullObject());
            }

            string abb  = node.GetValue(ABB_VALUE);
            string name = node.GetValue(NAME_VALUE);
            float  mass = NE_Helper.GetValueAsFloat(node, MASS_VALUE);
            float  cost = NE_Helper.GetValueAsFloat(node, COST_VALUE);

            string product        = node.GetValue(PRODUCT_VALUE);
            float  productPerHour = NE_Helper.GetValueAsFloat(node, PRODUCT_PER_HOUR_VALUE);

            string reactant           = node.GetValue(REACTANT_VALUE);
            float  reactantPerProduct = NE_Helper.GetValueAsFloat(node, REACTANT_PER_PRODUCT_VALUE);

            EquipmentRacks type = EquipmentRacksFactory.getType(node.GetValue(TYPE_VALUE));

            LabEquipment eq = new LabEquipment(abb, name, type, mass, cost, productPerHour, product, reactantPerProduct, reactant);

            eq.lab = lab;
            ConfigNode expNode = node.GetNode(ExperimentData.CONFIG_NODE_NAME);

            if (expNode != null)
            {
                eq.loadExperiment(ExperimentData.getExperimentDataFromNode(expNode));
            }

            return(eq);
        }
Esempio n. 4
0
        public override void installExperiment(ExperimentData exp)
        {
            switch (exp.getEquipmentNeeded())
            {
            case EquipmentRacks.MSG:
                if (msgSlot.isEquipmentInstalled() && msgSlot.experimentSlotFree())
                {
                    msgSlot.installExperiment(exp);
                    msgStatus = exp.getAbbreviation();
                    Fields["msgStatus"].guiActive = true;
                }
                else
                {
                    NE_Helper.logError("installExperiment, installed: " + msgSlot.isEquipmentInstalled() + "; free: " + msgSlot.experimentSlotFree());
                }
                break;

            case EquipmentRacks.USU:
                if (usuSlot.isEquipmentInstalled() && usuSlot.experimentSlotFree())
                {
                    usuSlot.installExperiment(exp);
                    usuStatus = exp.getAbbreviation();
                    Fields["usuStatus"].guiActive = true;
                }
                else
                {
                    NE_Helper.logError("installExperiment, installed: " + usuSlot.isEquipmentInstalled() + "; free: " + usuSlot.experimentSlotFree());
                }
                break;
            }
        }
Esempio n. 5
0
        private void drawManifestGUI(int id)
        {
            GUILayout.BeginVertical();
            manifestScrollPos = GUILayout.BeginScrollView(manifestScrollPos, GUILayout.Width(width - 20), GUILayout.Height(getHeight(storageSlots.Count) - fixedHeight));
            string text = "";

            foreach (ExperimentStorage e in storageSlots)
            {
                text += "<b>" + e.identifier + "</b>\n";
                if (e.isEmpty())
                {
                    text += "\t empty\n";
                }
                else
                {
                    ExperimentData exp = e.getStoredExperimentData();
                    text += exp.getDescription("\t ") + "\n";
                    text += "\t State: " + exp.getStateString() + "\n";
                }
                text += "\n";
            }
            GUI.skin.label.wordWrap = true;
            GUILayout.Label(text, GUILayout.Height((slotHeight * storageSlots.Count) - 10));
            GUILayout.EndScrollView();
            if (GUILayout.Button("Close"))
            {
                showManifest = false;
            }
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Esempio n. 6
0
 protected ExperimentStep(ExperimentData exp, string type, string name, int index = 0)
 {
     this.exp   = exp;
     this.type  = type;
     this.name  = name;
     this.index = index;
 }
        private void setExperiment(ExperimentData experimentData)
        {
            NE_Helper.log("MOVExp.setExp() id: " + experimentData.getId());
            expData = experimentData;
            //contains = expData.getAbbreviation();
            expData.setStorage(this);

            experimentID = expData.getId();
            experiment   = ResearchAndDevelopment.GetExperiment(experimentID);

            experimentActionName = "Results";
            resetActionName      = "Throw Away Results";
            reviewActionName     = "Review " + expData.getAbbreviation() + " Results";

            useStaging            = false;
            useActionGroups       = true;
            hideUIwhenUnavailable = true;
            resettable            = false;
            resettableOnEVA       = false;

            dataIsCollectable = false;
            collectActionName = "Collect Results";
            interactionRange  = 1.2f;
            xmitDataScalar    = 0.05f;
            if (chanceTexture)
            {
                setTexture(expData);
            }
        }
Esempio n. 8
0
 public override void installExperiment(ExperimentData exp)
 {
     if (exp.getEquipmentNeeded() == EquipmentRacks.EXPOSURE)
     {
         exposureSlot.installExperiment(exp);
         experimentName = exp.getAbbreviation() + ": " + exp.stateString();
     }
 }
 internal void showDialog(List <ExperimentStorage> targets, ExperimentData experimentData)
 {
     NE_Helper.log("start");
     this.targets = targets;
     exp          = experimentData;
     NE_Helper.log("init done");
     windowID = WindowCounter.getNextWindowID();
     showGui  = true;
 }
Esempio n. 10
0
 internal ExperimentData getExperiment()
 {
     if (!isEquipmentInstalled() || experimentSlotFree())
     {
         return(ExperimentData.getNullObject());
     }
     else
     {
         return(equ.getExperiment());
     }
 }
        internal void installExperiment(ExperimentData exp)
        {
            this.exp = exp;
            exp.installed(this);
            GameObject ego = lab.getExperimentGO(exp.getId());

            if (ego != null)
            {
                ego.SetActive(true);
            }
        }
        private void loadExperiment(ExperimentData experimentData)
        {
            this.exp = experimentData;
            exp.load(this);
            GameObject ego = lab.getExperimentGO(exp.getId());

            if (ego != null)
            {
                ego.SetActive(true);
            }
        }
 private void setTexture(ExperimentData expData)
 {
     GameDatabase.TextureInfo tex = textureReg.getTextureForExperiment(expData);
     if (tex != null)
     {
         changeTexture(tex);
     }
     else
     {
         NE_Helper.logError("Change Experiment Container Texure: Texture Null");
     }
 }
        public static ExperimentData getExperimentDataFromNode(ConfigNode node)
        {
            if (node.name != CONFIG_NODE_NAME)
            {
                NE_Helper.logError("getLabEquipmentFromNode: invalid Node: " + node.name);
                return(getNullObject());
            }
            float mass = getMass(node.GetValue(MASS_VALUE));

            ExperimentData exp = ExperimentFactory.getExperiment(node.GetValue(TYPE_VALUE), mass);

            exp.load(node);
            return(exp);;
        }
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            NE_Helper.log("ExperimentStorage: OnLoad");

            ConfigNode expNode = node.GetNode(ExperimentData.CONFIG_NODE_NAME);

            if (expNode != null)
            {
                setExperiment(ExperimentData.getExperimentDataFromNode(expNode));
            }
            else
            {
                setExperiment(ExperimentData.getNullObject());
            }
        }
Esempio n. 16
0
        private static ExperimentStep createExperimentStep(string type, ExperimentData exp, string name, int index)
        {
            switch (type)
            {
            case "ResStep":
                return(new ResourceExperimentStep(exp, name, index));

            case "MEPResStep":
                return(new MEPResourceExperimentStep(exp, name, index));

            case "KerbalResStep":
                return(new KerbalResearchStep(exp, name, index));

            default:
                return(new ExperimentStep(exp, "", name, index));
            }
        }
Esempio n. 17
0
        public override void installExperiment(ExperimentData exp)
        {
            switch (exp.getEquipmentNeeded())
            {
            case EquipmentRacks.CIR:
                if (cirSlot.isEquipmentInstalled() && cirSlot.experimentSlotFree())
                {
                    cirSlot.installExperiment(exp);
                    cirStatus = exp.getAbbreviation();
                    Fields["cirStatus"].guiActive = true;
                }
                else
                {
                    NE_Helper.logError("installExperiment, installed: " + cirSlot.isEquipmentInstalled() + "; free: " + cirSlot.experimentSlotFree());
                }
                break;

            case EquipmentRacks.FIR:
                if (firSlot.isEquipmentInstalled() && firSlot.experimentSlotFree())
                {
                    firSlot.installExperiment(exp);
                    ffrStatus = exp.getAbbreviation();
                    Fields["ffrStatus"].guiActive = true;
                }
                else
                {
                    NE_Helper.logError("installExperiment, installed: " + firSlot.isEquipmentInstalled() + "; free: " + firSlot.experimentSlotFree());
                }
                break;

            case EquipmentRacks.PRINTER:
                if (printerSlot.isEquipmentInstalled() && printerSlot.experimentSlotFree())
                {
                    printerSlot.installExperiment(exp);
                    prStatus = exp.getAbbreviation();
                    Fields["prStatus"].guiActive = true;
                }
                else
                {
                    NE_Helper.logError("installExperiment, installed: " + printerSlot.isEquipmentInstalled() + "; free: " + printerSlot.experimentSlotFree());
                }
                break;
            }
        }
Esempio n. 18
0
 public override void installExperiment(ExperimentData exp)
 {
     switch (exp.getEquipmentNeeded())
     {
     case EquipmentRacks.KEMINI:
         if (keminiSlot.isEquipmentInstalled() && keminiSlot.experimentSlotFree())
         {
             keminiSlot.installExperiment(exp);
             keminiStatus = exp.getAbbreviation();
             Fields["keminiStatus"].guiActive = true;
             keminiSlot.experimentAction();
         }
         else
         {
             NE_Helper.logError("installExperiment, installed: " + keminiSlot.isEquipmentInstalled() + "; free: " + keminiSlot.experimentSlotFree());
         }
         break;
     }
 }
        internal GameDatabase.TextureInfo getTextureForExperiment(ExperimentData expData)
        {
            GameDatabase.TextureInfo tex;
            if (textureReg.TryGetValue(expData.getType(), out tex))
            {
                return(tex);
            }
            else
            {
                NE_Helper.log("Loading Texture for experiment: " + expData.getType());
                GameDatabase.TextureInfo newTex = getTexture(expData.getType());
                if (newTex != null)
                {
                    textureReg.Add(expData.getType(), newTex);
                    return(newTex);
                }
            }

            return(null);
        }
        /// <summary>
        /// Sets or clears the stored experiment
        /// </summary>
        /// <param name="experimentData">Experiment data.</param>
        private void setExperiment(ExperimentData experimentData)
        {
            NE_Helper.log("MOVExp.setExp() id: " + experimentData.getId());
            expData = experimentData;
            //contains = expData.getAbbreviation();
            expData.setStorage(this);

            experimentID = expData.getId();
            if (expData.getId() == "")
            {
                experiment = null;
            }
            else
            {
                experiment = ResearchAndDevelopment.GetExperiment(experimentID);
            }

            experimentActionName = Localizer.GetStringByTag("#ne_Results");
            resetActionName      = Localizer.GetStringByTag("#ne_Discard_Results");
            reviewActionName     = Localizer.Format("#ne_Review_1_Results", expData.getAbbreviation());

            useStaging            = false;
            useActionGroups       = true;
            hideUIwhenUnavailable = true;
            resettable            = false;
            resettableOnEVA       = false;

            dataIsCollectable = false;
            collectActionName = Localizer.GetStringByTag("#ne_Collect_Results");
            interactionRange  = 1.2f;
            xmitDataScalar    = 0.05f;
            if (chanceTexture)
            {
                setTexture(expData);
            }
            RefreshMassAndCost();
        }
        internal void showDialog(List <ExperimentStorage> targets, ExperimentData experimentData)
        {
            NE_Helper.log("start");
            this.targets = targets;
            exp          = experimentData;
            NE_Helper.log("init done");
            if (exp == null || targets == null || targets.Count == 0)
            {
                this.enabled = false;
                return;
            }
            // Highlight source part
            sourcePart = exp.store.getPart();
            sourcePart.SetHighlightColor(dullOrange);
            sourcePart.SetHighlightType(Part.HighlightType.AlwaysOn);
            sourcePart.SetHighlight(true, false);

            // Create a list of destination parts and highlight them
            for (int i = 0, count = targets.Count; i < count; i++)
            {
                Part p = targets[i].part;
                if (p == sourcePart || destinationParts.Contains(p))
                {
                    continue;
                }
                destinationParts.Add(p);
                p.SetHighlightColor(dullCyan);
                p.SetHighlightType(Part.HighlightType.AlwaysOn);
                p.SetHighlight(true, false);
            }

            smInfo = ScreenMessages.PostScreenMessage(Localizer.Format("#ne_Select_a_part_to_transfer_1_to_ESC_to_cancel", exp.getAbbreviation()),
                                                      15, ScreenMessageStyle.UPPER_CENTER);
            smInfo.color = Color.cyan;
            this.enabled = true;
            NE_Helper.LockUI();
        }
Esempio n. 22
0
        public static ExperimentStep getExperimentStepFromConfigNode(ConfigNode node, ExperimentData exp)
        {
            if (node.name != CONFIG_NODE_NAME)
            {
                NE_Helper.logError("getExperimentStepFromConfigNode: invalid Node: " + node.name);
                return(new ExperimentStep(exp, "", ""));
            }
            int            index = NE_Helper.GetValueAsInt(node, INDEX_VALUE);
            string         name  = node.GetValue(NAME_VALUE);
            ExperimentStep step  = createExperimentStep(node.GetValue(TYPE_VALUE), exp, name, index);

            step.load(node);
            return(step);
        }
 public void removeExperimentData()
 {
     part.mass -= expData.getMass();
     setExperiment(ExperimentData.getNullObject());
 }
 internal void storeExperiment(ExperimentData experimentData)
 {
     setExperiment(experimentData);
 }
        public static ExperimentData getExperiment(string type, float mass)
        {
            switch (type)
            {
            case "Test":
                return(new TestExperimentData(mass));

            case "CCF":
                return(new CCF_ExperimentData(mass));

            case "CFE":
                return(new CFE_ExperimentData(mass));

            case "FLEX":
                return(new FLEX_ExperimentData(mass));

            case "CFI":
                return(new CFI_ExperimentData(mass));

            case "MIS1":
                return(new MIS1_ExperimentData(mass));

            case "MIS2":
                return(new MIS2_ExperimentData(mass));

            case "MIS3":
                return(new MIS3_ExperimentData(mass));

            case "MEE1":
                return(new MEE1_ExperimentData(mass));

            case "MEE2":
                return(new MEE2_ExperimentData(mass));

            case "CVB":
                return(new CVB_ExperimentData(mass));

            case "PACE":
                return(new PACE_ExperimentData(mass));

            case "KeminiD5":
                return(new KeminiD5_ExperimentData(mass));

            case "KeminiD8":
                return(new KeminiD8_ExperimentData(mass));

            case "KeminiMSC3":
                return(new KeminiMSC3_ExperimentData(mass));

            case "KeminiD7":
                return(new KeminiD7_ExperimentData(mass));

            case "KeminiD10":
                return(new KeminiD10_ExperimentData(mass));

            case "ADUM":
                return(new ADUM_ExperimentData(mass));

            case "SpiU":
                return(new SpiU_ExperimentData(mass));

            default:
                NE_Helper.logError("Unknow ExperimentData Type");
                return(ExperimentData.getNullObject());
            }
        }
 public KerbalResearchStep(ExperimentData exp, string name, int index)
     : base(exp, "KerbalResStep", name, index)
 {
 }
 internal KerbalResearchStep(ExperimentData exp, string resName, float amount, int index)
     : base(exp, resName, amount, "KerbalResStep", "name", index)
 {
 }
Esempio n. 28
0
        /* +---------------------------------------------------+
         * |              Storage Manifest                     |
         * +---------------------------------------------------+
         * | OMS ESC 4/1                                    |^||
         * |         Material Exposure Experiment 1         | ||
         * |         Needs: MEP-825 and MPL-600 or MSL-1000 | ||
         * |         State: Finished                        | ||
         * |                                                | ||
         * | OMS ESC 4/2                                    | ||
         * |         empty                                  | ||
         * |                                                | ||
         * | OMS ESC 4/3                                    | ||
         * |         3D Printer Demonstration Test          |v||
         * |                  [Close]                          |
         * +---------------------------------------------------+
         */
        private void showManifestWindow()
        {
            // This is a list of content items to add to the dialog
            List <DialogGUIBase> dialog = new List <DialogGUIBase>();

            // TODO? Add description of part for which we're displaying the manifest
            //dialog.Add(new DialogGUILabel("Chooose lab"));
            //dialog.Add(new DialogGUISpace(4));

            // Build a button list of all available experiments with their descriptions
            int numSlots = storageSlots.Count;

            DialogGUIBase[] scrollList = new DialogGUIBase[numSlots + 1];
            scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < numSlots; i++)
            {
                var e = storageSlots[i];
                sb.Append("<b>").Append(e.identifier).Append("</b>\n");
                if (e.isEmpty())
                {
                    sb.Append("\t ").Append(Localizer.Format("#ne_empty")).AppendLine();
                }
                else
                {
                    ExperimentData exp = e.getStoredExperimentData();
                    sb.Append(exp.getDescription("\t ")).AppendLine();
                    sb.Append("\t ").Append(Localizer.Format("#ne_Status")).Append(": ").Append(exp.displayStateString()).AppendLine();
                }

                var label = new DialogGUILabel(sb.ToString(), true, true);
                var h     = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, label);
                scrollList[i + 1] = h;
                sb.Length         = 0;
            }

            // NB: Specify a minimum size; the scroll-list will automatically expand to fill available space in the parent form.
            dialog.Add(
                new DialogGUIScrollList(new Vector2(300, 300), false, true,
                                        //new DialogGUIScrollList(Vector2.one, false, true,
                                        new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.UpperLeft, scrollList)
                                        ));

            dialog.Add(new DialogGUISpace(4));

            // Add a centered "Close" button
            dialog.Add(new DialogGUIHorizontalLayout(new DialogGUIBase[]
            {
                new DialogGUIFlexibleSpace(),
                new DialogGUIButton(Localizer.Format("#ne_Close"), null, true),
                new DialogGUIFlexibleSpace(),
            }));

            // Calculate size of dialog window
            Rect pos = new Rect(0.5f, 0.5f, width, fixedHeight + numSlots * slotHeight);

            if (pos.height > maxHeight)
            {
                pos.height = maxHeight;
            }

            // Actually create and show the dialog
            PopupDialog.SpawnPopupDialog(
                new MultiOptionDialog("", "", Localizer.Format("#ne_Storage_Manifest"), HighLogic.UISkin, pos, dialog.ToArray()),
                false, HighLogic.UISkin);
        }
Esempio n. 29
0
 internal MEPResourceExperimentStep(ExperimentData exp, string name, int index = 0)
     : base(exp, "MEPResStep", name, index)
 {
 }
Esempio n. 30
0
 public MEPResourceExperimentStep(ExperimentData exp, string res, float amount, string name, int index)
     : base(exp, res, amount, "MEPResStep", name, index)
 {
 }