示例#1
0
            public static void Postfix(MechComponent __instance, ref Text __result)
            {
                try
                {
                    if (!__instance.IsFunctional || __instance.GetType() != typeof(Weapon))
                    {
                        return;
                    }

                    Weapon weapon = (Weapon)__instance;
                    if (IsJammed(weapon))
                    {
                        string originalUIName = __result.ToString();
                        Color  color          = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.orangeHalf;

                        __result = new Localize.Text($"<color=#{ColorUtility.ToHtmlStringRGBA(color)}>{originalUIName}</color>", new object[] { });

                        //string weaponCaliber = new String(originalUIName.Where(Char.IsDigit).ToArray());
                        //__result = new Localize.Text($"JAMMED <size=75%>(UAC/{weaponCaliber})</size>", new object[] { });
                        //__result.Append(" <size=75%>( JAMMED )</size>", new object[0]);
                        //__result = new Localize.Text("UAC JAMMED", new object[] { });
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
示例#2
0
            public static void Postfix(ref List <Localize.Text> __result, MechDef mechDef)
            {
                if (!Core.Settings.RepairRearm)
                {
                    return;
                }

                if (mechDef != null && mechDef.MechTags.Contains("XLRP_R&R"))
                {
                    Localize.Text RR_Text = new Localize.Text("REPAIR & REARM: 'Mech has armor damage that needs repair", Array.Empty <object>());
                    __result.Add(RR_Text);
                }
            }
示例#3
0
            static void Postfix(MechLabMechInfoWidget __instance, MechDef mechDef)
            {
                if (!Core.Settings.RepairRearm)
                {
                    return;
                }

                if (mechDef != null && mechDef.MechTags.Contains("XLRP_R&R"))
                {
                    Localize.Text        RR_Text  = new Localize.Text("REPAIR & REARM: 'Mech has armor damage that needs repair", Array.Empty <object>());
                    List <Localize.Text> RR_Label = new List <Localize.Text>();
                    RR_Label.Add(RR_Text);
                    __instance.ToggleGenericAlert(RR_Label);
                }
            }
示例#4
0
            // Completeley overriding original method
            public static bool Prefix(CombatHUDMWStatus __instance, Pilot pilot)
            {
                try
                {
                    if (!(pilot.ParentActor is Mech mech))
                    {
                        return(true);
                    }
                    Logger.Info($"[CombatHUDMWStatus_RefreshPilot_PREFIX] Pilot: {pilot.Callsign}");

                    Color inspired = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.blue;
                    Color good     = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.white;
                    Color medium   = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.StabilityPipsShown.color;
                    Color bad      = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.orange;
                    Color critical = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.FloatiePilotDamage.color;

                    // Utilize the former injuries item as a general state description
                    CombatHUDStatusStackItem pilotStateHeader = __instance.InjuriesItem;
                    int           stressLevel           = pilot.GetStressLevel();
                    Localize.Text stressLevelDescriptor = new Localize.Text(Miscellaneous.GetStressLevelString(stressLevel), Array.Empty <object>());
                    Localize.Text unknownDescriptor     = new Localize.Text("UNKNOWN", Array.Empty <object>());
                    Localize.Text stateDescriptor       = pilot.IsIncapacitated || pilot.HasEjected ? unknownDescriptor : stressLevelDescriptor;

                    SVGAsset stateIcon = __instance.InjuriesItem.Icon.vectorGraphics;
                    //SVGAsset stateIcon = LazySingletonBehavior<UIManager>.Instance.UILookAndColorConstants.FloatieIconPilotInjury;
                    Color stateColor = Miscellaneous.GetStressLevelColor(stressLevel);

                    //pilotStateHeader.ShowIcon(stateIcon, stateDescription, stateColor);
                    pilotStateHeader.ShowExistingIcon(stateDescriptor, stateColor);
                    pilotStateHeader.AddTooltipString(new Localize.Text("???WILL THIS BE VISIBLE ANYWHERE AT ALL???", new object[] { }), EffectNature.Buff);

                    __instance.InspiredItem.Free();

                    /* TRY: Put pilots personal morale (high|low spirits) in InspiredItem?
                     * if (pilot.HasHighMorale)
                     * {
                     *  Localize.Text highSpiritsDescriptor = new Localize.Text("HIGH SPIRITS", Array.Empty<object>());
                     *  Color highSpiritsColor = LazySingletonBehavior<UIManager>.Instance.UIColorRefs.blue;
                     *  __instance.InspiredItem.ShowExistingIcon(highSpiritsDescriptor, highSpiritsColor);
                     * }
                     * else if (pilot.HasLowMorale)
                     * {
                     *  Localize.Text lowSpiritsDescriptor = new Localize.Text("LOW SPIRITS", Array.Empty<object>());
                     *  Color lowSpiritsColor = LazySingletonBehavior<UIManager>.Instance.UIColorRefs.orange;
                     *  __instance.InspiredItem.ShowExistingIcon(lowSpiritsDescriptor, lowSpiritsColor);
                     * }
                     */



                    // Passives
                    // BEWARE: This needs to be cleared everytime as there's a limited number of stackslots available and there are no control mechanisms or safeguards available!
                    __instance.PassivesList.ClearAllStatuses();

                    // Injuries
                    SVGAsset      injuriesIcon = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.FloatieIconPilotInjury;
                    Localize.Text injuriesText;
                    Color         injuriesColor;
                    if (pilot.IsIncapacitated)
                    {
                        injuriesText  = new Localize.Text("INCAPACITATED", new object[] { });
                        injuriesColor = critical;
                    }
                    else
                    {
                        injuriesText = new Localize.Text("INJURIES: {0}/{1}", new object[]
                        {
                            pilot.Injuries,
                            pilot.Health
                        });
                        float pilotRemainingHealth = pilot.Health - pilot.Injuries;
                        injuriesColor = (pilotRemainingHealth == 1) ? critical : (pilotRemainingHealth == 2) ? bad : (pilotRemainingHealth < pilot.Health) ? medium : good;
                    }
                    __instance.PassivesList.ShowItem(injuriesIcon, injuriesText, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = injuriesColor;



                    // StressLevel
                    SVGAsset      stressLevelIcon = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.FloatieIconPilotInjury;
                    Localize.Text stressLevelText = new Localize.Text("STRESS: {0}/{1}", new object[]
                    {
                        stressLevel,
                        4
                    });
                    Color stressLevelColor = Miscellaneous.GetStressLevelColor(stressLevel);
                    __instance.PassivesList.ShowItem(stressLevelIcon, stressLevelText, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = stressLevelColor;



                    // Fortitude (Derived from resists, morale and combat experience)
                    int fortitudeValue = (int)Math.Round(Assess.GetResistanceModifiers(mech, true, false));

                    SVGAsset      fortitudeIcon = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.MoraleDefendButtonIcon;
                    Localize.Text fortitudeText = new Localize.Text("FORTITUDE: {0}{1}", new object[]
                    {
                        fortitudeValue,
                        ""
                    });
                    Color fortitudeColor = pilot.HasMoraleInspiredEffect ? inspired : good;
                    __instance.PassivesList.ShowItem(fortitudeIcon, fortitudeText, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = fortitudeColor;



                    /* High|Low spirits
                     * if (pilot.HasHighMorale)
                     * {
                     *  SVGAsset highSpiritsIcon = LazySingletonBehavior<UIManager>.Instance.UILookAndColorConstants.StatusInspiredIcon;
                     *  Localize.Text highSpiritsDescriptor = new Localize.Text("HIGH SPIRITS", Array.Empty<object>());
                     *  Color highSpiritsColor = LazySingletonBehavior<UIManager>.Instance.UIColorRefs.blue;
                     *  __instance.PassivesList.ShowItem(highSpiritsIcon, highSpiritsDescriptor, new List<Localize.Text>(), new List<Localize.Text>()).Icon.color = highSpiritsColor;
                     *
                     *  // REF: This variant doesn't change anything regarding color updates
                     *  //CombatHUDStatusStackItem passiveStackItemHighSpirits = __instance.PassivesList.ShowItem(highSpiritsIcon, new Text("DUMMY", Array.Empty<object>()), new List<Localize.Text>(), new List<Localize.Text>());
                     *  //passiveStackItemHighSpirits.ShowExistingIcon(highSpiritsDescriptor, highSpiritsColor);
                     * }
                     * else if (pilot.HasLowMorale)
                     * {
                     *  SVGAsset lowSpiritsIcon = LazySingletonBehavior<UIManager>.Instance.UILookAndColorConstants.StatusInspiredIcon;
                     *  Localize.Text lowSpiritsDescriptor = new Localize.Text("LOW SPIRITS", Array.Empty<object>());
                     *  Color lowSpiritsColor = LazySingletonBehavior<UIManager>.Instance.UIColorRefs.orange;
                     *  __instance.PassivesList.ShowItem(lowSpiritsIcon, lowSpiritsDescriptor, new List<Localize.Text>(), new List<Localize.Text>()).Icon.color = lowSpiritsColor;
                     * }
                     */



                    // Weapons
                    int   functionalWeapons   = mech.Weapons.FindAll(w => w.DamageLevel == ComponentDamageLevel.Functional).Count;
                    int   penalizedWeapons    = mech.Weapons.FindAll(w => w.DamageLevel == ComponentDamageLevel.Penalized).Count;
                    float weaponHealthRatio   = (float)(functionalWeapons - penalizedWeapons / 2) / (float)mech.Weapons.Count;
                    int   weaponHealthPercent = (int)Math.Round(weaponHealthRatio * 100);

                    SVGAsset      weaponHealthIcon = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.SmallHardpointIcon;
                    Localize.Text weaponHealthText = new Localize.Text("WEAPONS: {0}{1}", new object[]
                    {
                        weaponHealthPercent,
                        "%"
                    });
                    Color weaponHealthColor = (weaponHealthPercent <= 25) ? critical : (weaponHealthPercent <= 50) ? bad : (weaponHealthPercent <= 75) ? medium : good;
                    __instance.PassivesList.ShowItem(weaponHealthIcon, weaponHealthText, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = weaponHealthColor;



                    // Mech Health
                    float mechHealthRatio   = (mech.SummaryStructureCurrent + mech.SummaryArmorCurrent) / (mech.SummaryStructureMax + mech.SummaryArmorMax);
                    int   mechHealthPercent = (int)Math.Round(mechHealthRatio * 100);

                    SVGAsset      mechHealthIcon       = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.StatusCoverIcon;
                    Localize.Text mechHealthDescriptor = new Localize.Text("MECH: {0}{1}", new object[] { mechHealthPercent, "%" });
                    Color         mechHealthColor      = (mechHealthPercent <= 25) ? critical : (mechHealthPercent <= 55) ? bad : (mechHealthPercent <= 85) ? medium : good;
                    __instance.PassivesList.ShowItem(mechHealthIcon, mechHealthDescriptor, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = mechHealthColor;



                    // Skipping original method
                    return(false);
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                    return(true);
                }
            }