--
-- Originally was Boss HUD rendering code.
-- (c) Inuyasha 2014.
-- Permissionwas granted by Inuyasha to use this code
-- and the associated graphics in other mods.
--
local function hud_draw(v, player)
        local notboostfill = 0;
        local notboostcap = 0;
        local feeltheheat = 0;
 
        -- Iterate through all thinkers for bosses
			if player.mo and (player.mo.skin == "greeneyesonic")
			and player.powers[pw_carry] != CR_NIGHTSMODE
					notboostcap = $1 + 40
					notboostfill = $1 + player.notboostmeter
					feeltheheat = $1 + player.feelingheat
			end
 
        local p_startseg = v.cachePatch("METRENDL")
        local p_onseg    = v.cachePatch("METRMIDL")
        local p_offseg   = v.cachePatch("METRMPTY")
        local p_endseg   = v.cachePatch("METRENDR")
        local p_heat     = v.cachePatch("METRHEAT")
 
        local posx = 320 - 26
        local posy = 176
 
        -- Ending segment first
        if player.mo and (player.mo.skin == "greeneyesonic")
		and player.powers[pw_carry] != CR_NIGHTSMODE
        v.draw(posx, posy, p_endseg, V_SNAPTOBOTTOM|V_SNAPTORIGHT)
        posx = $1 - 1
 
        -- Step through backwards, to match the way we're drawing.
        for i = notboostcap, 1, -1
                if notboostfill >= i
                        v.draw(posx, posy, p_onseg, V_SNAPTOBOTTOM|V_SNAPTORIGHT)
                else
                        v.draw(posx, posy, p_offseg, V_SNAPTOBOTTOM|V_SNAPTORIGHT)
                end
                posx = $1 - 1;
        end
       
        if feeltheheat == 1
                v.draw(260, 176, p_heat, V_SNAPTOBOTTOM|V_SNAPTORIGHT)
        end
 
        -- Start segment
        v.draw(posx, posy, p_startseg, V_SNAPTOBOTTOM|V_SNAPTORIGHT);
end
end
hud.add(hud_draw)