public CrateVO GetCrateVOFromTargetedOffer(TargetedBundleVO offerVO)
        {
            IDataController dataController = Service.Get <IDataController>();

            if (offerVO == null)
            {
                return(null);
            }
            if (offerVO.RewardUIDs == null || offerVO.RewardUIDs.Count < 1)
            {
                return(null);
            }
            int i     = 0;
            int count = offerVO.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = Service.Get <IDataController>().GetOptional <RewardVO>(offerVO.RewardUIDs[i]);
                if (optional != null)
                {
                    string crateReward = optional.CrateReward;
                    if (!string.IsNullOrEmpty(crateReward))
                    {
                        return(dataController.GetOptional <CrateVO>(crateReward));
                    }
                }
                i++;
            }
            return(null);
        }
        private void InitializeTriggerOffer(TargetedBundleVO offerVO)
        {
            if (offerVO == null)
            {
                Service.Get <StaRTSLogger>().Error("InitializeTriggerOffer called with null value.");
                return;
            }
            if (this.lastKnownTargetedOffer != null && this.lastKnownTargetedOffer.Uid == offerVO.Uid)
            {
                this.CurrentTargetedOffer = this.lastKnownTargetedOffer;
            }
            else
            {
                this.CurrentTargetedOffer = offerVO;
                uint duration = (uint)offerVO.Duration;
                this.OfferExpiresAt = Service.Get <ServerAPI>().ServerTime + duration;
                TriggerTargetedOfferCommand triggerTargetedOfferCommand = new TriggerTargetedOfferCommand(new TargetedOfferIDRequest
                {
                    PlayerId = Service.Get <CurrentPlayer>().PlayerId,
                    OfferId  = offerVO.Uid
                });
                triggerTargetedOfferCommand.AddSuccessCallback(new AbstractCommand <TargetedOfferIDRequest, TriggerTargetedOfferResponse> .OnSuccessCallback(this.OnTriggeredOfferResponse));
                Service.Get <ServerAPI>().Enqueue(triggerTargetedOfferCommand);
            }
            string text;

            this.FindAvailableIAP(this.CurrentTargetedOffer, out text, out this.currentOfferCost);
        }
 public TargetedBundleRewardedConfirmScreen(TargetedBundleVO offerVO) : base("gui_promotional_confirmation")
 {
     this.itemLabels   = new UXLabel[3];
     this.itemSprites  = new UXSprite[3];
     this.currentOffer = null;
     this.currentOffer = offerVO;
 }
示例#4
0
        public static CrateInfoModalScreen CreateForTargetedOfferTest(TargetedBundleVO offer, CrateVO crate)
        {
            CrateInfoModalScreen crateInfoModalScreen = CrateInfoModalScreen.CreateForTargetedOffer(offer, crate);

            crateInfoModalScreen.ignoreExpirationAutoClose = true;
            return(crateInfoModalScreen);
        }
        public bool FindAvailableIAP(TargetedBundleVO offerVO, out string currentIapId, out string offerCost)
        {
            bool            result         = false;
            IDataController dataController = Service.Get <IDataController>();

            currentIapId = string.Empty;
            offerCost    = string.Empty;
            InAppPurchaseController inAppPurchaseController = Service.Get <InAppPurchaseController>();
            int i     = 0;
            int count = offerVO.LinkedIAPs.Count;

            while (i < count)
            {
                string uid = offerVO.LinkedIAPs[i];
                InAppPurchaseTypeVO optional = dataController.GetOptional <InAppPurchaseTypeVO>(uid);
                if (optional != null)
                {
                    InAppPurchaseProductInfo iAPProduct = inAppPurchaseController.GetIAPProduct(optional.ProductId);
                    if (iAPProduct != null)
                    {
                        currentIapId = optional.ProductId;
                        offerCost    = iAPProduct.FormattedRealCost;
                        result       = true;
                        break;
                    }
                }
                i++;
            }
            return(result);
        }
