Added Multiplayer and multi character support for Transformation progress

This commit is contained in:
Wofsauge committed 2022-03-22 22:31:37 +01:00
1 parent 266867cecc
commit a13ee770c3
2 files changed
+36 -13

No files matched your search

+23 -8
View File
@@ -417,9 +417,8 @@ function EID:getTransformation(id, variant, subType)
local default = EID.EntityTransformations[entityString]
if default~= nil then listToTest = default end
local customLegacy = nil
if id == 5 and variant == 100 then
customLegacy = __eidItemTransformations[adjustedSubtype]
local customLegacy = __eidItemTransformations[adjustedSubtype]
if customLegacy~= nil then listToTest = listToTest..","..customLegacy end
end
@@ -1418,12 +1417,28 @@ EID.TransformationLookup = {}
function EID:buildTransformationTables()
EID.TransformationLookup = {}
for entityString, transformationData in pairs(EID.EntityTransformations) do
for transformation in string.gmatch(transformationData, '([^,]+)') do
if EID.TransformationLookup[transformation] == nil then
EID.TransformationLookup[transformation] = {}
end
EID.TransformationLookup[transformation][entityString] = true
EID:alterTransformationLookup(entityString, transformationData, true)
end
-- legacy
for subType, transformationData in pairs(__eidItemTransformations) do
EID:alterTransformationLookup("5.100."..subType, transformationData, true)
end
-- add custom
for entityString, transformationData in pairs(EID.CustomTransformAssignments) do
EID:alterTransformationLookup(entityString, transformationData, true)
end
-- custom remove
for entityString, transformationData in pairs(EID.CustomTransformRemovals) do
EID:alterTransformationLookup(entityString, transformationData, nil)
end
end
function EID:alterTransformationLookup(entityString, transformString, addToList)
for transformation in string.gmatch(transformString, '([^,]+)') do
if EID.TransformationLookup[transformation] == nil then
EID.TransformationLookup[transformation] = {}
end
EID.TransformationLookup[transformation][entityString] = addToList
end
end
@@ -1442,7 +1457,7 @@ function EID:evaluateTransformationProgress(transformation)
EID.TransformationProgress[i][transformation] = transformData.NumNeeded or 3
else
for entityString, _ in pairs(EID.TransformationLookup[transformation]) do
eType, eVariant, eSubType = entityString:match("([^.]+).([^.]+).([^.]+)")
local eType, eVariant, eSubType = entityString:match("([^.]+).([^.]+).([^.]+)")
if tonumber(eType) == EntityType.ENTITY_PICKUP then
if tonumber(eVariant) == PickupVariant.PICKUP_COLLECTIBLE then
if EID.TouchedActiveItems[i][tonumber(eSubType)] then
+13 -5
View File
@@ -664,14 +664,22 @@ function EID:printDescription(desc, cachedID)
if EID.Config["TransformationText"] or EID.Config["TransformationProgress"] then
local transformationName = ""
if EID.Config["TransformationText"] then
transformationName = EID:getTransformationName(transform).." "
transformationName = EID:getTransformationName(transform)
end
if EID.Config["TransformationProgress"] then
-- TODO: call evaluate only when ItemQueue of player changes to save performance
EID:evaluateTransformationProgress(transform)
local numCollected = EID.TransformationProgress[EID:getPlayerID(EID.player)][transform]
local numMax = EID.TransformationData[transform] and EID.TransformationData[transform].NumNeeded or 3
transformationName = transformationName.."("..numCollected.."/"..numMax..")"
transformationName = transformationName .. " "
for _, player in ipairs(EID.players) do
if player:GetPlayerType() ~= PlayerType.PLAYER_THESOUL_B then
if #EID.players > 1 then
local playerIcon = EID:getIcon("Player"..player.SubType) ~= EID.InlineIcons["ERROR"] and "{{Player"..player.SubType.."}}" or "{{CustomTransformation}}"
transformationName = transformationName .. playerIcon
end
local numCollected = EID.TransformationProgress[EID:getPlayerID(player)][transform]
local numMax = EID.TransformationData[transform] and EID.TransformationData[transform].NumNeeded or 3
transformationName = transformationName.."("..numCollected.."/"..numMax..") "
end
end
end
local iconWidth = transformSprite[3] or -1
local iconHeight = transformSprite[4] or -1