public static void Postfix(string id, TagDataStruct __result)
        {
            string desc;

            if (PilotQuirkManager.Instance.lookUpQuirkDescription(id, out desc))
            {
                __result.DescriptionTag += "\n\n" + desc;
            }
        }
Esempio n. 2
0
            public static void Postfix(HBSTagView __instance, TagSet tagSet, GameContext context)
            {
                if (!Pre_Control.settings.MechBonding)
                {
                    return;
                }

                if (tagSet.Contains("PQ_Mech_Mastery"))
                {
                    bool HasTattoo = PilotHolder.pilotDef.PilotTags.Any(x => x.StartsWith("PQ_Pilot_GUID"));
                    if (!HasTattoo)
                    {
                        return;
                    }

                    string PilotTattoo = PilotHolder.pilotDef.PilotTags.First(x => x.StartsWith("PQ_Pilot_GUID"));
                    if (!MechBonding.PilotsAndMechs.Keys.Contains(PilotTattoo) || MechBonding.PilotsAndMechs[PilotTattoo].Count() == 0)
                    {
                        return;
                    }

                    var    MechExperience = MechBonding.PilotsAndMechs[PilotTattoo];
                    var    BondedMech     = MechExperience.Aggregate((l, r) => l.Value > r.Value ? l : r).Key;
                    string MasteryTier    = "";
                    if (MechExperience[BondedMech] >= Pre_Control.settings.Tier4)
                    {
                        MasteryTier = "Elite ";
                    }
                    else if (MechExperience[BondedMech] >= Pre_Control.settings.Tier3)
                    {
                        MasteryTier = "Veteran ";
                    }
                    else if (MechExperience[BondedMech] >= Pre_Control.settings.Tier2)
                    {
                        MasteryTier = "Regular ";
                    }
                    else if (MechExperience[BondedMech] >= Pre_Control.settings.Tier1)
                    {
                        MasteryTier = "Green ";
                    }

                    string DescriptionName = MasteryTier + " 'Mech Pilot";

                    var    item         = new TagDataStruct("HACK_GENCON_UNIT", true, true, "name", DescriptionName, "description");
                    string contextItem  = string.Format("{0}[{1}]", "TDSF", item.Tag);
                    string friendlyName = item.FriendlyName;
                    var    itemTT       = TooltipUtilities.GetGameContextTooltipString(contextItem, friendlyName);

                    __instance.AddTag(itemTT, item.FriendlyName);
                }
            }