示例#6
0
        private void HandleCurrencyOfferPurchase(TargetedBundleVO currentOffer)
        {
            int credits    = 0;
            int materials  = 0;
            int contraband = 0;
            int num        = 0;
            int num2       = 0;

            GameUtils.GetCurrencyCost(currentOffer.Cost, out credits, out materials, out contraband, out num2, out num);
            if (!GameUtils.CanAffordCosts(credits, materials, contraband, num))
            {
                if (num == 0)
                {
                    PayMeScreen.ShowIfNotEnoughCurrency(credits, materials, contraband, "SPD", new OnScreenModalResult(this.OnCurrencyPurchased));
                }
                else
                {
                    GameUtils.PromptToBuyCrystals();
                }
            }
            else
            {
                this.MakeCurrencyOfferPurchase();
            }
        }
示例#7
0
 private void SetupCurrencyCostOffer(TargetedBundleVO currentOffer)
 {
     this.purchaseIAPButtonLabel.Visible          = false;
     this.purchaseWithCurrencySprite.Visible      = true;
     this.purchaseWithCurrencyButtonLabel.Visible = true;
     UXUtils.SetupTargetedOfferCostUI(currentOffer, this.purchaseWithCurrencyButtonLabel, this.purchaseWithCurrencySprite);
 }
        public void LogTargetedBundleBI(string action, TargetedBundleVO currentOffer)
        {
            string context = "SPD";
            string uid     = currentOffer.Uid;
            string text    = this.currentOfferCost;
            string text2   = (currentOffer.Groups.Count >= 1) ? currentOffer.Groups[0] : string.Empty;
            int    count   = currentOffer.RewardUIDs.Count;
            string text3   = (count > 0) ? currentOffer.RewardUIDs[0] : string.Empty;
            string text4   = (count > 1) ? currentOffer.RewardUIDs[1] : string.Empty;
            string text5   = (count > 2) ? currentOffer.RewardUIDs[2] : string.Empty;
            string text6   = currentOffer.Duration.ToString();
            int    num     = (int)(this.OfferExpiresAt - Service.Get <ServerAPI>().ServerTime);

            if (num < 0)
            {
                num = 0;
            }
            string text7   = num.ToString();
            string message = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}", new object[]
            {
                uid,
                text,
                text2,
                text3,
                text4,
                text5,
                text6,
                text7
            });

            Service.Get <BILoggingController>().TrackGameAction(context, action, message, null);
        }
示例#9
0
        private void SetupIAPLinkedOffer(TargetedBundleVO currentOffer)
        {
            this.purchaseWithCurrencySprite.Visible      = false;
            this.purchaseWithCurrencyButtonLabel.Visible = false;
            this.purchaseIAPButtonLabel.Visible          = true;
            TargetedBundleController targetedBundleController = Service.TargetedBundleController;
            bool flag = false;

            if (currentOffer != null)
            {
                string text;
                string text2;
                flag = targetedBundleController.FindAvailableIAP(currentOffer, out text, out text2);
                if (flag && !string.IsNullOrEmpty(text))
                {
                    this.purchaseIAPButtonLabel.Text = this.lang.Get("TARGETED_BUNDLE_PURCHASE", new object[]
                    {
                        text2
                    });
                    this.purchaseButton.Tag = text;
                }
            }
            if (!flag)
            {
                this.purchaseButton.Visible         = false;
                this.purchaseIAPButtonLabel.Visible = false;
                Service.Logger.Error("No iap available for targeted bundle screen: " + currentOffer.Uid);
            }
        }
 private void KillSwitchClearOffers()
 {
     this.ResetOffer();
     this.GlobalCooldownExpiresAt = 0u;
     this.OfferExpiresAt          = 0u;
     this.NextOfferAvailableAt    = 0u;
     this.lastKnownTargetedOffer  = null;
     this.FetchingNewOffer        = false;
 }
        private void LoadCurrentTargetedOffer(string offerId, uint triggeredTime)
        {
            IDataController dataController = Service.Get <IDataController>();

            this.CurrentTargetedOffer = dataController.GetOptional <TargetedBundleVO>(offerId);
            if (this.CurrentTargetedOffer != null)
            {
                this.OfferExpiresAt = triggeredTime + (uint)this.CurrentTargetedOffer.Duration;
            }
        }
