basically I have an inventory state Tmap of FVectro2D and bool in Lyra, here the length is 60
void ULyraInventoryManagerComponent::DefaultInventoryState()
{
float GridX = 0.f;
float GridY = 0.f;
for (int i = 0; i < InventorySize; i++)
{
InventoryState.Add(FVector2D(GridX, GridY), false);
if(GridX == InventoryWidth-1)
{
GridX = 0.f;
GridY++;
}
else
{
GridX++;
}
}
TArray<FVector2D> ItemLocations;
InventoryState.GetKeys(ItemLocations);
// LENGTH == 60
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("LENGTH %d"), ItemLocations.Num()));
}
when I add an item the InventoryState says that its empty
ULyraInventoryItemInstance* ULyraInventoryManagerComponent::AddItemDefinition(TSubclassOf<ULyraInventoryItemDefinition> ItemDef, int32 StackCount)
{
ULyraInventoryItemInstance* Result = nullptr;
if (ItemDef != nullptr)
{
Result = InventoryList.AddEntry(ItemDef, StackCount);
const UEO_InventoryFragment_Icon* Fragment = Cast<UEO_InventoryFragment_Icon>(Result->FindFragmentByClass(UEO_InventoryFragment_Icon::StaticClass()));
if (Fragment)
{
bool bSuccess = false;
int32 Remaining = StackCount;
TArray<FVector2D> ItemLocations;
InventoryState.GetKeys(ItemLocations);
// length == 0
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("LENGTH in AddItemDefinition %i"), ItemLocations.Num()));
AddItemFromFloor(Fragment, Result, bSuccess, Remaining);
if (Remaining != 0)
{
Result->AddStatTagStack(TAG_Lyra_Inventory_Item_Count, Remaining);
}
}
if (IsUsingRegisteredSubObjectList() && IsReadyForReplication() && Result)
{
AddReplicatedSubObject(Result);
}
}
return Result;
}```