Back to Home

ESO Lua File v101041

ingame/stuck/stuck_manager.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
ZO_STUCK_NAME = "Stuck"
local Stuck_Manager = ZO_Object:Subclass()
function Stuck_Manager:New(...)
    local stuck = ZO_Object.New(self)
    stuck:Initialize(...)
    return stuck
end
function Stuck_Manager:Initialize()
    -- this is a check for bringing up a dialog after /reloadui and still being stuck
    local function OnPlayerActivated()
        self:SetActiveSystem()
        self.activeSystem:OnPlayerActivated()
    end
    local function OnStuckBegin()
        self:SetActiveSystem()
        self.activeSystem:OnStuckBegin()
    end
    -- keep the same active system for cancel / complete, as we don't want to orphan dialogs from a different platform
    local function OnStuckCanceled()
        self.activeSystem:OnStuckCanceled()
    end
    local function OnStuckComplete()
        self.activeSystem:OnStuckComplete()
    end
    -- use SYSTEMS for the errors, as PC handles them within the chat event handler, and gamepad handles them with dialogs that can be closed
    -- using the active system here causes a bunch of issues if the user runs gamepad unstuck -> PC unstuck, as PC stuck doesn't run through the stuck manager
    local function OnStuckErrorAlreadyInProgress()        
        SYSTEMS:GetObject(ZO_STUCK_NAME):OnStuckErrorAlreadyInProgress()
    end
    local function OnStuckErrorInvalidLocation()
        SYSTEMS:GetObject(ZO_STUCK_NAME):OnStuckErrorInvalidLocation()
    end
    local function OnStuckErrorInCombat()
        SYSTEMS:GetObject(ZO_STUCK_NAME):OnStuckErrorInCombat()
    end
    local function OnStuckErrorOnCooldown()
        SYSTEMS:GetObject(ZO_STUCK_NAME):OnStuckErrorOnCooldown()
    end
    EVENT_MANAGER:RegisterForEvent(ZO_STUCK_NAME, EVENT_PLAYER_ACTIVATED, function() OnPlayerActivated() end)
    EVENT_MANAGER:RegisterForEvent(ZO_STUCK_NAME, EVENT_STUCK_BEGIN, function() OnStuckBegin() end)
    EVENT_MANAGER:RegisterForEvent(ZO_STUCK_NAME, EVENT_STUCK_CANCELED, function() OnStuckCanceled() end)
    EVENT_MANAGER:RegisterForEvent(ZO_STUCK_NAME, EVENT_STUCK_COMPLETE, function() OnStuckComplete() end)
    EVENT_MANAGER:RegisterForEvent(ZO_STUCK_NAME, EVENT_STUCK_ERROR_ALREADY_IN_PROGRESS, function() OnStuckErrorAlreadyInProgress() end)
    EVENT_MANAGER:RegisterForEvent(ZO_STUCK_NAME, EVENT_STUCK_ERROR_INVALID_LOCATION, function() OnStuckErrorInvalidLocation() end)
    EVENT_MANAGER:RegisterForEvent(ZO_STUCK_NAME, EVENT_STUCK_ERROR_IN_COMBAT, function() OnStuckErrorInCombat() end)
    EVENT_MANAGER:RegisterForEvent(ZO_STUCK_NAME, EVENT_STUCK_ERROR_ON_COOLDOWN, function() OnStuckErrorOnCooldown() end)
end
function Stuck_Manager:SetActiveSystem()
    self.activeSystem = SYSTEMS:GetObject(ZO_STUCK_NAME)
end
ZO_STUCK_MANAGER = Stuck_Manager:New()