public MechlabHardpointHelper(GameObject hpgo, HardpointInfo hpinfo)
        {
            go = hpgo;

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

            Text      = hpgo.GetComponentInChildren <LocalizableText>();
            Icon      = hpgo.GetComponentInChildren <SVGImage>();
            BackImage = hpgo.GetComponent <Image>();

            TextColor = Text.GetComponent <UIColorRefTracker>();
            IconColor = Icon.GetComponent <UIColorRefTracker>();
            Tooltip   = hpgo.GetComponent <HBSTooltip>();

            init(hpinfo.WeaponCategory.GetIcon(), hpinfo.TooltipCaption, hpinfo.Description);
        }
        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);
        }
        public void LoadValue(string value)
        {
            WeaponCategory = WeaponCategoryEnumeration.GetWeaponCategoryByName(value);

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

            if (!WeaponCategory.Is_NotSet)
            {
                HPinfo = HardpointController.Instance[WeaponCategory];
            }
        }
        public void LoadValue(string value)
        {
            Control.LogDebug(DType.Hardpoints, $"UseHardpoint LoadValue for {Def.Description.Id}: {value}");

            var cat = WeaponCategoryEnumeration.GetWeaponCategoryByName(value);

            WeaponCategory = cat ?? WeaponCategoryEnumeration.GetNotSetValue();

            hpInfo = WeaponCategory.Is_NotSet ? null : HardpointController.Instance[WeaponCategory];
            if (hpInfo != null && !hpInfo.AllowOnWeapon)
            {
                Control.LogError($"{Def.Description.Id} use {value} weapon category that cannot be used on weapons");
                hpInfo         = null;
                WeaponCategory = WeaponCategoryEnumeration.GetNotSetValue();
            }

            Control.LogDebug(DType.Hardpoints, $"- {cat.WeaponCategoryID}:{cat.Name}/{cat.FriendlyName}");
        }
Exemplo n.º 5
0
 public HPUsage(HPUsage other, bool reset = false)
 {
     this.hpInfo = other.hpInfo;
     this.Total  = other.Total;
     this.Used   = reset ? 0 : other.Used;
 }
Exemplo n.º 6
0
 public HPUsage(HardpointInfo hp, int total, int used = 0)
 {
     hpInfo = hp;
     Total  = total;
     Used   = used;
 }