示例#12
0
        private void LoadCurrentTargetedOffer(string offerId, uint triggeredTime)
        {
            StaticDataController staticDataController = Service.StaticDataController;

            this.CurrentTargetedOffer = staticDataController.GetOptional <TargetedBundleVO>(offerId);
            if (this.CurrentTargetedOffer != null)
            {
                this.OfferExpiresAt = triggeredTime + (uint)this.CurrentTargetedOffer.Duration;
            }
            Service.EventManager.SendEvent(EventId.TargetedBundleContentPrepared, null);
        }
示例#13
0
        public static CrateInfoModalScreen CreateForTargetedOffer(TargetedBundleVO offer, CrateVO crate)
        {
            BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>();
            Entity         currentHQ    = buildingLookupController.GetCurrentHQ();
            BuildingTypeVO buildingType = currentHQ.Get <BuildingComponent>().BuildingType;
            string         planetId     = Service.Get <CurrentPlayer>().PlanetId;

            return(new CrateInfoModalScreen(crate.Uid, planetId, buildingType.Lvl)
            {
                ModalReason = CrateInfoReason.Reason_Targeted_Offer,
                CurrentOffer = offer
            });
        }
 public bool IsCurrencyCostOffer(TargetedBundleVO offerVO)
 {
     if (offerVO.LinkedIAPs != null && offerVO.LinkedIAPs.Count > 0)
     {
         return(false);
     }
     if (offerVO.Cost != null && offerVO.Cost.Length != 0)
     {
         return(true);
     }
     Service.Get <StaRTSLogger>().Error("Targeted Bundle Offser has no linked IAP and no Cost: " + offerVO.Uid);
     return(false);
 }
        public void GrantTargetedBundleRewards(TargetedBundleVO offerVO)
        {
            IDataController dataController = Service.Get <IDataController>();
            int             i     = 0;
            int             count = offerVO.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = dataController.GetOptional <RewardVO>(offerVO.RewardUIDs[i]);
                if (optional == null)
                {
                    Service.Get <StaRTSLogger>().WarnFormat("Trying to grant {0} which cannot be found.", new object[]
                    {
                        offerVO.RewardUIDs[i]
                    });
                }
                else
                {
                    bool flag = true;
                    if (optional.CurrencyRewards != null)
                    {
                        Dictionary <string, int> dictionary = GameUtils.ListToMap(optional.CurrencyRewards);
                        int num = 0;
                        dictionary.TryGetValue("crystals", out num);
                        if (num > 0)
                        {
                            flag = false;
                        }
                    }
                    else if (!string.IsNullOrEmpty(optional.DroidRewards))
                    {
                        flag = false;
                    }
                    else if (optional.BuildingInstantRewards != null || optional.BuildingInstantUpgrades != null || optional.HeroResearchInstantUpgrades != null || optional.TroopResearchInstantUpgrades != null || optional.SpecAttackResearchInstantUpgrades != null)
                    {
                        flag = false;
                    }
                    if (flag)
                    {
                        RewardUtils.GrantInAppPurchaseRewardToHQInventory(optional);
                    }
                    else
                    {
                        RewardUtils.GrantReward(Service.Get <CurrentPlayer>(), optional);
                    }
                }
                i++;
            }
        }
