public virtual void Init(HardpointInfo hpinfo)
        {
            HPInfo = hpinfo;


            if (hpinfo?.WeaponCategory == null || hpinfo.WeaponCategory.Is_NotSet || !hpinfo.Visible)
            {
                Hide();
                return;
            }

            WeaponCategory = hpinfo.WeaponCategory;

            if (HPInfo.OverrideColor)
            {
                color   = HPInfo.HPColor;
                uicolor = UIColor.Custom;
            }
            else
            {
                uicolor = HPInfo.WeaponCategory.GetUIColor();
            }

            init(HPInfo.WeaponCategory.GetIcon(), hpinfo.TooltipCaption, hpinfo.Description);
        }
Exemplo n.º 2
0
 private IEnumerable <HardpointDef> CreateEntries(WeaponCategoryValue category, int count)
 {
     for (var i = 0; i < count; i++)
     {
         yield return(new HardpointDef(category, false));
     }
 }
Exemplo n.º 3
0
        public static void Postfix(WeaponCategoryValue __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;
            }
        }
        public void OnLoaded(Dictionary <string, object> values)
        {
            AddWeaponCategory = WeaponCategoryEnumeration.GetWeaponCategoryByName(AddHardpoint);

            if (AddWeaponCategory == null)
            {
                AddWeaponCategory = WeaponCategoryEnumeration.GetNotSetValue();
            }

            UseWeaponCategory = WeaponCategoryEnumeration.GetWeaponCategoryByName(UseHardpoint);

            if (UseWeaponCategory == null)
            {
                UseWeaponCategory = WeaponCategoryEnumeration.GetNotSetValue();
            }
        }
        public LocationHardpointHelper(MechLabHardpointElement element)

        {
            Element  = element;
            traverse = new Traverse(element);

            weapon_category = traverse.Field <WeaponCategoryValue>("currentWeaponCategoryValue");
            WeaponCategory  = null;

            this.Text      = traverse.Field <LocalizableText>("hardpointText").Value;
            this.TextColor = Text.GetComponent <UIColorRefTracker>();
            this.Icon      = traverse.Field <SVGImage>("hardpointIcon").Value;
            this.IconColor = Icon.GetComponent <UIColorRefTracker>();
            this.Canvas    = traverse.Field <CanvasGroup>("thisCanvasGroup").Value;
            this.Tooltip   = element.GetComponent <HBSTooltip>();
            BackImage      = null;
        }
Exemplo n.º 6
0
 internal static WeaponCategoryValue MapToBasicType(WeaponCategoryValue value)
 {
     if (value.IsBallistic)
     {
         return(WeaponCategoryEnumeration.GetBallistic());
     }
     else if (value.IsEnergy)
     {
         return(WeaponCategoryEnumeration.GetEnergy());
     }
     else if (value.IsMissile)
     {
         return(WeaponCategoryEnumeration.GetMissile());
     }
     else if (value.IsSupport)
     {
         return(WeaponCategoryEnumeration.GetSupport());
     }
     else
     {
         throw new System.Exception("nope");
     }
 }
 internal static WeaponCategoryValue MapToBasicType(WeaponCategoryValue value)
 {
     if (value.IsBallistic)
     {
         return(WeaponCategoryEnumeration.GetBallistic());
     }
     else if (value.IsEnergy)
     {
         return(WeaponCategoryEnumeration.GetEnergy());
     }
     else if (value.IsMissile)
     {
         return(WeaponCategoryEnumeration.GetMissile());
     }
     else if (value.IsSupport)
     {
         return(WeaponCategoryEnumeration.GetSupport());
     }
     else
     {
         Control.mod.Logger.LogWarning($"Unsupported weapon category for {value.ID}");
         return(WeaponCategoryEnumeration.GetNotSetValue());
     }
 }
        //public void SetupDefaults()
        //{
        //    var hp = new HardpointInfo()
        //    {
        //        ID = "Ballistic",
        //        Visible = true,
        //        AllowOnWeapon = true,
        //        OverrideColor = false,
        //        Description = "A 'Mech can mount a limited number of weapons of each type, represented by 'hardpoints.' Ballistic hardpoints can mount Autocannon weapon systems, including the AC/2, AC/5, AC/10, and AC/20.",
        //        TooltipCaption = "Ballistic Hardpoints"

        //    };
        //    hp.Complete();
        //    HardpointsByName[hp.ID] = hp;
        //    HardpointsByID[hp.WeaponCategory.ID] = hp;

        //    hp = new HardpointInfo()
        //    {
        //        ID = "Energy",
        //        Visible = true,
        //        AllowOnWeapon = true,
        //        Description = "A 'Mech can mount a limited number of weapons of each type, represented by 'hardpoints.' Energy hardpoints can mount Energy weapon systems, including Medium Lasers, Large Lasers, and PPCs.",
        //        TooltipCaption = "Energy Hardpoints"
        //    };
        //    hp.Complete();
        //    HardpointsByName[hp.ID] = hp;
        //    HardpointsByID[hp.WeaponCategory.ID] = hp;

        //    hp = new HardpointInfo()
        //    {
        //        ID = "Missile",
        //        Visible = true,
        //        AllowOnWeapon = true,
        //        Description = "A 'Mech can mount a limited number of weapons of each type, represented by 'hardpoints.' Missile hardpoints can mount short- and long-range missile systems (SRMs and LRMs).",
        //        TooltipCaption = "Missile Hardpoints"
        //    };
        //    hp.Complete();
        //    HardpointsByName[hp.ID] = hp;
        //    HardpointsByID[hp.WeaponCategory.ID] = hp;

        //    hp = new HardpointInfo()
        //    {
        //        ID = "AntiPersonnel",
        //        Visible = true,
        //        AllowOnWeapon = true,
        //        Description = "A 'Mech can mount a limited number of weapons of each type, represented by 'hardpoints.' Support weapon hardpoints can mount antipersonnel weapon systems, including the Small Laser, Machine Gun, and Flamer.",
        //        TooltipCaption = "Support Weapon Hardpoints"
        //    };
        //    hp.Complete();
        //    HardpointsByName[hp.ID] = hp;
        //    HardpointsByID[hp.WeaponCategory.ID] = hp;

        //    hp = new HardpointInfo()
        //    {
        //        ID = "AMS",
        //        Visible = false,
        //        AllowOnWeapon = true,
        //        AllowOmni = false
        //    };
        //    hp.Complete();
        //    HardpointsByName[hp.ID] = hp;
        //    HardpointsByID[hp.WeaponCategory.ID] = hp;

        //    hp = new HardpointInfo()
        //    {
        //        ID = "Melee",
        //        Visible = false,
        //        AllowOnWeapon = true,
        //        AllowOmni = false
        //    };
        //    hp.Complete();
        //    HardpointsByName[hp.ID] = hp;
        //    HardpointsByID[hp.WeaponCategory.ID] = hp;

        //}

        public HardpointInfo this[WeaponCategoryValue wc] => wc == null ? null : this[wc.Name];
