// ============ Jettison Ammo ============

        public static void AutoJettisonAmmo(MechHeatSequence __instance)
        {
            try {
                if (!__instance.IsComplete)
                {
                    return;
                }
                Mech mech = __instance.OwningMech;
                if (mech == null || mech.IsDead || mech.HasMovedThisRound || mech.IsProne || mech.IsShutDown)
                {
                    return;
                }
                if (!FriendOrFoe(mech, Settings.AutoJettisonAmmo, Settings.AutoJettisonEnemyAmmo))
                {
                    return;
                }

                Dictionary <AmmoCategoryValue, bool> checkedType = new Dictionary <AmmoCategoryValue, bool>();
                List <AmmunitionBox> jettison = new List <AmmunitionBox>();
                foreach (AmmunitionBox box in mech.ammoBoxes)
                {
                    if (box.CurrentAmmo <= 0)
                    {
                        continue;
                    }
                    AmmoCategoryValue type = box.ammoCategoryValue;
                    if (checkedType.ContainsKey(type))
                    {
                        if (checkedType[type])
                        {
                            jettison.Add(box);
                        }
                        continue;
                    }
                    bool canUseAmmo = mech.Weapons.Any(e => e.AmmoCategoryValue == type && e.DamageLevel < ComponentDamageLevel.NonFunctional);
                    if (!canUseAmmo)
                    {
                        jettison.Add(box);
                    }
                    checkedType[type] = !canUseAmmo;
                }

                if (jettison.Count <= 0)
                {
                    return;
                }
                foreach (AmmunitionBox box in jettison)
                {
                    ZeroAmmo(box, mech.uid, __instance.SequenceGUID);
                }
                foreach (AmmoCategoryValue type in checkedType.Where(e => e.Value).Select(e => e.Key))
                {
                    Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(mech,
                                                                                                                type + " AMMO JETTISONED", FloatieMessage.MessageNature.Buff, false)));
                }
            }                 catch (Exception ex) { Error(ex); }
        }
Exemple #2
0
        public static void Postfix(AmmoCategoryValue __instance, ref SVGAsset __result)
        {
            if (DataManager_PrewarmComplete.dataManager == null)
            {
                return;
            }
            SVGAsset result = DataManager_PrewarmComplete.dataManager.GetObjectOfType <SVGAsset>(__instance.Icon, BattleTechResourceType.SVGAsset);

            if (result != null)
            {
                __result = result;
            }
        }
Exemple #3
0
 public static bool isBuildinIcon(this AmmoCategoryValue ammoCat)
 {
     return(UILookAndColorConstantsIcons.Contains(ammoCat.Icon));
 }