Пример #1
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);
                }
            }
Пример #2
0
        static void Postfix(SGBarracksServicePanel __instance, Pilot p,
                            BattleTech.UI.TMProWrapper.LocalizableText ___biographyLabel, SimGameState ___sim, HBSTagView ___tagViewer)
        {
            if (p == null)
            {
                return;
            }

            CrewDetails details = ModState.GetCrewDetails(p.pilotDef);

            // Disable the battle stats
            GameObject battleStats = __instance.gameObject.FindFirstChildNamed(ModConsts.GO_HBS_Barracks_ServicePanel_BattleStats);

            if (details.IsMechTechCrew || details.IsMedTechCrew || details.IsAerospaceCrew)
            {
                battleStats.SetActive(false);
            }
            else
            {
                battleStats.SetActive(true);
            }

            Mod.Log.Debug?.Write($"Iterating tags for pilot: {p.Name}");
            // Filter the HR GUID tag out
            List <string> filteredTags = p.pilotDef.PilotTags.Where(t => !t.StartsWith(ModTags.Tag_GUID)).ToList();
            TagSet        baseTags     = new TagSet(filteredTags);

            foreach (string tag in p.pilotDef.PilotTags)
            {
                ___tagViewer.Initialize(baseTags, ___sim.Context, ___sim.DebugMode, 4);
            }

            Mod.Log.Debug?.Write("Updating attitude fields.");

            StringBuilder sb = new StringBuilder();

            if (!details.IsPlayer)
            {
                // Inject hazard pay, if appropriate
                if (details.HazardPay > 0)
                {
                    string hazardPayS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Hazard_Pay],
                                                 new object[] { SimGameState.GetCBillString(details.HazardPay) }).ToString();
                    Mod.Log.Debug?.Write($"Hazard pay is: {hazardPayS}");
                    sb.Append(hazardPayS);
                    sb.Append("\n");
                }

                // Inject attitude
                string attitudeValKey = ModText.LT_Crew_Attitude_Average;
                if (details.Attitude >= Mod.Config.Attitude.ThresholdBest)
                {
                    attitudeValKey = ModText.LT_Crew_Attitude_Best;
                }
                else if (details.Attitude >= Mod.Config.Attitude.ThresholdGood)
                {
                    attitudeValKey = ModText.LT_Crew_Attitude_Good;
                }
                else if (details.Attitude <= Mod.Config.Attitude.ThresholdWorst)
                {
                    attitudeValKey = ModText.LT_Crew_Attitude_Worst;
                }
                else if (details.Attitude <= Mod.Config.Attitude.ThresholdPoor)
                {
                    attitudeValKey = ModText.LT_Crew_Attitude_Poor;
                }

                string attitudeDescS = new Text(Mod.LocalizedText.Labels[attitudeValKey]).ToString();
                Mod.Log.Debug?.Write($"Attitude value is: {details.Attitude} with label: {attitudeDescS}");

                string attitudeS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Biography_Attitude],
                                            new object[] { attitudeDescS, details.Attitude }).ToString();
                sb.Append(attitudeS);
                sb.Append("\n");

                // Convert favored and hated faction
                if (details.FavoredFactionId > 0)
                {
                    FactionValue faction         = FactionEnumeration.GetFactionByID(details.FavoredFactionId);
                    string       favoredFactionS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Biography_Faction_Favored],
                                                            new object[] { faction.FactionDef.CapitalizedName }).ToString();
                    sb.Append(favoredFactionS);
                    sb.Append("\n");
                    Mod.Log.Debug?.Write($"  Favored Faction is: {favoredFactionS}");
                }

                if (details.HatedFactionId > 0)
                {
                    FactionValue faction       = FactionEnumeration.GetFactionByID(details.HatedFactionId);
                    string       hatedFactionS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Biography_Faction_Hated],
                                                          new object[] { faction.FactionDef.CapitalizedName }).ToString();
                    sb.Append(hatedFactionS);
                    sb.Append("\n");
                    Mod.Log.Debug?.Write($"  Hated Faction is: {hatedFactionS}");
                }
            }

            // Add the original description
            sb.Append(Interpolator.Interpolate(p.pilotDef.Description.GetLocalizedDetails().ToString(true), ___sim.Context, true));

            string biographyS = sb.ToString();

            Mod.Log.Debug?.Write($"Biography will be: {biographyS}");
            ___biographyLabel.SetText(biographyS, Array.Empty <object>());
        }