public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     NE_Helper.log("MPL OnLoad");
     msgSlot = getLabEquipmentSlot(node.GetNode(MSG_CONFIG_NODE_NAME));
     usuSlot = getLabEquipmentSlot(node.GetNode(USU_CONFIG_NODE_NAME));
 }
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     NE_Helper.log("MPL OnSave");
     node.AddNode(getConfigNodeForSlot(MSG_CONFIG_NODE_NAME, msgSlot));
     node.AddNode(getConfigNodeForSlot(USU_CONFIG_NODE_NAME, usuSlot));
 }
示例#3
0
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     NE_Helper.log("MEP OnSave");
     node.AddValue(MEP_STATE_VALUE, MEPlabState);
     node.AddNode(getConfigNodeForSlot(SLOT_CONFIG_NODE_NAME, exposureSlot));
 }
示例#4
0
        public override List <Lab> getFreeLabsWithEquipment(Vessel vessel)
        {
            List <Lab> ret = new List <Lab>();

            MSL_Module[] allPhysicsLabs = null;
            if (cachedVesselID == vessel.id && partCount == vessel.parts.Count && physicsLabCache != null)
            {
                allPhysicsLabs = physicsLabCache;
            }
            else
            {
                allPhysicsLabs  = UnityFindObjectsOfType(typeof(MSL_Module)) as MSL_Module[];
                physicsLabCache = allPhysicsLabs;
                cachedVesselID  = vessel.id;
                partCount       = vessel.parts.Count;
                NE_Helper.log("Lab Cache refresh");
            }
            for (int idx = 0, count = allPhysicsLabs.Length; idx < count; idx++)
            {
                var lab = allPhysicsLabs[idx];
                if (lab.vessel == vessel && lab.hasEquipmentInstalled(neededEquipment) && lab.hasEquipmentFreeExperimentSlot(neededEquipment))
                {
                    ret.Add(lab);
                }
            }
            return(ret);
        }
        private void loadOrCreateSettings()
        {
            bool d = false;

            try
            {
                if (String.IsNullOrEmpty(SETTINGS_FILE))
                {
                    SETTINGS_FILE = KSPUtil.ApplicationRootPath + "GameData/NehemiahInc/NE_Science_Common/Resources/settings.cfg";
                }
                ConfigNode settings = ConfigNode.Load(SETTINGS_FILE);
                if (settings == null)
                {
                    settings.AddValue(DEBUG_VALUE, false);
                    settings.Save(SETTINGS_FILE);
                }
                else
                {
                    d = bool.Parse(settings.GetValue(DEBUG_VALUE));
                }
            }
            catch (Exception e)
            {
                d = true;
                NE_Helper.logError("Loading Settings: " + e.Message);
            }
            NE_Helper.debug = d;
        }
 private void checkForExp()
 {
     if (node != null && node.attachedPart != null)
     {
         KEESExperiment newExp = node.attachedPart.GetComponent <KEESExperiment>();
         if (newExp != null)
         {
             if (exp == null)
             {
                 exp = newExp;
                 exp.dockedToPEC(true);
                 NE_Helper.log("New KEES Experiment installed");
             }
             else if (exp != newExp)
             {
                 exp.dockedToPEC(false);
                 exp = newExp;
                 exp.dockedToPEC(true);
                 NE_Helper.log("KEES Experiment switched");
             }
         }
         else if (exp != null)
         {
             exp.dockedToPEC(false);
             NE_Helper.log("KEES Experiment undocked");
             exp = null;
         }
     }
 }
        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);
            }
        }