示例#16
0
        public static CrateInfoModalScreen CreateForTargetedOffer(TargetedBundleVO offer, CrateVO crate)
        {
            BuildingLookupController buildingLookupController = Service.BuildingLookupController;
            Entity         currentHQ    = buildingLookupController.GetCurrentHQ();
            BuildingTypeVO buildingType = currentHQ.Get <BuildingComponent>().BuildingType;
            string         planetId     = Service.CurrentPlayer.PlanetId;
            FactionType    faction      = Service.CurrentPlayer.Faction;
            bool           flag         = ArmoryUtils.PlayerHasArmory();

            return(new CrateInfoModalScreen(crate.Uid, planetId, buildingType.Lvl, faction, flag)
            {
                ModalReason = CrateInfoReason.Reason_Targeted_Offer,
                CurrentOffer = offer
            });
        }
 public void HandleTargetedOfferSuccess(CrateData crateDataTO, TargetedBundleVO offerVO)
 {
     if (crateDataTO != null)
     {
         Service.Get <EventManager>().SendEvent(EventId.OpeningPurchasedCrate, null);
         List <string> resolvedSupplyIdList = GameUtils.GetResolvedSupplyIdList(crateDataTO);
         Service.Get <InventoryCrateRewardController>().GrantInventoryCrateReward(resolvedSupplyIdList, crateDataTO);
         this.LogTargetedBundleBI("purchase_complete", offerVO);
     }
     else
     {
         TargetedBundleRewardedConfirmScreen screen = new TargetedBundleRewardedConfirmScreen(offerVO);
         Service.Get <ScreenController>().AddScreen(screen);
     }
     this.ResetOffer();
 }
        public void MakeTargetedBundlePurchase(TargetedBundleVO currentOffer, string iapId)
        {
            bool flag = false;

            if (this.IsCurrencyCostOffer(currentOffer))
            {
                flag = true;
                this.HandleCurrencyOfferPurchase(currentOffer);
            }
            else if (iapId != null && this.CanPurchaseIAPLinkedOffer(currentOffer))
            {
                flag = true;
                Service.Get <EventManager>().SendEvent(EventId.InAppPurchaseSelect, iapId);
                Service.Get <EventManager>().SendEvent(EventId.TargetedBundleReserve, iapId);
                Service.Get <InAppPurchaseController>().PurchaseProduct(iapId);
            }
            if (flag)
            {
                this.LogTargetedBundleBI("purchase_attempt");
            }
        }
示例#19
0
        public static void SetupTargetedOfferCostUI(TargetedBundleVO currentOffer, UXLabel label, UXSprite sprite)
        {
            string[] cost = currentOffer.Cost;
            if (cost == null || cost.Length == 0)
            {
                Service.Logger.Error("SetupCurrencyCostOffer Cost was empty or null: " + currentOffer.Uid);
                return;
            }
            string       costString = cost[0];
            CurrencyType type       = CurrencyType.None;
            int          num        = -1;
            int          credits    = 0;
            int          materials  = 0;
            int          contraband = 0;
            int          crystals   = 0;

            if (GameUtils.ParseCurrencyCostString(costString, out type, out num))
            {
                switch (type)
                {
                case CurrencyType.Credits:
                    credits = num;
                    break;

                case CurrencyType.Materials:
                    materials = num;
                    break;

                case CurrencyType.Contraband:
                    contraband = num;
                    break;

                case CurrencyType.Crystals:
                    crystals = num;
                    break;
                }
            }
            UXUtils.SetupSingleResourceUI(num, type, label, sprite, credits, materials, contraband, crystals);
        }
        private bool CanPurchaseIAPLinkedOffer(TargetedBundleVO currentOffer)
        {
            bool            flag           = true;
            IDataController dataController = Service.Get <IDataController>();
            int             i     = 0;
            int             count = currentOffer.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = dataController.GetOptional <RewardVO>(currentOffer.RewardUIDs[i]);
                if (optional != null && optional.BuildingInstantRewards != null)
                {
                    flag = this.CanPlaceAllRewardBuildings(optional.BuildingInstantRewards);
                    if (!flag)
                    {
                        AlertScreen.ShowModal(false, Service.Get <Lang>().Get("promo_error_nospace_title", new object[0]), Service.Get <Lang>().Get("promo_error_nospace_desc", new object[0]), null, null);
                        break;
                    }
                }
                i++;
            }
            return(flag);
        }
        public void GetNewOffer(EventId triggerEventId)
        {
            if (!GameConstants.TARGETED_OFFERS_ENABLED)
            {
                this.KillSwitchClearOffers();
                Service.Get <EventManager>().SendEvent(EventId.TargetedBundleContentPrepared, null);
                return;
            }
            uint serverTime = Service.Get <ServerAPI>().ServerTime;
            uint num        = serverTime - this.lastGetOffersQueryTime;
            bool flag       = (ulong)num < (ulong)((long)this.getOffersLimiter);

            if (flag)
            {
                string message = "Querying GetNewOffers too frequently: " + triggerEventId.ToString();
                Service.Get <StaRTSLogger>().Warn(message);
                return;
            }
            this.lastGetOffersQueryTime = serverTime;
            this.FetchingNewOffer       = true;
            this.lastKnownTargetedOffer = this.CurrentTargetedOffer;
            this.PrepareContent();
            Service.Get <EventManager>().SendEvent(EventId.TargetedBundleContentPrepared, null);
        }
