Inventory
#
Read more about the Inventory system in Hiro here.
List items
#
List all inventory items defined in the codex, optionally filtered by category.
1
2
3
4
5
6
7
8
9
10
11
12
13
| FHiroInventoryListRequest Request;
Request.ItemCategory = TEXT("weapons");
FHiroOnInventoryList OnInventoryList;
OnInventoryList.AddDynamic(this, &AMyActor::OnInventoryList);
FOnError OnError;
HiroClient->InventoryList(Session, Request, OnInventoryList, OnError);
void AMyActor::OnInventoryList(const FHiroInventoryList& InventoryList)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryList.ToJson());
}
|
List user inventory items
#
List all inventory items owned by the player, optionally filtered by category.
1
2
3
4
5
6
7
8
9
10
11
12
13
| FHiroInventoryListRequest Request;
Request.ItemCategory = TEXT("weapons");
FHiroOnInventoryListInventory OnInventoryListInventory;
OnInventoryListInventory.AddDynamic(this, &AMyActor::OnInventoryListInventory);
FOnError OnError;
HiroClient->InventoryListInventory(Session, Request, OnInventoryListInventory, OnError);
void AMyActor::OnInventoryList(const FHiroInventoryList& InventoryList)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryList.ToJson());
}
|
Consume inventory items
#
Consume one or more inventory items owned by the player.
1
2
3
4
5
6
7
8
9
10
11
12
13
| FHiroInventoryConsumeRequest Request;
Request.Items.Add(TEXT("health_potion"), 1);
FHiroOnInventoryConsume OnInventoryConsume;
OnInventoryConsume.AddDynamic(this, &AMyActor::OnInventoryConsume);
FOnError OnError;
HiroClient->InventoryConsume(Session, Request, OnInventoryConsume, OnError);
void AMyActor::OnInventoryConsume(const FHiroInventoryConsumeRewards& InventoryConsumeRewards)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryConsumeRewards.ToJson());
}
|
Grant inventory items
#
Grant one or more inventory items to the player.
1
2
3
4
5
6
7
8
9
10
11
12
13
| FHiroInventoryGrantRequest Request;
Request.Items.Add(TEXT("bronze_sword"), 1);
FHiroOnInventoryGrant OnInventoryGrant;
OnInventoryGrant.AddDynamic(this, &AMyActor::OnInventoryGrant);
FOnError OnError;
HiroClient->InventoryGrant(Session, Request, OnInventoryGrant, OnError);
void AMyActor::OnInventoryConsume(const FHiroInventoryUpdateAck& InventoryUpdateAck)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryUpdateAck.ToJson());
}
|
Update inventory items
#
Update the properties on one or more inventory items owned by the player.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| FHiroInventoryUpdateItemsRequest Request;
FHiroInventoryUpdateItemProperties ItemProperties;
ItemProperties.StringProperties.Add(TEXT("example_property"), TEXT("example_value"));
ItemProperties.NumericProperties.Add(TEXT("numeric_property"), 10);
Request.ItemUpdates.Add(TEXT("bronze_sword"), ItemProperties);
FHiroOnInventoryUpdate OnInventoryUpdate;
OnInventoryUpdate.AddDynamic(this, &AMyActor::OnInventoryUpdate);
FOnError OnError;
HiroClient->InventoryUpdate(Session, Request, OnInventoryUpdate, OnError);
void AMyActor::OnInventoryConsume(const FHiroInventoryUpdateAck& InventoryUpdateAck)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *InventoryUpdateAck.ToJson());
}
|