Exemplo n.º 1
0
            public IEnumerable <DialogGUIBase> GetTraitDescription(bool showParts, List <ProtoCrewMember> crew)
            {
                List <ExperienceTraitConfig> careers = GameDatabase.Instance.ExperienceConfigs
                                                       .GetTraitsWithEffect(this.Trait)
                                                       .Select(name => GameDatabase.Instance.ExperienceConfigs.GetExperienceTraitConfig(name))
                                                       .ToList();

                //  #Needed    Specialist   #Crew    Generalist   #Crew
                //  1.5        Miner        2        3*Engineer   0
                //    Scrounger Drill-

                var requirementRow = new DialogGUIHorizontalLayout();

                string quantity = UncrewedQuantity + DisabledQuantity > 0.001
                    ? $"{this.TotalQuantity - UncrewedQuantity - DisabledQuantity:N1}/{this.TotalQuantity:N1}"
                    : this.TotalQuantity.ToString("N1");

                if (UncrewedQuantity > 0.001)
                {
                    quantity = TextEffects.Red(quantity);
                }
                else if (DisabledQuantity > 0.001)
                {
                    quantity = TextEffects.Yellow(quantity);
                }
                requirementRow.AddChild(new DialogGUILabel(quantity, width: NumberColumnWidth));
                for (int i = 0; i < careers.Count; ++i)
                {
                    ExperienceEffectConfig effectConfig = careers[i].Effects.First(effect => effect.Name == this.Trait);
                    var levelString = effectConfig.Config.GetValue("level");
                    int numStars    = SkillLevel - int.Parse(levelString ?? "0");

                    requirementRow.AddChild(new DialogGUILabel(
                                                PksCrewRequirement.DescribeKerbalTrait(numStars, careers[i].Title), ProfessionColumnWidth));
                    requirementRow.AddChild(new DialogGUILabel(
                                                $"{crew.Count(c => c.trait == careers[i].Title && c.experienceLevel >= numStars)}",
                                                width: NumberColumnWidth));
                }
                yield return(requirementRow);

                if (showParts)
                {
                    var partsRow = new DialogGUIHorizontalLayout();
                    partsRow.AddChild(new DialogGUISpace(15));
                    partsRow.AddChild(new DialogGUILabel($"<I>{string.Join(", ", this.PartNames)}</I>"));
                    yield return(partsRow);
                }
            }
Exemplo n.º 2
0
        public void OnUpgrade()
        {
            if (!this.CanUpgrade)
            {
                return;
            }

            PartResourceDefinition rocketPartsResourceDefinition = PartResourceLibrary.Instance.GetDefinition(rocketPartsResourceName);

            vessel.GetConnectedResourceTotals(rocketPartsResourceDefinition.id, out double rocketPartsOnHand, out double _);
            string kerbalFixerDescription = PksCrewRequirement.DescribeKerbalsWithEffect(requiredEffect, 1 + this.TieredConverter.Tier);

            if (rocketPartsOnHand == 0)
            {
                PopupMessageWithKerbal.ShowPopup("No can do boss!", $"This job requires {rocketPartsResourceDefinition.displayName}; there are none aboard.", "K, I'll go get some");
                return;
            }

            int numUpgraders = this.NumberOfUpgraders();

            if (numUpgraders == 0)
            {
                PopupMessageWithKerbal.ShowPopup("No can do boss!", $"This job requires a {kerbalFixerDescription}; there are none aboard", "K, I'll go get some");
                return;
            }

            PopupMessageWithKerbal.ShowOkayCancel(
                title: "Moar Boosters!",
                content: $"Upgrading this part will take it offline for {this.upgradeTimeInKerbalDays:N} days "
                + $"and require the full-time attention of a {kerbalFixerDescription} (you have {numUpgraders} on board).  "
                + $"It will take {this.upgradeCost} {rocketPartsResourceDefinition.displayName} (you have "
                + $"{rocketPartsOnHand:N} on-hand at the moment).\r\n\r\n"
                + "But moreover, in order for this part to function once it gets upgraded, the whole "
                + "supply chain that leads up to this part needs to be updated as well.  This operation needs "
                + "to be approached with some care; if your kerbals run out of snacks during the upgrade, "
                + "the whole operation can go to pieces.",
                okayButton: "Let's Do This!",
                cancelButton: "Err, nope.",
                onOkay: this.StartUpgrade);
        }