示例#22
0
        public void HandleReceiptVerificationResponse(string uid, string transactionId, string currencyCode, double price, double bonusMultiplier, bool isPromo, string offerUid, CrateData crateData)
        {
            CurrentPlayer        currentPlayer        = Service.CurrentPlayer;
            StaticDataController staticDataController = Service.StaticDataController;
            InAppPurchaseTypeVO  inAppPurchaseTypeVO  = staticDataController.Get <InAppPurchaseTypeVO>(uid);

            if (inAppPurchaseTypeVO.IsPromo)
            {
                isPromo = true;
            }
            bool   flag = !string.IsNullOrEmpty(offerUid);
            string text = inAppPurchaseTypeVO.RewardEmpire;

            if (currentPlayer.Faction == FactionType.Rebel)
            {
                text = inAppPurchaseTypeVO.RewardRebel;
            }
            if (string.IsNullOrEmpty(text) && !flag)
            {
                Service.Logger.Error("MoneyReceiptVerifyResponse:" + inAppPurchaseTypeVO.Uid + " faction specific reward uids do not exist");
                return;
            }
            bool             flag2            = false;
            TargetedBundleVO targetedBundleVO = null;

            if (flag)
            {
                targetedBundleVO = staticDataController.GetOptional <TargetedBundleVO>(offerUid);
                if (targetedBundleVO != null)
                {
                    Service.TargetedBundleController.GrantTargetedBundleRewards(targetedBundleVO);
                    flag2 = true;
                }
                else
                {
                    Service.Logger.Error("MoneyReceiptVerifyResponse: targeted offer " + offerUid + " does not exist");
                }
            }
            else
            {
                RewardVO optional = staticDataController.GetOptional <RewardVO>(text);
                if (optional == null)
                {
                    Service.Logger.Error("MoneyReceiptVerifyResponse:" + text + " does not exist");
                }
                else if (inAppPurchaseTypeVO.CurrencyType.Equals("hard"))
                {
                    RewardUtils.GrantReward(currentPlayer, optional, bonusMultiplier);
                }
                else
                {
                    RewardUtils.GrantInAppPurchaseRewardToHQInventory(optional);
                }
            }
            if (inAppPurchaseTypeVO.ProductId.Contains("promo"))
            {
                isPromo = true;
            }
            int amount;

            if (inAppPurchaseTypeVO.CurrencyType.Equals("hard"))
            {
                amount = (int)Math.Floor(bonusMultiplier * (double)inAppPurchaseTypeVO.Amount);
            }
            else
            {
                amount = inAppPurchaseTypeVO.Amount;
            }
            this.Consume(inAppPurchaseTypeVO.ProductId);
            string     text2             = uid;
            bool       flag3             = false;
            SaleTypeVO currentActiveSale = SaleUtils.GetCurrentActiveSale();

            if (currentActiveSale != null && !isPromo)
            {
                text2 = text2 + "_" + currentActiveSale.Uid;
            }
            if (isPromo)
            {
                text2 += "_promo";
                flag3  = true;
            }
            if (GameConstants.IAP_FORCE_POPUP_ENABLED)
            {
                flag3 = true;
            }
            if (flag2)
            {
                Service.TargetedBundleController.HandleTargetedOfferSuccess(crateData, targetedBundleVO);
            }
            else if (flag3)
            {
                this.ShowRedemptionScreen(amount, uid);
                Service.EventManager.SendEvent(EventId.InAppPurchaseMade, null);
            }
            Service.DMOAnalyticsController.LogPaymentAction(currencyCode, price, inAppPurchaseTypeVO.ProductId, 1, text2);
        }