Esempio n. 3
0
            public static void Postfix(string id, TagDataStruct __result)
            {
                if (id == "HACK_GENCON_UNIT")
                {
                    __result.DescriptionTag += MechMasterTagDescription(UI_Changes.PilotHolder, __result.DescriptionTag);
                }

                if (!Pre_Control.settings.TagIDToDescription.ContainsKey(id))
                {
                    return;
                }

                __result.DescriptionTag += "\n\n" + Pre_Control.settings.TagIDToDescription[id];
            }
        private static PilotDef GenerateCrew(StarSystem starSystem, string callsign, PilotDef pilotDef)
        {
            Mod.Log.Debug?.Write($"Generating support crew with callsign: {callsign}");

            // Generate the lifepath we'll use
            LifePath lifePath = LifePathHelper.GetRandomLifePath();

            int initialAge = ModState.SimGameState.Constants.Pilot.MinimumPilotAge +
                             ModState.SimGameState.NetworkRandom.Int(1, ModState.SimGameState.Constants.Pilot.StartingAgeRange + 1);
            int currentAge = Mod.Random.Next(initialAge, 70);

            Mod.Log.Debug?.Write($" - currentAge: {currentAge}");

            Gender newGender   = RandomGender();
            Gender voiceGender = newGender;

            if (voiceGender == Gender.NonBinary)
            {
                voiceGender = ((!(ModState.SimGameState.NetworkRandom.Float() < 0.5f)) ? Gender.Female : Gender.Male);
            }
            string voice        = RandomUnusedVoice(voiceGender);
            string newFirstName = ModState.CrewCreateState.NameGenerator.GetFirstName(newGender);
            string newLastName  = ModState.CrewCreateState.NameGenerator.GetLastName();

            Mod.Log.Debug?.Write($" - gender: {newGender}  voiceGender: {voiceGender}  firstName: {newFirstName}  lastName: {newLastName}");
            pilotDef.SetVoice(voice);

            StringBuilder lifepathDescParagraphs = new StringBuilder();
            string        backgroundTitle        = new Text(lifePath.Description.Title).ToString();
            string        backgroundDesc         = new Text(lifePath.Description.Description).ToString();
            // DETAILS string is EXTREMELY picky, see HumanDescriptionDef.GetLocalizedDetails. There format must be followed *exactly*
            string formattedBackground = $"{Environment.NewLine}<b>{backgroundTitle}:</b>  {backgroundDesc}";

            Mod.Log.Debug?.Write($" - Background: {formattedBackground}");
            lifepathDescParagraphs.Append(formattedBackground);

            // Add tags from the lifepath
            TagSet tagSet = new TagSet();

            tagSet.AddRange(lifePath.RequiredTags);

            foreach (string tag in lifePath.RandomTags)
            {
                double tagRoll = Mod.Random.NextDouble();
                if (tagRoll <= Mod.Config.HiringHall.LifePath.RandomTagChance)
                {
                    tagSet.Add(tag);
                }
            }
            Mod.Log.Debug?.Write($" - Tags: {String.Join(", ", tagSet)}");

            // Add tags to the background
            foreach (string tagId in tagSet)
            {
                Tag_MDD tagIfExists = MetadataDatabase.Instance.GetTagIfExists(tagId);
                if (tagIfExists != null)
                {
                    TagDataStruct tagStruct    = new TagDataStruct(tagId, tagIfExists.PlayerVisible, tagIfExists.Important, tagIfExists.Name, tagIfExists.FriendlyName, tagIfExists.Description);
                    string        formattedTag = $"<b><color=#ff8c00>{tagStruct.FriendlyName}:</b>  <color=#ffffff>{tagStruct.DescriptionTag}";
                    lifepathDescParagraphs.Append(formattedTag);
                }
            }

            string id = GenerateID();
            HumanDescriptionDef descriptionDef = new HumanDescriptionDef(id, callsign, newFirstName, newLastName, callsign, newGender,
                                                                         FactionEnumeration.GetNoFactionValue(), currentAge, lifepathDescParagraphs.ToString(), null);

            StatCollection statCollection = pilotDef.GetStats();
            int            spentXPPilot   = GetSpentXPPilot(statCollection);

            List <string> alreadyAssignedPortraits = new List <string>();

            if (ModState.SimGameState.Commander != null && ModState.SimGameState.Commander.pilotDef.PortraitSettings != null)
            {
                alreadyAssignedPortraits.Add(ModState.SimGameState.Commander.pilotDef.PortraitSettings.Description.Id);
            }
            foreach (Pilot activePilot in ModState.SimGameState.PilotRoster)
            {
                if (activePilot.pilotDef.PortraitSettings != null)
                {
                    alreadyAssignedPortraits.Add(activePilot.pilotDef.PortraitSettings.Description.Id);
                }
            }

            PilotDef pilotDef2 = new PilotDef(descriptionDef, pilotDef.BaseGunnery, pilotDef.BasePiloting, pilotDef.BaseGuts, pilotDef.BaseTactics, 0,
                                              ModState.SimGameState.CombatConstants.PilotingConstants.DefaultMaxInjuries, lethalInjury: false, 0, voice, pilotDef.abilityDefNames,
                                              AIPersonality.Undefined, 0, tagSet, spentXPPilot, 0)
            {
                DataManager      = ModState.SimGameState.DataManager,
                PortraitSettings = GetPortraitForGenderAndAge(voiceGender, currentAge, alreadyAssignedPortraits)
            };

            ModState.SimGameState.pilotGenCallsignDiscardPile.Add(pilotDef2.Description.Callsign);

            return(pilotDef2);
        }