-local registerEvents = M.RegisterEvents;
-
-local function updateHealth(frame, unit)
- local current, max = UnitHealth(unit), frame.health.max;
- frame.health:Show();
- -- sanity check, occasionally UnitHealthMax gives zero
- if current > max then
- -- somehow current health has gone over the maximum (missed maxhealth event)
- frame.health.max = UnitHealthMax(unit);
- max = frame.health.max;
- if current > max then
- -- error state, still over maximum
- frame.health:SetWidth(width);
- return;
- end
- elseif max > 0 then
- frame.health:SetWidth(current/frame.health.max*width);
- else
- frame.health:SetWidth(width);
- return;
- end
-
- if UnitIsDeadOrGhost(unit) then
- frame.health:Hide();
- end
-end