Energy #

Read more about the Energy system in Hiro here.

Get all energies #

Get the energies and their current timers for the player.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
FHiroOnEnergyGet OnEnergyGet;
OnEnergyGet.AddDynamic(this, &AMyActor::OnEnergyGet);
FOnError OnError;

HiroClient->EnergyGet(Session, OnEnergyGet, OnError);

void AMyActor::OnEnergyGet(const FHiroEnergyList& EnergyList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EnergyList.ToJson());
}

Spend one or more energies #

Spend one or more energies for the player.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
FHiroEnergySpendRequest Request;
Request.Amounts.Add(TEXT("power"), 10);
Request.Amounts.Add(TEXT("tickets"), 1);

FHiroOnEnergySpend OnEnergySpend;
OnEnergySpend.AddDynamic(this, &AMyActor::OnEnergySpend);
FOnError OnError;

HiroClient->EnergySpend(Session, Request, OnEnergySpend, OnError);

void AMyActor::OnEnergySpend(const FHiroEnergySpendReward& EnergySpendReward)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EnergySpendReward.ToJson());
}

Granting energy #

While energy can be granted as part of a reward, you can also grant it directly.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
FHiroEnergyGrantRequest Request;
Request.Amounts.Add(TEXT("power"), 10);
Request.Amounts.Add(TEXT("tickets"), 1);

FHiroOnEnergyGrant OnEnergyGrant;
OnEnergySpend.AddDynamic(this, &AMyActor::OnEnergyGrant);
FOnError OnError;

HiroClient->EnergyGrant(Session, Request, OnEnergyGrant, OnError);

void AMyActor::OnEnergyGrant(const FHiroEnergyList& EnergyList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EnergyList.ToJson());
}