Rework Unidentified Pill eval, to allow Description modifiers when unidentified

This commit is contained in:
Wofsauge committed 2023-10-08 16:54:53 +02:00
1 parent 34b7c2a8dc
commit c3c8710617
2 files changed
+33 -18

No files matched your search

+18 -12
View File
@@ -395,18 +395,7 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity, checkModifiers)
EID:getObjectItemTypeAndCharge(description)
if checkModifiers ~= false then
for _,modifier in ipairs(EID.DescModifiers) do
local result = modifier.condition(description)
if type(result) == "table" then
for _,callback in ipairs(result) do
-- If the modifier loads a different description obj (which also goes through the modifier checks), we should stop our checks so text doesn't get printed twice
if description.ObjSubType ~= SubType then break end
description = callback(description)
end
elseif result then
description = modifier.callback(description)
end
end
description = EID:applyDescriptionModifier(description, SubType)
end
return description
end
@@ -429,6 +418,23 @@ function EID:getLegacyModDescription(Type, Variant, SubType)
return nil
end
-- apply Description Modifier to a given description object
function EID:applyDescriptionModifier(description, SubType)
for _,modifier in ipairs(EID.DescModifiers) do
local result = modifier.condition(description)
if type(result) == "table" then
for _,callback in ipairs(result) do
-- If the modifier loads a different description obj (which also goes through the modifier checks), we should stop our checks so text doesn't get printed twice
if description.ObjSubType ~= SubType then break end
description = callback(description)
end
elseif result then
description = modifier.callback(description)
end
end
return description
end
-- Returns the icon and mod name of a given EID description object as a preformatted description string
function EID:getModNameString(descObj)
local modString = ""
+15 -6
View File
@@ -813,12 +813,21 @@ function EID:renderUnidentifiedPill(entity)
table.insert(EID.CachedIcons, {})
table.insert(EID.CachedRenderPoses, Vector(pos.X, pos.Y))
end
EID:renderString(
"{{Pill"..pillColor.."}} "..EID:getDescriptionEntry("unidentifiedPill"),
pos,
Vector(EID.Scale, EID.Scale),
EID:getErrorColor()
)
local descriptionObj = EID:getDescriptionObj(entity.Type, entity.Variant, entity.SubType, entity, false)
descriptionObj.Name = EID:getDescriptionEntry("unidentifiedPill")
descriptionObj.Description = ""
descriptionObj.ShowWhenUnidentified = false
descriptionObj = EID:applyDescriptionModifier(descriptionObj, -999)
if EID.Config["ShowItemIcon"] then
descriptionObj.Name = "{{Pill"..pillColor.."}} "..descriptionObj.Name
end
EID:renderString(descriptionObj.Name, pos + Vector(0,-1), Vector(EID.Scale, EID.Scale), EID:getErrorColor())
if EID.Config["ShowItemDescription"] and descriptionObj.ShowWhenUnidentified then
pos.Y = pos.Y + EID.lineHeight * EID.Scale
EID:printBulletPoints(descriptionObj.Description, pos)
end
end
-- RGB colors for each player's highlights (Red, Blue, Green, Yellow)