예제 #1
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);
            }
        }
예제 #2
0
        public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
        {
            //Questionmark icon as fallback
            Rectangle?iconFrame   = null;
            Texture2D iconTexture = (GetIconTexture(ref iconFrame) ?? TextureAssets.NpcHead[0]).Value;

            iconFrame ??= iconTexture.Frame();

            //TML handles modifying draw parameters inside of it
            BigProgressBarHelper.DrawFancyBar(spriteBatch, lifePercent, iconTexture, iconFrame.Value, shieldPercent);
        }