示例#8
0
        /// <summary>
        /// Gets all lab crew members.
        /// </summary>
        /// <returns>A (possibly empty) list of lab crew members.</returns>
        internal List <string> getAllLabCrewMembers()
        {
            List <string> members = new List <string>();

            if (state == ExperimentState.INSTALLED || state == ExperimentState.RUNNING)
            {
                try {
                    if (store == null)
                    {
                        NE_Helper.logError("getAllLabCrewMembers: store is null!");
                    }
                    Lab lab = ((LabEquipment)store).getLab();
                    if (lab == null)
                    {
                        NE_Helper.logError("getAllLabCrewMembers: lab is null!");
                    }
                    if (lab.part == null)
                    {
                        NE_Helper.logError("getAllLabCrewMembers: lab.part is null!");
                    }
                    if (lab.part.protoModuleCrew == null)
                    {
                        NE_Helper.logError("getAllLabCrewMembers: lab.part.protoModuleCrew is null!");
                    }
                    for (int idx = 0, count = lab.part.protoModuleCrew.Count; idx < count; idx++)
                    {
                        var crewMember = lab.part.protoModuleCrew[idx];
                        members.Add(crewMember.name.Trim());
                    }
                } catch (NullReferenceException nre) {
                    NE_Helper.logError("getAllLabCrewMembers: nullref!\n" + nre.StackTrace);
                }
            }
            return(members);
        }
 internal void abortStep()
 {
     NE_Helper.log("Abort Research");
     ScreenMessages.PostScreenMessage("Test subject left lab. Research aborted!", 6, ScreenMessageStyle.UPPER_CENTER);
     subject = "";
     ((LabEquipment)exp.store).setResourceMaxAmount(res, 0f);
 }
        public List <ExperimentStorage> getFreeExperimentContainers(Vessel vessel)
        {
            List <ExperimentStorage> freeCont = new List <ExperimentStorage>();
            List <ExperimentStorage> allCont;

            if (cachedVesselID == vessel.id && partCount == vessel.parts.Count && contCache != null)
            {
                allCont = contCache;
            }
            else
            {
                allCont        = new List <ExperimentStorage>(UnityFindObjectsOfType(typeof(ExperimentStorage)) as ExperimentStorage[]);
                contCache      = allCont;
                cachedVesselID = vessel.id;
                partCount      = vessel.parts.Count;
                NE_Helper.log("Storage Cache refresh");
            }

            foreach (ExperimentStorage c in allCont)
            {
                if (c.vessel == vessel && c.isEmpty() && c.type == storageType)
                {
                    freeCont.Add(c);
                }
            }
            return(freeCont);
        }
 public void install(Lab lab)
 {
     NE_Helper.log("Lab equipment install in " + lab.abbreviation);
     gen = createGenerator(product, productPerHour, reactant, reactantPerProduct, lab);
     lab.addGenerator(gen);
     this.lab = lab;
 }
示例#12
0
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     NE_Helper.log("MEP OnSave");
     node.AddValue(MEP_STATE_VALUE, MEPlabState);
     node.AddNode(exposureSlot.getConfigNode());
 }
示例#13
0
        private void initERacksActive()
        {
            if (part.internalModel != null)
            {
                GameObject labIVA = part.internalModel.gameObject.transform.GetChild(0).GetChild(0).gameObject;
                if (labIVA.GetComponent <MeshFilter>().name == "MPL_IVA")
                {
                    msg = labIVA.transform.GetChild(3).gameObject;

                    cfe = msg.transform.GetChild(2).GetChild(0).gameObject;
                    usu = labIVA.transform.GetChild(4).gameObject;

                    cfe.SetActive(!msgSlot.experimentSlotFree());
                    msg.SetActive(msgSlot.isEquipmentInstalled());
                    usu.SetActive(usuSlot.isEquipmentInstalled());

                    NE_Helper.log("init E Racks successfull");
                }
                else
                {
                    NE_Helper.logError("MPL mesh not found");
                }
            }
            else
            {
                NE_Helper.log("init E Racks internal model null");
            }
        }
        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);
        }
示例#15
0
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     NE_Helper.log("MPL OnSave");
     node.AddNode(msgSlot.getConfigNode());
     node.AddNode(usuSlot.getConfigNode());
 }
