예제 #1
0
        //Check of the parts has to be upgraded
        private TestResult checkPart(ConfigNode part, LoadContext loadContext)
        {
            string partName = NodeUtil.GetPartNodeNameValue(part, loadContext).Split('_')[0];

            string[] attachementNodes = part.GetValues("attN");
            switch (partName)
            {
            case "KKAOSS.Storage.g":
            case "KKAOSS.Storage.mid.g":
            case "KKAOSS.Storage.size2.m":
            case "KKAOSS.Storage.size2.s":
                for (int j = 0; j < attachementNodes.Length; j++)
                {
                    string[] values = attachementNodes[j].Split(',');
                    if ((values[0] == "left") || (values[0] == "right"))
                    {
                        return(TestResult.Upgradeable);
                    }
                }
                break;

            case "KKAOSS.Service.g":
                for (int j = 0; j < attachementNodes.Length; j++)
                {
                    string[] values = attachementNodes[j].Split(',');
                    if (values[0] == "inner")
                    {
                        return(TestResult.Upgradeable);
                    }
                }
                break;

            case "KKAOSS.gangway.2.adapter":
            case "KKAOSS.garage.front.g.2":
            case "KKAOSS.garage.struct.g.2":
                for (int j = 0; j < attachementNodes.Length; j++)
                {
                    string[] values = attachementNodes[j].Split(',');
                    if (values[0].StartsWith("node_leg"))
                    {
                        return(TestResult.Upgradeable);
                    }
                }
                break;

            case "KKAOSS.container.SEP":
                for (int j = 0; j < attachementNodes.Length; j++)
                {
                    string[] values = attachementNodes[j].Split(',');
                    if (values[0] == "front")
                    {
                        return(TestResult.Upgradeable);
                    }
                }
                break;
            }
            return(TestResult.Pass);
        }
예제 #2
0
        public override TestResult OnTest(ConfigNode node, LoadContext loadContext, ref string nodeName)
        {
            nodeName = NodeUtil.GetPartNodeNameValue(node, loadContext);
            TestResult testResult = TestResult.Pass;

            ConfigNode[] nodes = node.GetNodes("MODULE");
            TestResult   result;
            int          num;

            for (int i = nodes.Length - 1; i >= 0; i = num)
            {
                string value = nodes[i].GetValue("name");
                string a     = value;
                if (a == "ModuleAmpYearPPTRCS" || a == "ModuleAmpYearPoweredRCS")
                {
                    result = TestResult.Upgradeable;
                    return(result);
                }
                num = i - 1;
            }
            result = testResult;
            return(result);
        }
예제 #3
0
        //upgrade the save file
        public override void OnUpgrade(ConfigNode node, LoadContext loadContext, ConfigNode ParentNode)
        {
            //when the part of a craft should be upgraded
            if (loadContext == LoadContext.Craft)
            {
                upgradePart(node, loadContext);
            }
            else if (loadContext == LoadContext.SFS)
            {
                string partName = NodeUtil.GetPartNodeNameValue(node, loadContext);

                //iterate over all vessels in the savefile
                ConfigNode[] vessels = node.GetNode("FLIGHTSTATE").GetNodes("VESSEL");
                for (int i = 0; i < vessels.Length; i++)
                {
                    //iterate of all parts in the vessel
                    ConfigNode[] parts = vessels[i].GetNodes("PART");
                    for (int j = 0; j < parts.Length; j++)
                    {
                        upgradePart(parts[j], loadContext);
                    }
                }
            }
        }
예제 #4
0
        //Upgrade the part
        private void upgradePart(ConfigNode part, LoadContext loadContext)
        {
            string partName = NodeUtil.GetPartNodeNameValue(part, loadContext).Split('_')[0];

            string[] attachementNodes = part.GetValues("attN");

            switch (partName)
            {
            case "KKAOSS.Storage.g":
            case "KKAOSS.Storage.mid.g":
            case "KKAOSS.Storage.size2.m":
            case "KKAOSS.Storage.size2.s":
                int left  = 1;
                int right = 1;
                for (int i = 0; i < attachementNodes.Length; i++)
                {
                    string[] values = attachementNodes[i].Split(',');
                    if (values[0] == "left")
                    {
                        part.SetValue("attN", "left" + left + "," + values[1], i, false);
                        left++;
                    }
                    else if (values[0] == "right")
                    {
                        part.SetValue("attN", "right" + right + "," + values[1], i, false);
                        right++;
                    }
                }
                break;

            case "KKAOSS.garage.front.g.2":
            case "KKAOSS.garage.struct.g.2":
            case "KKAOSS.gangway.2.adapter":
                int leg = 1;
                for (int i = 0; i < attachementNodes.Length; i++)
                {
                    string[] values = attachementNodes[i].Split(',');
                    if (values[0].StartsWith("node_leg"))
                    {
                        part.SetValue("attN", "leg" + leg + "," + values[1], i, false);
                        leg++;
                    }
                }
                break;

            case "KKAOSS.Service.g":
                int inner = 1;
                for (int i = 0; i < attachementNodes.Length; i++)
                {
                    string[] values = attachementNodes[i].Split(',');
                    if (values[0] == "inner")
                    {
                        if (inner == 1)
                        {
                            part.SetValue("attN", "innerbottom" + "," + values[1], i, false);
                        }
                        else
                        {
                            part.SetValue("attN", "innertop" + "," + values[1], i, false);
                        }
                        inner++;
                    }
                }
                break;

            case "KKAOSS.container.SEP":
                int front = 1;
                for (int i = 0; i < attachementNodes.Length; i++)
                {
                    string[] values = attachementNodes[i].Split(',');
                    if (values[0] == "front")
                    {
                        part.SetValue("attN", "front" + front + "," + values[1], i, false);
                        front++;
                    }
                }
                break;
            }
        }