44 lines
2.1 KiB
C#
44 lines
2.1 KiB
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace RudderSdk.Core;
|
|
|
|
/// <summary>Session of a scenario battle-pass node.</summary>
|
|
public sealed class BattlePassSession
|
|
{
|
|
internal BattlePassSession(ScenarioNodeContext context) => Context = context;
|
|
|
|
/// <summary>Underlying node context.</summary>
|
|
public ScenarioNodeContext Context { get; }
|
|
|
|
/// <summary>Node id.</summary>
|
|
public string Id => Context.NodeId;
|
|
|
|
/// <summary>Reads a typed value from the node data.</summary>
|
|
public T Get<T>(string key, T defaultValue = default!) => Context.Get(key, defaultValue);
|
|
|
|
/// <summary>Advances the run through the onLevelUp handle.</summary>
|
|
public Task LevelUpAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onLevelUp", cancellationToken);
|
|
|
|
/// <summary>Advances the run through the onLevelUp handle (fire-and-forget).</summary>
|
|
public void LevelUp() => Context.Complete("onLevelUp");
|
|
|
|
/// <summary>Advances the run through the onMaxLevel handle.</summary>
|
|
public Task MaxLevelAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onMaxLevel", cancellationToken);
|
|
|
|
/// <summary>Advances the run through the onMaxLevel handle (fire-and-forget).</summary>
|
|
public void MaxLevel() => Context.Complete("onMaxLevel");
|
|
|
|
/// <summary>Advances the run through the onPremiumPurchase handle.</summary>
|
|
public Task PremiumPurchaseAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onPremiumPurchase", cancellationToken);
|
|
|
|
/// <summary>Advances the run through the onPremiumPurchase handle (fire-and-forget).</summary>
|
|
public void PremiumPurchase() => Context.Complete("onPremiumPurchase");
|
|
|
|
/// <summary>Advances the run through the onComplete handle.</summary>
|
|
public Task CompleteAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onComplete", cancellationToken);
|
|
|
|
/// <summary>Advances the run through the onComplete handle (fire-and-forget).</summary>
|
|
public void Complete() => Context.Complete("onComplete");
|
|
}
|