Beispiel #1
0
        private static Color[] LerpWeaponColours(UIColorRefs ui)
        {
            if (Settings.SaturationOfLoadout <= 0)
            {
                return(new Color[0]);
            }
            Color[] colours = new Color[] { Color.clear, ui.ballisticColor, ui.energyColor, ui.missileColor, ui.smallColor };
            float   saturation = (float)Settings.SaturationOfLoadout, lower = saturation * 0.8f;

            for (int i = colours.Length - 1; i > 0; i--)
            {
                Color.RGBToHSV(colours[i], out float h, out float s, out float v);
                colours[i] = Color.HSVToRGB(h, i == 3 ? lower : saturation, 1);
            }
            return(colours);
        }
Beispiel #2
0
        public static void EnhanceWeaponLoadout(CombatHUDTargetingComputer __instance, List <TMPro.TextMeshProUGUI> ___weaponNames, UIManager ___uiManager)
        {
            try {
                UIColorRefs   colours = ___uiManager.UIColorRefs;
                AbstractActor actor   = __instance.ActivelyShownCombatant as AbstractActor;
                List <Weapon> weapons = actor?.Weapons;
                if (actor == null || weapons == null || colours == null)
                {
                    return;
                }
                if (ByType == null)
                {
                    ByType = LerpWeaponColours(colours);
                    DisableLoadoutLineWrap(___weaponNames);
                }
                float close = 0, medium = 0, far = 0;
                for (int i = Math.Min(___weaponNames.Count, weapons.Count) - 1; i >= 0; i--)
                {
                    Weapon w = weapons[i];
                    if (w == null || !w.CanFire)
                    {
                        continue;
                    }
                    float damage = w.DamagePerShot * w.ShotsWhenFired;
                    if (Settings.ShowDamageInLoadout)
                    {
                        ___weaponNames[i].text = ___weaponNames[i].text.Replace(" +", "+") + MetaColour + " (" + damage + ")";
                    }
                    if (ByType.Length > 0 && ___weaponNames[i].color == colours.qualityA)
                    {
                        if ((int)w.Category < ByType.Length)
                        {
                            ___weaponNames[i].color = ByType[(int)w.Category];
                        }
                    }
                    if (w.MaxRange <= 90)
                    {
                        close += damage;
                    }
                    else if (w.MaxRange <= 360)
                    {
                        medium += damage;
                    }
                    else
                    {
                        far += damage;
                    }
                }

                if (Settings.ShowAlphaDamageInLoadout != null && HasDamageLabel(colours.white))
                {
                    loadout.text = string.Format(Settings.ShowAlphaDamageInLoadout, close + medium + far, close, medium, far, medium + far);
                }

                if (Settings.ShowMeleeDamageInLoadout && actor is Mech mech)
                {
                    int    start = weapons.Count, dmg = (int)(mech.MeleeWeapon?.DamagePerShot * mech.MeleeWeapon?.ShotsWhenFired);
                    string format = Settings.ShowDamageInLoadout ? "{0} {1}({2})" : "{0} {1}{2}";
                    if (start < ___weaponNames.Count && dmg > 0)
                    {
                        SetWeapon(___weaponNames[start], colours.white, format, Translate("Melee"), MetaColour, dmg);
                    }
                    dmg = (int)(mech.DFAWeapon?.DamagePerShot * mech.DFAWeapon?.ShotsWhenFired);
                    if (actor.WorkingJumpjets > 0 && start + 1 < ___weaponNames.Count && dmg > 0)
                    {
                        SetWeapon(___weaponNames[start + 1], colours.white, format, Translate("DFA"), MetaColour, dmg);
                    }
                }
            }                 catch (Exception ex) { Error(ex); }
        }