Rework Unidentified Pill eval, to allow Description modifiers when unidentified
This commit is contained in:
1 parent
34b7c2a8dc
commit
c3c8710617
2 files changed
+33
-18
No files matched your search
+18
-12
@@ -395,18 +395,7 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity, checkModifiers)
|
|||||||
EID:getObjectItemTypeAndCharge(description)
|
EID:getObjectItemTypeAndCharge(description)
|
||||||
|
|
||||||
if checkModifiers ~= false then
|
if checkModifiers ~= false then
|
||||||
for _,modifier in ipairs(EID.DescModifiers) do
|
description = EID:applyDescriptionModifier(description, SubType)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
return description
|
return description
|
||||||
end
|
end
|
||||||
@@ -429,6 +418,23 @@ function EID:getLegacyModDescription(Type, Variant, SubType)
|
|||||||
return nil
|
return nil
|
||||||
end
|
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
|
-- Returns the icon and mod name of a given EID description object as a preformatted description string
|
||||||
function EID:getModNameString(descObj)
|
function EID:getModNameString(descObj)
|
||||||
local modString = ""
|
local modString = ""
|
||||||
|
|||||||
@@ -813,12 +813,21 @@ function EID:renderUnidentifiedPill(entity)
|
|||||||
table.insert(EID.CachedIcons, {})
|
table.insert(EID.CachedIcons, {})
|
||||||
table.insert(EID.CachedRenderPoses, Vector(pos.X, pos.Y))
|
table.insert(EID.CachedRenderPoses, Vector(pos.X, pos.Y))
|
||||||
end
|
end
|
||||||
EID:renderString(
|
|
||||||
"{{Pill"..pillColor.."}} "..EID:getDescriptionEntry("unidentifiedPill"),
|
local descriptionObj = EID:getDescriptionObj(entity.Type, entity.Variant, entity.SubType, entity, false)
|
||||||
pos,
|
descriptionObj.Name = EID:getDescriptionEntry("unidentifiedPill")
|
||||||
Vector(EID.Scale, EID.Scale),
|
descriptionObj.Description = ""
|
||||||
EID:getErrorColor()
|
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
|
end
|
||||||
|
|
||||||
-- RGB colors for each player's highlights (Red, Blue, Green, Yellow)
|
-- RGB colors for each player's highlights (Red, Blue, Green, Yellow)
|
||||||
|
|||||||
Reference in new issue
Block a user