Back to Home

ESO Lua File v100035

ingame/companion/companion_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
67
68
69
70
71
72
73
74
75
76
77
-----------------------------
-- Companion Manager
-----------------------------
ZO_Companion_Manager = ZO_InitializingCallbackObject:Subclass()
function ZO_Companion_Manager:Initialize()
    self.companionSceneNameSet = {}
    self.companionInteraction =
    {
        type = "Companion",
        interactTypes = { INTERACTION_COMPANION_MENU },
        OnInteractionCanceled = function()
            -- we want to abort like vanilla interactions, but because vanilla
            -- interactions are tied to individual scenes we need to instead gate
            -- on _any_ companion interaction
            local currentSceneName = SCENE_MANAGER:GetCurrentSceneName()
            if self.companionSceneNameSet[currentSceneName] and SCENE_MANAGER:IsShowing(currentSceneName) then
                SCENE_MANAGER:RequestShowLeaderBaseScene(ZO_BHSCR_INTERACT_ENDED)
            end
        end,
    }
    -- Shared search for companion equipment
    local filterTargetDescriptor =
    {
        [BACKGROUND_LIST_FILTER_TARGET_BAG_SLOT] =
        {
            searchFilterList =
            {
                BACKGROUND_LIST_FILTER_TYPE_NAME,
            },
            primaryKeys =
            {
                BAG_BACKPACK,
                BAG_COMPANION_WORN,
            }
        },
    }
    TEXT_SEARCH_MANAGER:SetupContextTextSearch("companionEquipmentTextSearch", filterTargetDescriptor)
end
function ZO_Companion_Manager:CreateInteractScene(newSceneName)
    local newScene = ZO_InteractScene:New(newSceneName, SCENE_MANAGER, self.companionInteraction)
    self.companionSceneNameSet[newSceneName] = true
    return newScene
end
function ZO_Companion_Manager:GetLevelInfo()
    --The companion's current level and the amount of experience the companion has earned at that level
    local level, currentXpInLevel = GetActiveCompanionLevelInfo()
    --The total amount of experience required to go from the current level to the next
    local totalXpInLevel = GetNumExperiencePointsInCompanionLevel(level + 1) or 0
    local isMaxLevel = totalXpInLevel == 0
    return level, currentXpInLevel, totalXpInLevel, isMaxLevel
end
function ZO_Companion_Manager:GetActiveCompanionIcon()
    local companionId = GetActiveCompanionDefId()
    local collectibleId = GetCompanionCollectibleId(companionId)
    return GetCollectibleIcon(collectibleId)
end
function ZO_Companion_Manager:GetActiveCompanionPassivePerkAbilityId()
    local companionId = GetActiveCompanionDefId()
    return GetCompanionPassivePerkAbilityId(companionId)
end
ZO_COMPANION_MANAGER = ZO_Companion_Manager:New()
    return HasActiveCompanion() or HasBlockedCompanion()
end