public void Draw(SpriteBatch spriteBatch)
 {
     if (_currentBar != null)
     {
         _currentBar.Draw(_info, spriteBatch);
     }
 }
Exemplo n.º 2
0
        public override bool PreventDraw => true;         //Prevents the default drawing code

        public override void Draw(SpriteBatch spriteBatch, IBigProgressBar currentBar, BigProgressBarInfo info)
        {
            if (currentBar == null)
            {
                return;
                //Only draw if vanilla decided to draw one (we let it update because we didn't override PreventUpdate to return true)
            }

            if (currentBar is CommonBossBigProgressBar)
            {
                //If this is a regular bar without any special features, we draw our own thing. Sadly, "life to display" is not a variable we can access,
                //but since we are dealing with the very basic implementation that only tracks a single NPC, we can use "info"

                NPC   npc         = Main.npc[info.npcIndexToAimAt];
                float lifePercent = Utils.Clamp(npc.life / (float)npc.lifeMax, 0f, 1f);

                //Unused method by vanilla, which simply draws a few boxes that represent a boss bar (fixed position, colors, no icon)
                BigProgressBarHelper.DrawBareBonesBar(spriteBatch, lifePercent);
            }
            else
            {
                //If a bar with special behavior is currently selected, draw it instead because we don't have access to its special features

                currentBar.Draw(ref info, spriteBatch);
            }
        }