Exemplo n.º 9
0
        // see EffectsManager.GetTargetComponents for order and logic
        internal static bool IsStatusEffectAffectingWeapon(StatisticEffectData statisticData, WeaponSubType subType, WeaponType type, WeaponCategoryValue categoryValue)
        {
            if (statisticData.targetCollection != TargetCollection.Weapon)
            {
                return(false);
            }

            if (statisticData.targetWeaponSubType != WeaponSubType.NotSet)
            {
                return(statisticData.targetWeaponSubType == subType);
            }
            else if (statisticData.targetWeaponType != WeaponType.NotSet)
            {
                return(statisticData.targetWeaponType == type);
            }
            else if (!statisticData.TargetWeaponCategoryValue.Is_NotSet)
            {
                return(statisticData.TargetWeaponCategoryValue.ID == categoryValue.ID);
            }

            return(true);
        }
Exemplo n.º 10
0
        internal static T ModifyWeaponStatistic <T>(StatisticAdapter <T> stat, MechDef mechDef, WeaponSubType subType, WeaponType type, WeaponCategoryValue categoryValue)
        {
            var effects = new List <EffectData>();

            foreach (var componentDef in mechDef.Inventory.Where(x => x.IsFunctionalORInstalling()).Select(x => x.Def))
            {
                if (componentDef.statusEffects == null)
                {
                    continue;
                }

                foreach (var effectData in componentDef.statusEffects)
                {
                    if (effectData.effectType != EffectType.StatisticEffect)
                    {
                        continue;
                    }
                    if (effectData.targetingData.effectTriggerType != EffectTriggerType.Passive ||
                        effectData.targetingData.effectTargetType != EffectTargetType.Creator)
                    {
                        continue;
                    }
                    if (stat.Key != effectData.statisticData.statName)
                    {
                        continue;
                    }
                    if (!IsStatusEffectAffectingWeapon(effectData.statisticData, subType, type, categoryValue))
                    {
                        continue;
                    }
                    effects.Add(effectData);
                }
            }
            OrderedStatusEffectsFeature.Shared.SortEffectDataList(effects);
            foreach (var effect in effects)
            {
                stat.Modify(effect);
            }
            return(stat.Get());
        }
Exemplo n.º 11
0
            public static void Prefix(AbstractActor __instance, ref float incomingDamage, WeaponCategoryValue weaponCategoryValue)
            {
                var mechTags = __instance.GetTags();

                if (mechTags.Contains("BR_MQ_AntiBallisticSleekDesign") && weaponCategoryValue.IsBallistic)
                {
                    incomingDamage *= Core.Settings.AntiBallisticSleekDesignFactor;
                }

                if (__instance.UnitType == UnitType.Mech)
                {
                    var mech = __instance as Mech;
                    if (mech.weightClass == WeightClass.ASSAULT && __instance.GetPilot().pilotDef.PilotTags.Contains("PQ_pilot_elite"))
                    {
                        __instance.StatCollection.Set <float>("CriticalHitChanceReceivedMultiplier", 0.4f);
                    }
                }

                //var CommandConsole = Methods.TeamHasTag(__instance, "BR_MQ_CommandConsole");
                //var AdvancedCommandModule = Methods.TeamHasTag(__instance, "BR_MQ_AdvancedCommandModule");
                //if (CommandConsole || AdvancedCommandModule)
                //{
                //    if (AdvancedCommandModule)
                //        incomingDamage *= Core.Settings.AdvancedCommandModuleFactor;
                //    else
                //        incomingDamage *= Core.Settings.CommandConsoleFactor;
                //}
            }
Exemplo n.º 12
0
 internal HardpointStat(WeaponCategoryValue category)
 {
     Category = category;
 }
Exemplo n.º 13
0
 public static bool isBuildinIcon(this WeaponCategoryValue weaponCat)
 {
     return(UILookAndColorConstantsIcons.Contains(weaponCat.Icon));
 }