Exemple #1
0
 private void setBottomDiameterFromEditor(float newDiameter, bool updateSymmetry)
 {
     if (newDiameter > maxDiameter)
     {
         newDiameter = maxDiameter;
     }
     if (newDiameter < minDiameter)
     {
         newDiameter = minDiameter;
     }
     if (SSTUUtils.isResearchGame() && newDiameter > techLimitMaxDiameter)
     {
         newDiameter = techLimitMaxDiameter;
     }
     bottomDiameter = newDiameter;
     rebuildFairing(true);
     updateShieldStatus();
     restoreEditorFields();
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             p.GetComponent <SSTUInterstageFairing>().setBottomDiameterFromEditor(newDiameter, false);
         }
     }
 }
        private static void updateTechLimitCache()
        {
            techLimitCache.Clear();
            ConfigNode[] techLimitSets = GameDatabase.Instance.GetConfigNodes("TECHLIMITSET");
            ConfigNode   setNode;

            ConfigNode[] techLimitNodes;
            ConfigNode   limitNode;
            string       setName;
            string       techName;
            float        techLimit;
            float        setTechLimit;
            int          len = techLimitSets.Length;
            int          len2;
            bool         researchGame = SSTUUtils.isResearchGame();

            for (int i = 0; i < len; i++)
            {
                setNode = techLimitSets[i];
                setName = setNode.GetStringValue("name");
                if (techLimitCache.ContainsKey(setName))
                {
                    continue;
                }
                setTechLimit = float.PositiveInfinity;
                if (researchGame)
                {
                    setTechLimit   = 0;
                    techLimitNodes = setNode.GetNodes("TECHLIMIT");
                    len2           = techLimitNodes.Length;
                    for (int k = 0; k < len2; k++)
                    {
                        limitNode = techLimitNodes[k];
                        techName  = limitNode.GetStringValue("name");
                        techLimit = limitNode.GetFloatValue("diameter");
                        if (techLimit > setTechLimit && SSTUUtils.isTechUnlocked(techName))
                        {
                            setTechLimit = techLimit;
                        }
                    }
                }
                techLimitCache.Add(setName, setTechLimit);
            }
        }
Exemple #3
0
        public static void updateTechLimits(String setName, out float maxDiameter)
        {
            maxDiameter = float.PositiveInfinity;
            if (!SSTUUtils.isResearchGame())
            {
                MonoBehaviour.print("Not a research game, exiting tech limit checks"); return;
            }
            if (HighLogic.CurrentGame == null)
            {
                MonoBehaviour.print("Current game is null, exiting tech limit checks"); return;
            }
            maxDiameter = 0;
            ConfigNode[] setNodes = GameDatabase.Instance.GetConfigNodes("TECHLIMITSET");
            int          len      = setNodes.Length;
            string       techName;

            for (int i = 0; i < len; i++)
            {
                if (setNodes[i].GetStringValue("name") == setName)//found the specified limit-set-name
                {
                    ConfigNode[] limitNodes = setNodes[i].GetNodes("TECHLIMIT");
                    int          setLen     = limitNodes.Length;
                    float        d;
                    for (int k = 0; k < setLen; k++)
                    {
                        techName = limitNodes[k].GetStringValue("name");
                        if (SSTUUtils.isTechUnlocked(limitNodes[k].GetStringValue("name")))
                        {
                            d = limitNodes[k].GetFloatValue("diameter");
                            if (d > maxDiameter)
                            {
                                maxDiameter = d;
                            }
                        }
                    }
                    break;
                }
            }
        }