Back to Home

ESO Lua File v100023

ingame/map/worldmaphouses_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
-- Singleton shared data
ZO_MapHousesData_Manager = ZO_Object:Subclass()
function ZO_MapHousesData_Manager:New(...)
    local singleton = ZO_Object.New(self)
    singleton:Initialize(...)
    return singleton
end
function ZO_MapHousesData_Manager:Initialize()
    self.houseMapData = {}
end
do
    local function HouseMapDataSort(lhs, rhs)
        if lhs.unlocked == rhs.unlocked then
            return lhs.houseName < rhs.houseName
        else
            return lhs.unlocked
        end
    end
    function ZO_MapHousesData_Manager:RefreshHouseList()
        local houseMapData = self.houseMapData
        ZO_ClearNumericallyIndexedTable(houseMapData)
        for nodeIndex = 1, GetNumFastTravelNodes() do
            local known, name, _, _, _, _, poiType = GetFastTravelNodeInfo(nodeIndex)
            if known and poiType == POI_TYPE_HOUSE then
                local houseId = GetFastTravelNodeHouseId(nodeIndex)
                if houseId ~= 0 then
                    local foundInZoneId = GetHouseFoundInZoneId(houseId)
                    local mapIndex = GetMapIndexByZoneId(foundInZoneId)
                    if mapIndex then
                        local houseCollectibleId = GetCollectibleIdForHouse(houseId)
                        local houseCollectibleData = ZO_COLLECTIBLE_DATA_MANAGER:GetCollectibleDataById(houseCollectibleId)
                        local houseData =
                        {
                            houseId = houseId,
                            houseName = houseCollectibleData:GetFormattedName(),
                            foundInZoneName = houseCollectibleData:GetFormattedHouseLocation(),
                            unlocked = houseCollectibleData:IsUnlocked(),
                            mapIndex = mapIndex,
                            nodeIndex = nodeIndex,
                        }
                        table.insert(houseMapData, houseData)
                    end
                end
            end
        end
        table.sort(houseMapData, HouseMapDataSort)
    end
end
function ZO_MapHousesData_Manager:GetHouseList()
    return self.houseMapData
end
WORLD_MAP_HOUSES_DATA = ZO_MapHousesData_Manager:New()