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));
 }
 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));
 }
 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);
            }
        }
        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");
                }
            }
        }
Beispiel #6
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));
 }
        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);
            }
        }
Beispiel #9
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);
        }
 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 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 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;
 }
Beispiel #13
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());
 }
Beispiel #14
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");
            }
        }
Beispiel #15
0
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     NE_Helper.log("MPL OnSave");
     node.AddNode(msgSlot.getConfigNode());
     node.AddNode(usuSlot.getConfigNode());
 }
Beispiel #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);
 }
        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);
        }
Beispiel #18
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());
 }
Beispiel #19
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);
 }
Beispiel #20
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));
 }
Beispiel #21
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));
 }
 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;
 }
Beispiel #23
0
        private void initPartObjects()
        {
            if (part.internalModel != null)
            {
                GameObject labIVA = part.internalModel.gameObject.transform.GetChild(0).GetChild(0).gameObject;
                if (labIVA.GetComponent <MeshFilter>().name == "Lab1IVA")
                {
                    NE_Helper.log("set printer transforms");
                    GameObject printer = labIVA.transform.GetChild(0).gameObject;
                    //GameObject cir = labIVA.transform.GetChild(1).gameObject;
                    headBase = printer.transform.GetChild(1).GetChild(0);
                    if (headBase != null)
                    {
                        prAs = 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(prMovingSound);
                        prAs.clip         = clip;
                        prAs.dopplerLevel = DOPPLER_LEVEL;
                        prAs.rolloffMode  = AudioRolloffMode.Logarithmic;
                        prAs.Stop();
                        prAs.loop        = true;
                        prAs.minDistance = MIN_DIST;
                        prAs.maxDistance = MAX_DIST;
                        prAs.volume      = 1f;

                        prBaseChgDirAs              = part.gameObject.AddComponent <AudioSource>();// using gameobjects from the internal model does not work AS would stay in the place it was added.
                        prBaseChgDirAs.clip         = GameDatabase.Instance.GetAudioClip(prBaseChgDirSound);
                        prBaseChgDirAs.dopplerLevel = DOPPLER_LEVEL;
                        prBaseChgDirAs.rolloffMode  = AudioRolloffMode.Logarithmic;
                        prBaseChgDirAs.Stop();
                        prBaseChgDirAs.loop        = false;
                        prBaseChgDirAs.minDistance = MIN_DIST;
                        prBaseChgDirAs.maxDistance = MAX_DIST;
                        prBaseChgDirAs.volume      = 0.4f;

                        prHeadChgDirAs              = part.gameObject.AddComponent <AudioSource>();// using gameobjects from the internal model does not work AS would stay in the place it was added.
                        prHeadChgDirAs.clip         = GameDatabase.Instance.GetAudioClip(prHeadChgDirSound);
                        prHeadChgDirAs.dopplerLevel = DOPPLER_LEVEL;
                        prHeadChgDirAs.rolloffMode  = AudioRolloffMode.Logarithmic;
                        prHeadChgDirAs.Stop();
                        prHeadChgDirAs.loop        = false;
                        prHeadChgDirAs.minDistance = MIN_DIST;
                        prHeadChgDirAs.maxDistance = MAX_DIST;
                        prHeadChgDirAs.volume      = 1f;
                    }
                    head = headBase.GetChild(0);
                }
            }
        }
        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());
            }
        }
        private GameDatabase.TextureInfo getTexture(string p)
        {
            KeyValuePair <string, string> textureName;

            if (textureNameReg.TryGetValue(p, out textureName))
            {
                NE_Helper.log("Looking for Texture:" + textureName.Value + " in : " + textureName.Key);
                GameDatabase.TextureInfo newTex = GameDatabase.Instance.GetTextureInfoIn(textureName.Key, textureName.Value);
                if (newTex != null)
                {
                    return(newTex);
                }
            }
            NE_Helper.logError("Could not load texture for Exp: " + p);
            return(null);
        }
