When trying to access the UIInfo of an InventoryItemComponent via the ItemAttributeCollection it is null. You are able to get the collection instance, but inside no data appears to be present. Other collection info like GetCommonType return their default values. I would assume this is a bug because the information is otherwise known.
What I tried:
static UIInfo GetUIInfo(ResourceName prefab) { UIInfo resultInfo; Resource resource = Resource.Load(prefab); if (resource && resource.IsValid()) { IEntitySource entitySource = resource.GetResource().ToEntitySource(); if (entitySource) { for(int nComponent, componentCount = entitySource.GetComponentCount(); nComponent < componentCount; nComponent++) { IEntityComponentSource componentSource = entitySource.GetComponent(nComponent); if(componentSource.GetClassName().ToType().IsInherited(InventoryItemComponent)) { ItemAttributeCollection itemAttributes; componentSource.Get("Attributes", itemAttributes); Print(itemAttributes); if (itemAttributes) { BaseItemAttributeData data = itemAttributes.FindAttribute(UIInfo); Print(data); ECommonItemType type = itemAttributes.GetCommonType(); Print(type); resultInfo = itemAttributes.GetUIInfo(); Print(resultInfo); if (resultInfo) break; } } } } } return resultInfo; }
SCRIPT : ItemAttributeCollection itemAttributes = SCR_ItemAttributeCollection<0x0000025C39B43AB0>
SCRIPT : BaseItemAttributeData data = NULL
SCRIPT : int type = 0
SCRIPT : UIInfo resultInfo = NULL
When I manually navigate to the source information of the UIInfo however I am able to read the data just fine:
IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(Resource.Load(prefab)); if (entitySource) { for(int nComponent, componentCount = entitySource.GetComponentCount(); nComponent < componentCount; nComponent++) { IEntityComponentSource componentSource = entitySource.GetComponent(nComponent); if(componentSource.GetClassName().ToType().IsInherited(InventoryItemComponent)) { BaseContainer attributesContainer = componentSource.GetObject("Attributes"); if (attributesContainer) { BaseContainer itemDisplayNameContainer = attributesContainer.GetObject("ItemDisplayName"); if (itemDisplayNameContainer) { string name, description; ResourceName icon; itemDisplayNameContainer.Get("Name", name); itemDisplayNameContainer.Get("Description", description); itemDisplayNameContainer.Get("Icon", icon); // DATA IS VALID HERE YAAAY break; } } } } }
Using BaseContainerTools.CreateInstanceFromContainer sadly also does not work this this. An instance is returned but it has no values.
IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(Resource.Load(prefab)); if (entitySource) { for(int nComponent, componentCount = entitySource.GetComponentCount(); nComponent < componentCount; nComponent++) { IEntityComponentSource componentSource = entitySource.GetComponent(nComponent); if(componentSource.GetClassName().ToType().IsInherited(InventoryItemComponent)) { BaseContainer attributesContainer = componentSource.GetObject("Attributes"); if (attributesContainer) { BaseContainer itemDisplayNameContainer = attributesContainer.GetObject("ItemDisplayName"); if (itemDisplayNameContainer) { resultInfo = UIInfo.Cast(BaseContainerTools.CreateInstanceFromContainer(itemDisplayNameContainer)); Print(resultInfo); Print("GetName: " + resultInfo.GetName()); Print("GetDescription: " + resultInfo.GetDescription()); Print("GetIconPath: " + resultInfo.GetIconPath()); break; } } } } }
SCRIPT : UIInfo resultInfo = UIInfo<0x000001782971E868>
SCRIPT : GetName:
SCRIPT : GetDescription:
SCRIPT : GetIconPath: