You've already forked Commercialization.tapadn
fix: support legacy TapADN rewarded scene slots
This commit is contained in:
@@ -62,7 +62,8 @@ public sealed class TapadnAwardVideoPlayer : ADPlayer, IDirichletRewardVideoAuto
|
||||
|
||||
public override void LoadAD()
|
||||
{
|
||||
var slotId = ResolveCurrentSlotId();
|
||||
var slotId = ResolveCurrentSlotId(out var mapped);
|
||||
Debug.Log($"[TapADN] Rewarded load requested. scene={NormalizeScenario(AdScene)}, slot={slotId}, source={GetSlotSource(mapped)}, auto={UseAutoLoad()}");
|
||||
if (!TapadnAdRequestFactory.TryParseSlotId(slotId, out _))
|
||||
{
|
||||
Debug.LogError($"[TapADN] Invalid rewarded slot id: {slotId}");
|
||||
@@ -128,9 +129,10 @@ public sealed class TapadnAwardVideoPlayer : ADPlayer, IDirichletRewardVideoAuto
|
||||
_showSettled = false;
|
||||
_rewardCloseSettleHandler?.Kill();
|
||||
_rewardCloseSettleHandler = null;
|
||||
_activeSlotId = ResolveCurrentSlotId();
|
||||
_activeSlotId = ResolveCurrentSlotId(out var mapped);
|
||||
Key = _activeSlotId;
|
||||
curState = 0;
|
||||
Debug.Log($"[TapADN] Rewarded show requested. scene={NormalizeScenario(AdScene)}, slot={_activeSlotId}, source={GetSlotSource(mapped)}, auto={UseAutoLoad()}");
|
||||
|
||||
if (UseAutoLoad())
|
||||
{
|
||||
@@ -203,25 +205,43 @@ public sealed class TapadnAwardVideoPlayer : ADPlayer, IDirichletRewardVideoAuto
|
||||
|
||||
public override void OnPlayRequestStarted()
|
||||
{
|
||||
var slotId = ResolveCurrentSlotId();
|
||||
var slotId = ResolveCurrentSlotId(out var mapped);
|
||||
Key = slotId;
|
||||
Debug.Log($"[TapADN] Rewarded play request. scene={NormalizeScenario(AdScene)}, slot={slotId}, source={GetSlotSource(mapped)}, auto={UseAutoLoad()}");
|
||||
TapadnSmartLoadOrchestrator.OnPlayRequestStarted(AD_Type.AwardVideo, AdScene, !UseAutoLoad() && IsReadly(), slotId);
|
||||
}
|
||||
|
||||
public override void EnterAdScenario(string scenario)
|
||||
{
|
||||
AdScene = NormalizeScenario(scenario);
|
||||
var slotId = ResolveCurrentSlotId();
|
||||
var slotId = ResolveCurrentSlotId(out var mapped);
|
||||
Key = slotId;
|
||||
Debug.Log($"[TapADN] Rewarded enter scene. scene={AdScene}, slot={slotId}, source={GetSlotSource(mapped)}");
|
||||
TapadnSmartLoadOrchestrator.OnEnterAdScenario(AD_Type.AwardVideo, AdScene, slotId);
|
||||
}
|
||||
|
||||
private string ResolveCurrentSlotId()
|
||||
{
|
||||
var slotId = TapadnAdController.CurrentOptions?.ResolveRewardedSlotId(_defaultSlotId, AdScene) ?? _defaultSlotId;
|
||||
return ResolveCurrentSlotId(out _);
|
||||
}
|
||||
|
||||
private string ResolveCurrentSlotId(out bool mapped)
|
||||
{
|
||||
if (TapadnAdController.CurrentOptions == null)
|
||||
{
|
||||
mapped = false;
|
||||
return string.IsNullOrWhiteSpace(_defaultSlotId) ? _defaultSlotId : _defaultSlotId.Trim();
|
||||
}
|
||||
|
||||
var slotId = TapadnAdController.CurrentOptions.ResolveRewardedSlotId(_defaultSlotId, AdScene, out mapped);
|
||||
return string.IsNullOrWhiteSpace(slotId) ? _defaultSlotId : slotId.Trim();
|
||||
}
|
||||
|
||||
private static string GetSlotSource(bool mapped)
|
||||
{
|
||||
return mapped ? "scene" : "default";
|
||||
}
|
||||
|
||||
private bool UseAutoLoad()
|
||||
{
|
||||
return TapadnAdController.CurrentOptions?.RewardedAutoLoad ?? true;
|
||||
|
||||
Reference in New Issue
Block a user