Back to Home

ESO Lua File v101042

ingame/uicombatoverlay/uicombatoverlay.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
local UICombatOverlay = ZO_Object:Subclass()
function UICombatOverlay:New(control)
    local overlay = ZO_Object.New(self)
    overlay.show = false
    overlay.control = GetControl(control, "Overlay")
    overlay.pulseTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_UICombatOverlayAnimation", overlay.control)
    overlay.fadeOutTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_UICombatOverlayFadeOut", overlay.control)
    local function Refresh()
        overlay:Refresh()
    end
    control:RegisterForEvent(EVENT_PLAYER_COMBAT_STATE, Refresh)
    control:RegisterForEvent(EVENT_PLAYER_DEAD, Refresh)
    control:RegisterForEvent(EVENT_PLAYER_ALIVE, Refresh)
    control:RegisterForEvent(EVENT_PLAYER_ACTIVATED, Refresh)
    return overlay
end
function UICombatOverlay:Refresh()
    local show = IsUnitInCombat("player") and not IsUnitDead("player")
    if(show ~= self.show) then
        self.show = show 
        
        if(show) then
            self.fadeOutTimeline:Stop()
            self.control:SetHidden(false)
            self.pulseTimeline:PlayFromStart()
        else
            self.pulseTimeline:Stop()
            self.fadeOutTimeline:PlayFromStart()
        end
    end
end
    UICombatOverlay:New(control)
end