Beispiel #1
0
        protected void UpdateOverheatBox(double val, double minVal)
        {
            if (!vessel.isActiveVessel)
            {
                overheatBox = null;
                return;
            }

            if (val >= (minVal - 0.00001d))
            {
                if (overheatBox == null)
                {
                    overheatBox = part.stackIcon.DisplayInfo();
                    overheatBox.SetMsgBgColor(XKCDColors.DarkRed.A(0.6f));
                    overheatBox.SetMsgTextColor(XKCDColors.OrangeYellow.A(0.6f));
                    overheatBox.SetMessage("Eng. Int.");
                    overheatBox.SetProgressBarBgColor(XKCDColors.DarkRed.A(0.6f));
                    overheatBox.SetProgressBarColor(XKCDColors.OrangeYellow.A(0.6f));
                }
                double scalar   = 1d / (1d - minVal);
                double scaleFac = 1f - scalar;
                float  gaugeMin = (float)(scalar * minVal + scaleFac);
                overheatBox.SetValue(Mathf.Clamp01((float)(val * scalar + scaleFac)), gaugeMin, 1.0f);
            }
            else
            {
                if (overheatBox != null)
                {
                    part.stackIcon.RemoveInfo(overheatBox);
                    overheatBox = null;
                }
            }
        }
Beispiel #2
0
 public void UpdateAmmoMeter(float ammoLevel)
 {
     if (BDArmorySettings.SHOW_AMMO_GAUGES && !BDArmorySettings.INFINITE_AMMO)
     {
         if (ammoLevel > 0)
         {
             if (emptyGauge != null)
             {
                 ForceRedraw();
             }
             if (ammoGauge == null)
             {
                 ammoGauge = InitAmmoGauge(AmmoName);
             }
             ammoGauge?.SetValue(ammoLevel, 0, 1);
         }
         else
         {
             if (ammoGauge != null)
             {
                 ForceRedraw();
             }
             if (emptyGauge == null)
             {
                 emptyGauge = InitEmptyGauge();
                 emptyGauge?.SetValue(1, 0, 1);
             }
         }
     }
     else if (ammoGauge != null || emptyGauge != null)
     {
         ForceRedraw();
     }
 }
Beispiel #3
0
 private void ForceRedraw()
 {
     part.stackIcon.ClearInfoBoxes();
     //null everything so other gauges will perperly re-initialize post ClearinfoBoxes()
     ammoGauge  = null;
     heatGauge  = null;
     reloadBar  = null;
     emptyGauge = null;
 }
Beispiel #4
0
 /// <param name="heatLevel">0 is no heat, 1 is max heat</param>
 public void UpdateHeatMeter(float heatLevel)
 {
     //heat
     if (heatLevel > (1f / 3))
     {
         if (heatGauge == null)
         {
             heatGauge = InitHeatGauge();
         }
         heatGauge?.SetValue((heatLevel * 3 - 1) / 2, 0, 1);    //null check
     }
     else if (heatGauge != null && heatLevel < 0.25f)
     {
         ForceRedraw();
     }
 }
Beispiel #5
0
        private ProtoStageIconInfo InitEmptyGauge() //could remove emptygauge, mainly a QoL thing, removal might increase performance slightly
        {
            EnsureStagingIcon();
            ProtoStageIconInfo g = part.stackIcon.DisplayInfo();

            // fix nullref if no stackicon exists
            if (g != null)
            {
                g.SetMsgBgColor(XKCDColors.AlmostBlack);
                g.SetMsgTextColor(XKCDColors.Yellow);
                g.SetMessage(Localizer.Format("#LOC_BDArmory_ProtoStageIconInfo_AmmoOut"));//"Ammo Depleted"
                g.SetProgressBarBgColor(XKCDColors.Yellow);
                g.SetProgressBarColor(XKCDColors.Black);
            }
            return(g);
        }
Beispiel #6
0
        private ProtoStageIconInfo InitHeatGauge() //thanks DYJ
        {
            EnsureStagingIcon();
            ProtoStageIconInfo v = part.stackIcon.DisplayInfo();

            // fix nullref if no stackicon exists
            if (v != null)
            {
                v.SetMsgBgColor(XKCDColors.DarkRed);
                v.SetMsgTextColor(XKCDColors.Orange);
                v.SetMessage(Localizer.Format("#LOC_BDArmory_ProtoStageIconInfo_Overheat"));//"Overheat"
                v.SetProgressBarBgColor(XKCDColors.DarkRed);
                v.SetProgressBarColor(XKCDColors.Orange);
            }
            return(v);
        }
