Пример #1
0
 public Design findDesign(Design d)
 {
     foreach (Design r in designs.Values)
     {
         if (r.Equals(d))
         {
             return(r);
         }
     }
     return(null);
 }
Пример #2
0
 public void AddDesign(Design d)
 {
     if (designs.ContainsKey(d.guid))
     {
         /* Implies we've messed up somewhere and tried to add the same Design twice. */
         Logging.LogFormat("Tried to add design with duplicate guid {0}", d.guid);
         return;
     }
     designs[d.guid] = d;
     generation++;
 }
Пример #3
0
        public Design(Design old, int newTL)         // upgrade of an existing design
        {
            name   = "";
            family = old.family;
            tl     = newTL;
            float tf = old.thrust / family.getMaxThrust(old.tl);

            thrust = family.getMaxThrust(tl) * tf;
            int ni = family.getMaxIgnitions(old.tl) - old.ignitions;

            ignitions    = family.getMaxIgnitions(tl) - ni;
            familyLetter = family.letter;
            upgradeFrom  = old.guid;
            guid         = Guid.NewGuid();
        }
Пример #4
0
 public Family(ConfigNode node)
 {
     letter = node.GetValue("letter")[0];
     try {
         description = node.GetValue("description");
         if (node.HasValue("minTf"))
         {
             minTf = float.Parse(node.GetValue("minTf"));
         }
         if (node.HasValue("minIgnitions"))
         {
             minIgnitions = int.Parse(node.GetValue("minIgnitions"));
         }
         foreach (ConfigNode tn in node.GetNodes("TechLevel"))
         {
             techLevels.Add(new TechLevel(tn));
         }
         baseDesign = new Design(this, 0);
     } catch (Exception ex) {
         Logging.LogFormat("Error occurred in family {0}, TL {1}", letter, techLevels.Count);
         throw ex;
     }
 }
Пример #5
0
 public Design(Design old) : this(old.name, old.family, old.tl, old.thrust, old.ignitions)         // clone
 {
 }
Пример #6
0
        public void applyConfig(bool propagate, bool movePart)
        {
            cacheDesign = null;
            if (design == null)
            {
                return;
            }
            if (engine == null)
            {
                Logging.LogFormat("No ModuleEngineConfigs found on part!");
                return;
            }
            if (design.check != Design.Constraint.OK)
            {
                Logging.LogFormat("Broken design {0}: letter={1}, problem={2}", design.name, design.familyLetter, design.check);
                return;
            }
            cacheDesign = design;
            DesignName  = design.name;
            Logging.LogFormat("Applying design '{0}': thrust {1}", design.name, design.thrust);

            engine.configs.Clear();
            ConfigNode node = new ConfigNode();

            /* Name to match our TestFlight configs.
             * Per TechLevel, not per Design, because the latter
             * would mean constructing TestFlight configs at run-
             * time which I'd rather not have to do.
             */
            string configName = String.Format("SPEngine-{0}-{1}", design.familyLetter, design.tl);

            node.AddValue("name", configName);
            node.AddValue("maxThrust", (design.thrust * chamberMultiplier).ToString());
            node.AddValue("minThrust", (design.thrust * chamberMultiplier * design.minThrottle).ToString());
            node.AddValue("ignitions", design.ignitions.ToString());
            ConfigNode ispn = new ConfigNode();

            design.isp.Save(ispn);
            node.AddNode("atmosphereCurve", ispn);
            node.AddValue("ullage", design.ullage.ToString());
            node.AddValue("pressureFed", design.pressureFed.ToString());
            node.AddValue("cost", (design.cost * chamberMultiplier).ToString());

            /* Setting this to 0 forces RF to calculate a proper throttle up time.
             * Previously it was taking (assumingly large) numbers and setting instant throttle
             */
            node.AddValue("throttleResponseRate", 0);
            for (int i = 0; i < design.propellants.Count; i++)
            {
                node.AddNode(design.propellants[i]);
            }
            for (int i = 0; i < design.ignitorResources.Count; i++)
            {
                node.AddNode(design.ignitorResources[i]);
            }
            engine.configs.Add(node);
            engine.SetConfiguration(configName);
            /* Scale the visual model, nodes and drag cubes */
            var       prefab = PartLoader.getPartInfoByName(part.partInfo.name).partPrefab;
            Transform xform = part.partTransform.Find("model"), preform = prefab.partTransform;

            xform.localScale = preform.localScale * scaleFactor;
            xform.hasChanged = true;
            fixNodes(movePart);

            /* TODO drag cubes.  Somehow.
             * DRVeyl says to do what https://github.com/KSP-RO/ProceduralParts/blob/3466a39/Source/ProceduralPart.cs#L698-L725 does.
             */
            if (propagate && design != design.family.baseDesign)
            {
                UpdateSymmetryCounterparts();
            }
        }
Пример #7
0
        public void applyConfig(bool propagate)
        {
            cacheDesign = null;
            if (design == null)
            {
                return;
            }
            if (engine == null)
            {
                Logging.LogFormat("No ModuleEngineConfigs found on part!");
                return;
            }
            if (design.check != Design.Constraint.OK)
            {
                Logging.LogFormat("Broken design {0}: letter={1}, problem={2}", design.name, design.familyLetter, design.check);
                return;
            }
            cacheDesign = design;
            DesignName  = design.name;
            Logging.LogFormat("Applying design '{0}': thrust {1}", design.name, design.thrust);

            engine.configs.Clear();
            ConfigNode node = new ConfigNode();

            /* Name to match our TestFlight configs.
             * Per TechLevel, not per Design, because the latter
             * would mean constructing TestFlight configs at run-
             * time which I'd rather not have to do.
             */
            string configName = String.Format("SPEngine-{0}-{1}", design.familyLetter, design.tl);

            node.AddValue("name", configName);
            node.AddValue("maxThrust", design.thrust.ToString());
            node.AddValue("minThrust", (design.thrust * design.minThrottle).ToString());
            node.AddValue("ignitions", design.ignitions.ToString());
            ConfigNode ispn = new ConfigNode();

            design.isp.Save(ispn);
            node.AddNode("atmosphereCurve", ispn);
            node.AddValue("ullage", design.ullage.ToString());
            node.AddValue("pressureFed", design.pressureFed.ToString());
            node.AddValue("cost", design.cost.ToString());

            /* Setting this to 0 forces RF to calculate a proper throttle up time.
             * Previously it was taking (assumingly large) numbers and setting instant throttle
             */
            node.AddValue("throttleResponseRate", 0);
            for (int i = 0; i < design.propellants.Count; i++)
            {
                node.AddNode(design.propellants[i]);
            }
            for (int i = 0; i < design.ignitorResources.Count; i++)
            {
                node.AddNode(design.ignitorResources[i]);
            }
            engine.configs.Add(node);
            engine.SetConfiguration(configName);
            if (propagate && design != design.family.baseDesign)
            {
                UpdateSymmetryCounterparts();
            }
        }