コード例 #1
0
        public static void Postfix(CombatHUDMechTrayArmorHover __instance)
        {
            HUDMechArmorReadout          ___Readout = (HUDMechArmorReadout)Traverse.Create(__instance).Property("Readout").GetValue();
            CombatHUDTooltipHoverElement ___ToolTip = (CombatHUDTooltipHoverElement)Traverse.Create(__instance).Property("ToolTip").GetValue();

            if (___Readout != null && ___Readout.DisplayedMech != null && ___Readout.DisplayedMech.Combat != null && ___ToolTip != null)
            {
                Mech target = ___Readout.DisplayedMech;
                if (!target.Combat.HostilityMatrix.IsLocalPlayerFriendly(target.TeamId))
                {
                    SensorScanType scanType = SensorLockHelper.CalculateSharedLock(target, ModState.LastPlayerActorActivated);
                    if (scanType < SensorScanType.AllInformation)
                    {
                        ___ToolTip.BuffStrings.Clear();
                        ___ToolTip.DebuffStrings.Clear();
                    }
                }
            }
        }
コード例 #2
0
 public static bool OverridePaperDollTooltip(CombatHUDMechTrayArmorHover __instance, Mech mech, ArmorLocation location)
 {
     try {
         if (!FriendOrFoe(mech, Settings.ShowAmmoInTooltip, Settings.ShowEnemyAmmoInTooltip))
         {
             return(true);
         }
         CombatHUDMechTrayArmorHover  me      = __instance;
         CombatHUDTooltipHoverElement ToolTip = (CombatHUDTooltipHoverElement)MechTrayArmorHoverToolTipProp.GetValue(me, null);
         ToolTip.BuffStrings.Clear();
         ToolTip.DebuffStrings.Clear();
         ToolTip.BasicString = Mech.GetLongArmorLocation(location);
         foreach (MechComponent mechComponent in mech.GetComponentsForLocation(MechStructureRules.GetChassisLocationFromArmorLocation(location), ComponentType.NotSet))
         {
             string componentName = mechComponent.UIName.ToString();
             int    allAmmo       = 1;
             if (mechComponent is Weapon weaponComp && !weaponComp.AmmoCategoryValue.Is_NotSet)
             {
                 componentName += "<size=80%> (x" + (allAmmo = weaponComp.CurrentAmmo) + ")";
             }
             else if (mechComponent is AmmunitionBox ammo)
             {
                 int curr = ammo.CurrentAmmo, max = ammo.AmmoCapacity;
                 componentName += "<size=80%> (" + curr + "/" + max + ")";
                 if (curr < max / 2)
                 {
                     componentName = "<#808080>" + componentName;
                 }
             }
             if (mechComponent.DamageLevel >= ComponentDamageLevel.NonFunctional || allAmmo <= 0)
             {
                 ToolTip.DebuffStrings.Add(new Text(componentName));
             }
             else
             {
                 ToolTip.BuffStrings.Add(new Text(componentName));
             }
         }