Refactored objectType & Charge display, to allow modders to alter Charge information

This commit is contained in:
Wofsauge committed 2022-11-05 17:25:30 +01:00
1 parent 805d57540f
commit 4d60441150
4 files changed
+39 -23

No files matched your search

+20
View File
@@ -392,6 +392,7 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity, checkModifiers)
description.ModName = tableEntry and tableEntry[4]
description.Quality = EID:getObjectQuality(description)
description.Icon = EID:getObjectIcon(description)
EID:getObjectItemTypeAndCharge(description)
if checkModifiers ~= false then
for _,modifier in ipairs(EID.DescModifiers) do
@@ -451,6 +452,25 @@ function EID:mergeDescriptionObjects(oldDescObj, newDescObj)
end
return newDescObj
end
function EID:getObjectItemTypeAndCharge(descObj)
if not (descObj.ObjType == 5 and descObj.ObjVariant == 100 and descObj.ObjSubType ~= nil) then
return
end
local itemConfig = EID.itemConfig:GetCollectible(descObj.ObjSubType)
descObj.ItemType = itemConfig.Type or -1
if descObj.ItemType == ItemType.ITEM_ACTIVE then
descObj.ChargeType = itemConfig.ChargeType or 0
descObj.Charges = itemConfig.MaxCharges or 0
-- Special handling for dynamic charge items
if REPENTANCE and (descObj.ObjSubType == CollectibleType.COLLECTIBLE_BLANK_CARD or descObj.ObjSubType == CollectibleType.COLLECTIBLE_PLACEBO or
descObj.ObjSubType == CollectibleType.COLLECTIBLE_CLEAR_RUNE or descObj.ObjSubType == CollectibleType.COLLECTIBLE_D_INFINITY) then
descObj.ChargeType = ItemConfig.CHARGE_SPECIAL
end
end
end
-- returns the specified object table in the current language.
-- falls back to english if it doesnt exist, unless specified otherwise
function EID:getDescriptionEntry(objTable, objID, noFallback)