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);
        }
Exemple #2
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;
            }
        }
Exemple #3
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");
            }
        }
Exemple #4
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);
        }
        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");
                }
            }
        }
        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;
        }
Exemple #8
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];
            }
        }
 protected LabEquipmentSlot getLabEquipmentSlot(ConfigNode configNode)
 {
     if (configNode != null)
     {
         return(LabEquipmentSlot.getLabEquipmentSlotFromConfigNode(configNode.GetNode(LabEquipmentSlot.CONFIG_NODE_NAME), this));
     }
     else
     {
         NE_Helper.logError("Lab GetLabEquipmentSlotFromNode: LabEquipmentSlotNode null");
         return(new LabEquipmentSlot(EquipmentRacks.NONE));
     }
 }
Exemple #11
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");
     }
 }
 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");
     }
 }
Exemple #13
0
 public void install(LabEquipment eq, Lab lab)
 {
     if (eq != null && type == eq.getType())
     {
         equ = eq;
         eq.install(lab);
     }
     else
     {
         NE_Helper.logError("LabEquipmentSlot.install: Type doesn't macht");
     }
 }
Exemple #14
0
        private void changeTexture(GameDatabase.TextureInfo newTexture)
        {
            Material mat = getScreenMaterial();

            if (mat != null)
            {
                mat.mainTexture = newTexture.texture;
            }
            else
            {
                NE_Helper.logError("Transform NOT found: " + "MEP IVA Screen");
            }
        }
Exemple #15
0
        private void changeTexture(GameDatabase.TextureInfo newTexture)
        {
            Material mat = getContainerMaterial();

            if (mat != null)
            {
                mat.mainTexture = newTexture.texture;
            }
            else
            {
                NE_Helper.logError("Transform NOT found: " + "Equipment Container");
            }
        }
        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);;
        }
Exemple #17
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);
        }
Exemple #18
0
        private GameDatabase.TextureInfo getTexture(EquipmentRacks p)
        {
            KeyValuePair <string, string> textureName;

            if (textureNameReg.TryGetValue(p, out textureName))
            {
                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);
        }
 public override void OnSave(ConfigNode node)
 {
     try{
         if (node == null)
         {
             NE_Helper.logError("OnSave: node is NULL!");
             //return;
         }
         base.OnSave(node);
         node.AddNode(expData.getNode());
     } catch (NullReferenceException nre) {
         NE_Helper.logError("ExperimentStorage.OnSave - NullReferenceException:\n"
                            + nre.StackTrace);
     }
 }
Exemple #20
0
        private void playAnimation(string animName, float speed, float time)
        {
            Animation anim = part.FindModelAnimators(animName).FirstOrDefault();

            if (anim != null)
            {
                anim[animName].speed          = speed;
                anim[animName].normalizedTime = time;

                anim.Play(animName);
            }
            else
            {
                NE_Helper.logError("no Animation; Name: " + animName);
            }
        }
        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);
        }
Exemple #22
0
        public static LabEquipmentSlot getLabEquipmentSlotFromConfigNode(ConfigNode node, Lab lab)
        {
            if (node == null || node.name != CONFIG_NODE_NAME)
            {
                NE_Helper.logError("getLabEquipmentFromNode: invalid Node: " + node == null? "NULL" : node.name);
                return(new LabEquipmentSlot(EquipmentRacks.NONE));
            }
            EquipmentRacks type   = EquipmentRacksFactory.getType(node.GetValue(TYPE_VALUE));
            LabEquipment   le     = null;
            ConfigNode     leNode = node.GetNode(LabEquipment.CONFIG_NODE_NAME);

            if (leNode != null)
            {
                le = LabEquipment.getLabEquipmentFromNode(leNode, lab);
            }
            return(new LabEquipmentSlot(type, le));
        }
        void Start()
        {
            ConfigNode settings = getSettingsNode();
            bool       d        = false;

            try
            {
                d = bool.Parse(settings.GetValue(DEBUG_VALUE));
            }
            catch (FormatException e)
            {
                d = true;
                NE_Helper.logError("Loading Settings: " + e.Message);
            }
            NE_Helper.debug = d;
            DontDestroyOnLoad(this);
        }
        public override ConfigNode getNode()
        {
            ConfigNode baseNode = base.getNode();

            try {
                baseNode.AddValue(ACTIVE_VALUE, activeStep);

                foreach (ExperimentStep es in steps)
                {
                    baseNode.AddNode(es.getNode());
                }
            } catch (NullReferenceException nre) {
                NE_Helper.logError("MultiStepExperimentData.getNode - NullReferenceException:\n"
                                   + nre.StackTrace);
            }
            return(baseNode);
        }
        internal List <string> getAllLabCrewMembers()
        {
            List <string> members = new List <string>();

            if (state == ExperimentState.INSTALLED || state == ExperimentState.RUNNING)
            {
                try {
                    Lab lab = ((LabEquipment)store).getLab();
                    foreach (ProtoCrewMember crewMember in lab.part.protoModuleCrew)
                    {
                        members.Add(crewMember.name.Trim());
                    }
                } catch (NullReferenceException nre) {
                    NE_Helper.logError("getAllLabCrewMembers: nullref!\n" + nre.StackTrace);
                }
            }
            return(members);
        }
Exemple #26
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;
            }
        }
Exemple #27
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;
     }
 }
Exemple #28
0
 private void switchLightsOff()
 {
     if (warnLight != null)
     {
         warnLight.intensity = 0f;
     }
     else
     {
         NE_Helper.logError("WarnLight null");
     }
     if (warnPointLight != null)
     {
         warnPointLight.intensity = 0.0f;
     }
     else
     {
         NE_Helper.logError("WarnPointLight null");
     }
 }
 public void installExperiment()
 {
     availableLabs = expData.getFreeLabsWithEquipment(part.vessel);
     if (availableLabs.Count > 0)
     {
         if (availableLabs.Count == 1)
         {
             installExperimentInLab(availableLabs[0]);
         }
         else
         {
             windowID = WindowCounter.getNextWindowID();
             showGui  = 3;
         }
     }
     else
     {
         NE_Helper.logError("Experiment install: No lab found");
     }
 }
 private Material getContainerMaterial()
 {
     if (contMat == null)
     {
         Transform t = part.FindModelTransform("Experiment");
         if (t != null)
         {
             contMat = t.renderer.material;
             return(contMat);
         }
         else
         {
             NE_Helper.logError("Experiment Container Material null");
             return(null);
         }
     }
     else
     {
         return(contMat);
     }
 }