示例#16
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     NE_Helper.log("MPL OnLoad");
     msgSlot = getLabEquipmentSlotByType(node, MSG_LAB_EQUIPMENT_TYPE);
     usuSlot = getLabEquipmentSlotByType(node, USU_LAB_EQUIPMENT_TYPE);
 }
示例#17
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;
            }
        }
        public override void OnUpdate()
        {
            base.OnUpdate();

            /* Only perform the max-G check if we are attached to a vessel.
             * During KAS grab, vessel can be itself or a Kerbal, and we may
             * get spurious high G's. */
            bool isVesselShip = part.parent != null && vessel != null && !vessel.isEVA;

            if (decoupled && vessel.vesselType != VesselType.Debris)
            {
                NE_Helper.log("Decoupled PEC recoverd");
                decoupled = false;
            }
            if (!decoupled && isVesselShip && vessel.geeForce > maxGforce)
            {
                NE_Helper.log("KEES PEC over max G, decouple\n" + this.ToString());
                decouple();
            }
            //Decouple for testing
            if (NE_Helper.debugging() && Input.GetKeyDown(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.D))
            {
                decouple();
            }
            if (!decoupled && counter == 0)//don't run this every frame
            {
                checkForExp();
            }
            counter = (++counter) % 6;
        }
        private GameDatabase.TextureInfo getTextureForState(string name)
        {
            NE_Helper.log("Experiment Name: " + name);
            switch (name)
            {
            case "empty":
                if (noExp == null)
                {
                    noExp = getTexture(folder, noExpTexture);
                }
                return(noExp);

            case "MEE1":
                if (mee1 == null)
                {
                    mee1 = getTexture(folder, mee1Texture);
                }
                return(mee1);

            case "MEE2":
                if (mee2 == null)
                {
                    mee2 = getTexture(folder, mee2Texture);
                }
                return(mee2);

            default:
                return(null);
            }
        }
        public override List <Lab> getFreeLabsWithEquipment(Vessel vessel)
        {
            List <Lab>        ret = new List <Lab>();
            List <MPL_Module> allPhysicsLabs;

            if (cachedVesselID == vessel.id && partCount == vessel.parts.Count && physicsLabCache != null)
            {
                allPhysicsLabs = physicsLabCache;
            }
            else
            {
                allPhysicsLabs  = new List <MPL_Module>(UnityFindObjectsOfType(typeof(MPL_Module)) as MPL_Module[]);
                physicsLabCache = allPhysicsLabs;
                cachedVesselID  = vessel.id;
                partCount       = vessel.parts.Count;
                NE_Helper.log("Lab Cache refresh");
            }
            foreach (MPL_Module lab in allPhysicsLabs)
            {
                if (lab.vessel == vessel && lab.hasEquipmentFreeExperimentSlot(neededEquipment))
                {
                    ret.Add(lab);
                }
            }
            return(ret);
        }
        public override ConfigNode getNode()
        {
            ConfigNode baseNode = base.getNode();

            try {
                if (baseNode == null)
                {
                    NE_Helper.logError("MultiStepExperimentData.getNode() - baseNode is NULL!");
                }
                baseNode.AddValue(ACTIVE_VALUE, activeStep);

                for (int idx = 0, count = steps.Length; idx < count; idx++)
                {
                    var es = steps[idx];
                    if (es == null)
                    {
                        NE_Helper.logError("MultiStepExperimentData(" + getId() + ").getNode() - es is NULL!\n"
                                           + "    entry " + (idx + 1) + " in steps[" + steps.Length + "] is NULL\n");
                        continue;
                    }
                    ConfigNode expNode = es.getNode();
                    if (expNode == null)
                    {
                        NE_Helper.logError("MultiStepExperimentData.getNode() - expNode is NULL!");
                        continue;
                    }
                    baseNode.AddNode(es.getNode());
                }
            } catch (NullReferenceException nre) {
                NE_Helper.logError("MultiStepExperimentData.getNode - NullReferenceException:\n"
                                   + nre.StackTrace);
            }
            return(baseNode);
        }
        private void initPartObjects()
        {
            if (part.internalModel != null)
            {
                GameObject labIVA = part.internalModel.gameObject.transform.GetChild(0).GetChild(0).gameObject;

                if (labIVA.GetComponent <MeshFilter>().name == "MEP IVA")
                {
                    NE_Helper.log("set alarm light");

                    GameObject light = labIVA.transform.GetChild(3).GetChild(0).gameObject;
                    alarmLight = light.transform.GetChild(0).gameObject.GetComponent <Light>();

                    lightMat = light.GetComponent <Renderer>().material;
                    alarmAs  = part.gameObject.GetComponent <AudioSource>();
                    if (alarmAs == null)
                    {
                        alarmAs = part.gameObject.AddComponent <AudioSource>(); // using gameobjects from the internal model does not work AS would stay in the place it was added.
                    }
                    AudioClip clip = GameDatabase.Instance.GetAudioClip(alarmSound);
                    alarmAs.clip         = clip;
                    alarmAs.dopplerLevel = DOPPLER_LEVEL;
                    alarmAs.rolloffMode  = AudioRolloffMode.Linear;
                    alarmAs.Stop();
                    alarmAs.loop        = true;
                    alarmAs.minDistance = MIN_DIST;
                    alarmAs.maxDistance = MAX_DIST;
                    alarmAs.volume      = 0.6f;
                }
                else
                {
                    NE_Helper.logError("MEP IVA not found");
                }
            }
        }