Beispiel #26
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (state == StartState.Editor)
            {
                return;
            }
            NE_Helper.log("MEP_Module OnStart");
            exposureSlot.onStart(this);
            if (!exposureSlot.isEquipmentInstalled())
            {
                exposureSlot.install(new LabEquipment("MEP", "MEP", EquipmentRacks.EXPOSURE, 0f, 0f, ExposureTimePerHour, Resources.EXPOSURE_TIME, 0, ""), this);;
            }

            switch (MEPlabState)
            {
            case MEPLabStatus.NOT_READY:
                playAnimation(deployAnimName, -1f, 0f);
                Events["FixArm"].guiActiveUnfocused = false;
                Events["DeployPlatform"].guiActive  = true;
                break;

            case MEPLabStatus.READY:
                playAnimation(startExpAnimName, -1f, 0f);
                Events["FixArm"].guiActiveUnfocused = false;
                Events["DeployPlatform"].guiActive  = true;
                break;

            case MEPLabStatus.RUNNING:
                playAnimation(startExpAnimName, 1f, 1f);
                Events["DeployPlatform"].guiActive  = false;
                Events["FixArm"].guiActiveUnfocused = false;
                break;

            case MEPLabStatus.ERROR_ON_START:
                playAnimation(errorOnStartAnimName, 1f, 1f);
                Events["FixArm"].guiActiveUnfocused = true;
                Events["DeployPlatform"].guiActive  = false;
                break;

            case MEPLabStatus.ERROR_ON_STOP:
                playAnimation(errorOnStopAnimName, -1f, 0f);
                Events["FixArm"].guiActiveUnfocused = true;
                Events["DeployPlatform"].guiActive  = false;
                break;
            }
        }
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);

            if (checkedForKIS())
            {
                NE_Helper.log("KIS Installed");
                Events["attachPEC"].active    = false;
                Events["attachPEC"].guiActive = false;
            }
            else
            {
                NE_Helper.log("No KIS");
                Events["attachPEC"].active    = true;
                Events["attachPEC"].guiActive = true;
            }
        }
Beispiel #28
0
        private void initERacksActive()
        {
            if (part.internalModel != null)
            {
                GameObject labIVA = part.internalModel.gameObject.transform.GetChild(0).GetChild(0).gameObject;
                if (labIVA.GetComponent <MeshFilter>().name == "Lab1IVA")
                {
                    printer = labIVA.transform.GetChild(0).gameObject;
                    cir     = labIVA.transform.GetChild(1).gameObject;
                    fir     = labIVA.transform.GetChild(2).gameObject;

                    if (firSlot.isEquipmentInstalled())
                    {
                        fir.SetActive(true);
                    }
                    else
                    {
                        fir.SetActive(false);
                    }

                    if (cirSlot.isEquipmentInstalled())
                    {
                        cir.SetActive(true);
                    }
                    else
                    {
                        cir.SetActive(false);
                    }

                    if (printerSlot.isEquipmentInstalled())
                    {
                        printer.SetActive(true);
                    }
                    else
                    {
                        printer.SetActive(false);
                    }
                }
                NE_Helper.log("init E Racks successfull");
            }
            else
            {
                NE_Helper.log("init E Racks internal model null");
            }
        }
 internal override void updateCheck()
 {
     base.updateCheck();
     if (state == ExperimentState.RUNNING)
     {
         List <string> crewMembers = getAllLabCrewMembers();
         if (!crewMembers.Contains(getActiveStep().getSubjectName()))
         {
             string debug = "";
             foreach (string member in crewMembers)
             {
                 debug += member + ", ";
             }
             NE_Helper.log("Aborting Crew Members: " + debug + "; Subject; " + getActiveStep().getSubjectName());
             getActiveStep().abortStep();
             state = ExperimentState.INSTALLED;
         }
     }
 }
        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);
        }