Beispiel #7
0
        private ProtoStageIconInfo InitAmmoGauge(string ammoName) //thanks DYJ
        {
            EnsureStagingIcon();
            ProtoStageIconInfo a = part.stackIcon.DisplayInfo();

            // fix nullref if no stackicon exists
            if (a != null)
            {
                a.SetMsgBgColor(XKCDColors.Grey);
                a.SetMsgTextColor(XKCDColors.Yellow);
                //a.SetMessage("Ammunition");
                a.SetMessage($"{ammoName}");
                a.SetProgressBarBgColor(XKCDColors.DarkGrey);
                a.SetProgressBarColor(XKCDColors.Yellow);
            }
            return(a);
        }
Beispiel #8
0
        private ProtoStageIconInfo InitReloadBar()
        {
            EnsureStagingIcon();
            ProtoStageIconInfo v = part.stackIcon.DisplayInfo();

            if (v == null)
            {
                return(v);
            }
            v.SetMsgBgColor(XKCDColors.DarkGrey);
            v.SetMsgTextColor(XKCDColors.White);
            v.SetMessage(Localizer.Format("#LOC_BDArmory_ProtoStageIconInfo_Reloading"));//"Reloading"
            v.SetProgressBarBgColor(XKCDColors.DarkGrey);
            v.SetProgressBarColor(XKCDColors.Silver);

            return(v);
        }
        private ProtoStageIconInfo InitReloadBar()
        {
            EnsureStagingIcon();
            ProtoStageIconInfo v = part.stackIcon.DisplayInfo();

            if (v == null)
            {
                return(v);
            }
            v.SetMsgBgColor(XKCDColors.DarkGrey);
            v.SetMsgTextColor(XKCDColors.White);
            v.SetMessage("Reloading");
            v.SetProgressBarBgColor(XKCDColors.DarkGrey);
            v.SetProgressBarColor(XKCDColors.Silver);

            return(v);
        }
Beispiel #10
0
 /// <param name="reloadProgress">0 is just fired, 1 is just reloaded</param>
 public void UpdateReloadMeter(float reloadRemaining)
 {
     if (reloadRemaining < 1)
     {
         if (reloadBar == null)
         {
             reloadBar = InitReloadBar();
             if (ReloadAudioClip)
             {
                 AudioSource.PlayOneShot(ReloadAudioClip);
             }
         }
         reloadBar?.SetValue(reloadRemaining, 0, 1);
     }
     else if (reloadBar != null)
     {
         ForceRedraw();
         if (ReloadCompleteAudioClip)
         {
             AudioSource.PlayOneShot(ReloadCompleteAudioClip);
         }
     }
 }
Beispiel #11
0
        void UpdateReloadMeter()
        {
            if(Time.time-timeFired < (60/roundsPerMinute) && Time.time-timeFired > 0.1f)
            {
                if(reloadBar == null)
                {
                    reloadBar = InitReloadBar();
                    if(reloadAudioClip)
                    {
                        audioSource.PlayOneShot(reloadAudioClip);
                    }
                }
                reloadBar.SetValue(Time.time-timeFired, 0, 60/roundsPerMinute);
            }
            else if(reloadBar != null)
            {
                part.stackIcon.ClearInfoBoxes();
                reloadBar = null;
                if(reloadCompleteAudioClip)
                {
                    audioSource.PlayOneShot(reloadCompleteAudioClip);
                }

            }
        }
Beispiel #12
0
 void UpdateHeatMeter()
 {
     //heat
     if(heat > maxHeat/3)
     {
         if(heatGauge == null)
         {
             heatGauge = InitHeatGauge();
         }
         heatGauge.SetValue(heat, maxHeat/3, maxHeat);
     }
     else if(heatGauge != null && heat < maxHeat/4)
     {
         part.stackIcon.ClearInfoBoxes();
         heatGauge = null;
     }
 }
 protected void UpdateOverheatBox(double val, double minVal)
 {
     if (val >= (minVal - 0.00001d))
     {
         if (overheatBox == null)
         {
             overheatBox = part.stackIcon.DisplayInfo();
             overheatBox.SetMsgBgColor(XKCDColors.DarkRed.A(0.6f));
             overheatBox.SetMsgTextColor(XKCDColors.OrangeYellow.A(0.6f));
             overheatBox.SetMessage("Eng. Int.");
             overheatBox.SetProgressBarBgColor(XKCDColors.DarkRed.A(0.6f));
             overheatBox.SetProgressBarColor(XKCDColors.OrangeYellow.A(0.6f));
         }
         double scalar = 1d / (1d - minVal);
         double scaleFac = 1f - scalar;
         float gaugeMin = (float)(scalar * minVal + scaleFac);
         overheatBox.SetValue(Mathf.Clamp01((float)(val * scalar + scaleFac)), gaugeMin, 1.0f);
     }
     else
     {
         if (overheatBox != null)
         {
             part.stackIcon.RemoveInfo(overheatBox);
             overheatBox = null;
         }
     }
 }