示例#23
0
 public void ResetOffer()
 {
     this.CurrentTargetedOffer = null;
     Service.EventManager.SendEvent(EventId.TargetedBundleContentPrepared, null);
 }
示例#24
0
        private void UpdateElements()
        {
            StaticDataController     staticDataController     = Service.StaticDataController;
            TargetedBundleController targetedBundleController = Service.TargetedBundleController;

            this.currentOffer = targetedBundleController.CurrentTargetedOffer;
            if (this.currentOffer != null)
            {
                UXLabel element = base.GetElement <UXLabel>("LabelTitle");
                element.Text = this.lang.Get(this.currentOffer.Title, new object[0]);
                UXLabel element2 = base.GetElement <UXLabel>("LabelDescription");
                element2.Text = this.lang.Get(this.currentOffer.Description, new object[0]);
                TextureVO optional = staticDataController.GetOptional <TextureVO>("gui_textures_promotional");
                if (optional != null)
                {
                    UXTexture element3 = base.GetElement <UXTexture>("TexturePromoArt");
                    element3.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_entry");
                if (optional != null)
                {
                    UXTexture element4 = base.GetElement <UXTexture>("TextureEnvironmentEntry");
                    element4.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_treads");
                if (optional != null)
                {
                    UXTexture element5 = base.GetElement <UXTexture>("TextureEnvironmentRight");
                    element5.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_treads");
                if (optional != null)
                {
                    UXTexture element6 = base.GetElement <UXTexture>("TextureEnvironmentLeft");
                    element6.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_dust");
                if (optional != null)
                {
                    UXTexture element7 = base.GetElement <UXTexture>("TextureEnvironmentDustRight");
                    element7.LoadTexture(optional.AssetName);
                    element7 = base.GetElement <UXTexture>("TextureEnvironmentDustLeft");
                    element7.LoadTexture(optional.AssetName);
                }
                int i     = 0;
                int count = this.currentOffer.RewardUIDs.Count;
                while (i < count)
                {
                    RewardVO rewardVO = staticDataController.Get <RewardVO>(this.currentOffer.RewardUIDs[i]);
                    if (!RewardUtils.SetupTargetedOfferCrateRewardDisplay(rewardVO, this.itemLabels[i], this.itemSprites[i]))
                    {
                        List <RewardComponentTag> rewardComponents = RewardUtils.GetRewardComponents(rewardVO);
                        int j      = 0;
                        int count2 = rewardComponents.Count;
                        while (j < count2)
                        {
                            RewardComponentTag rewardComponentTag = rewardComponents[j];
                            this.itemLabels[i].Text = this.lang.Get("AMOUNT_AND_NAME", new object[]
                            {
                                rewardComponentTag.RewardName,
                                rewardComponentTag.Quantity
                            });
                            RewardUtils.SetRewardIcon(this.itemSprites[i], rewardComponentTag.RewardGeometryConfig, AnimationPreference.AnimationAlways);
                            j++;
                        }
                    }
                    i++;
                }
                if (targetedBundleController.IsCurrencyCostOffer(this.currentOffer))
                {
                    this.SetupCurrencyCostOffer(this.currentOffer);
                }
                else
                {
                    this.SetupIAPLinkedOffer(this.currentOffer);
                }
                UXUtils.SetupAnimatedCharacter(this.characterSprite1, this.currentOffer.Character1Image, ref this.charGeometry1);
                UXUtils.SetupAnimatedCharacter(this.characterSprite2, this.currentOffer.Character2Image, ref this.charGeometry2);
                uint serverTime = Service.ServerAPI.ServerTime;
                this.timeRemaining   = (int)(targetedBundleController.OfferExpiresAt - serverTime);
                this.timerLabel.Text = this.lang.Get("expires_in", new object[]
                {
                    GameUtils.GetTimeLabelFromSeconds(this.timeRemaining)
                });
                this.valueLabel.Text = this.lang.Get("PERCENTAGE", new object[]
                {
                    this.currentOffer.Discount.ToString()
                });
                this.value2Label.Text = this.lang.Get("TARGETED_BUNDLE_DISCOUNT", new object[]
                {
                    this.currentOffer.Discount.ToString()
                });
            }
            else
            {
                Service.Logger.Error("No current offer available for targeted bundle screen");
            }
        }
        private void UpdateFromTargetedOfferSummary(TargetedOfferSummary offerSummary)
        {
            DateTime         serverDateTime   = Service.Get <ServerAPI>().ServerDateTime;
            IDataController  dataController   = Service.Get <IDataController>();
            bool             flag             = false;
            TargetedBundleVO targetedBundleVO = null;

            if (!string.IsNullOrEmpty(offerSummary.AvailableOffer))
            {
                string availableOffer = offerSummary.AvailableOffer;
                targetedBundleVO = dataController.GetOptional <TargetedBundleVO>(availableOffer);
                if (targetedBundleVO != null)
                {
                    flag = targetedBundleVO.IgnoreCooldown;
                }
            }
            int  secondsFromEpoch        = DateUtils.GetSecondsFromEpoch(serverDateTime);
            uint globalCooldownExpiresAt = offerSummary.GlobalCooldownExpiresAt;

            if (!flag && globalCooldownExpiresAt != 0u && (long)secondsFromEpoch < (long)((ulong)globalCooldownExpiresAt))
            {
                Service.Get <StaRTSLogger>().DebugFormat("Offer global cooldown is in effect until {0}", new object[]
                {
                    LangUtils.FormatTime((long)offerSummary.GlobalCooldownExpiresAt)
                });
                this.GlobalCooldownExpiresAt = offerSummary.GlobalCooldownExpiresAt;
                this.OfferExpiresAt          = 0u;
                this.NextOfferAvailableAt    = 0u;
                this.SetBoundedTimer((long)((ulong)this.GlobalCooldownExpiresAt - (ulong)((long)secondsFromEpoch)), new TimerDelegate(this.CheckForNewOffer), false);
            }
            else if (targetedBundleVO != null)
            {
                Service.Get <StaRTSLogger>().DebugFormat("Available offer: {0}", new object[]
                {
                    offerSummary.AvailableOffer
                });
                if (targetedBundleVO.StartTime <= serverDateTime && serverDateTime < targetedBundleVO.EndTime && AudienceConditionUtils.IsValidForClient(targetedBundleVO.AudienceConditions))
                {
                    this.InitializeTriggerOffer(targetedBundleVO);
                }
                else
                {
                    Service.Get <StaRTSLogger>().WarnFormat("Server provided offer {0} was outside of date range {1} to {2}.", new object[]
                    {
                        offerSummary.AvailableOffer,
                        targetedBundleVO.StartTime,
                        targetedBundleVO.EndTime
                    });
                }
            }
            else if (offerSummary.NextOfferAvailableAt > 0u)
            {
                Service.Get <StaRTSLogger>().DebugFormat("Next offer available at {0}.", new object[]
                {
                    LangUtils.FormatTime((long)offerSummary.NextOfferAvailableAt)
                });
                this.NextOfferAvailableAt    = offerSummary.NextOfferAvailableAt;
                this.GlobalCooldownExpiresAt = 0u;
                this.OfferExpiresAt          = 0u;
                this.SetBoundedTimer((long)((ulong)this.NextOfferAvailableAt - (ulong)((long)DateUtils.GetSecondsFromEpoch(serverDateTime))), new TimerDelegate(this.CheckForNewOffer), false);
            }
            else
            {
                this.GlobalCooldownExpiresAt = 0u;
                this.OfferExpiresAt          = 0u;
                this.NextOfferAvailableAt    = 0u;
            }
            this.lastKnownTargetedOffer = null;
            this.FetchingNewOffer       = false;
            if (this.CurrentTargetedOffer != null)
            {
                Service.Get <EventManager>().SendEvent(EventId.TargetedBundleContentPrepared, null);
            }
        }
 public void ResetOffer()
 {
     this.CurrentTargetedOffer = null;
 }