示例#23
0
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     NE_Helper.log("MSL OnSave");
     node.AddNode(cirSlot.getConfigNode());
     node.AddNode(firSlot.getConfigNode());
     node.AddNode(printerSlot.getConfigNode());
 }
示例#24
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     NE_Helper.log("MSL OnLoad");
     cirSlot     = getLabEquipmentSlotByType(node, CIR_LAB_EQUIPMENT_TYPE);
     firSlot     = getLabEquipmentSlotByType(node, FIR_LAB_EQUIPMENT_TYPE);
     printerSlot = getLabEquipmentSlotByType(node, PRINTER_LAB_EQUIPMENT_TYPE);
 }
示例#25
0
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     NE_Helper.log("MSL OnSave");
     node.AddNode(getConfigNodeForSlot(CIR_CONFIG_NODE_NAME, cirSlot));
     node.AddNode(getConfigNodeForSlot(FIR_CONFIG_NODE_NAME, firSlot));
     node.AddNode(getConfigNodeForSlot(DPR_CONFIG_NODE_NAME, printerSlot));
 }
示例#26
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     NE_Helper.log("MSL OnLoad");
     cirSlot     = getLabEquipmentSlot(node.GetNode(CIR_CONFIG_NODE_NAME));
     firSlot     = getLabEquipmentSlot(node.GetNode(FIR_CONFIG_NODE_NAME));
     printerSlot = getLabEquipmentSlot(node.GetNode(DPR_CONFIG_NODE_NAME));
 }
 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;
 }
示例#28
0
 protected override void displayStatusMessage(string s)
 {
     try {
         labStatus = s;
         Fields["labStatus"].guiActive = true;
     } catch (Exception e) {
         NE_Helper.logError("MSL_Module.displayStatusMessage(): caught exception " + e + "\n" + e.StackTrace);
     }
 }
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);

            node = part.FindAttachNode(nodeName);
            if (node == null)
            {
                NE_Helper.logError("KEES PEC: AttachNode not found");
                node = part.attachNodes[0];
            }
        }
示例#30
0
 private void setTexture(LabEquipment type)
 {
     GameDatabase.TextureInfo tex = texFac.getTextureForEquipment(type.getType());
     if (tex != null)
     {
         changeTexture(tex);
     }
     else
     {
         NE_Helper.logError("Change Equipment Container Texure: Texture Null");
     }
 }