public void SetDiscount(GetDiscountForOfferEvent e, PremiumGoodsNode good, [JoinBy(typeof(SpecialOfferGroupComponent))] Optional <SingleNode <DiscountComponent> > personalOffer) { e.Discount = 0f; if (personalOffer.IsPresent()) { e.Discount = personalOffer.Get().component.DiscountCoeff; } }
public void OnDiscountAdded(NodeAddedEvent e, PremiumGoodsNode good, [Context, JoinBy(typeof(SpecialOfferGroupComponent))] SingleNode <DiscountComponent> personalOffer) { if (good.Entity.HasComponent <CustomOfferPriceForUIComponent>()) { good.Entity.RemoveComponent <CustomOfferPriceForUIComponent>(); } double num = good.goodsPrice.Price * (1f - personalOffer.component.DiscountCoeff); num = good.goodsPrice.Round(num); good.Entity.AddComponent(new CustomOfferPriceForUIComponent(num)); }
private void FillPack(PremiumPackComponent pack, PremiumGoodsNode packNode, int count) { GetDiscountForOfferEvent eventInstance = new GetDiscountForOfferEvent(); base.ScheduleEvent(eventInstance, packNode); pack.DaysText = packNode.countableItemsPack.Pack.First <KeyValuePair <long, int> >().Value.ToString(); pack.DaysDescription = packNode.specialOfferContentLocalization.Description; pack.Price = $"{(1f - eventInstance.Discount) * packNode.goodsPrice.Price:0.00} {packNode.goodsPrice.Currency}"; pack.Discount = eventInstance.Discount; pack.HasXCrystals = this.IsGoodsWithCrystals(packNode); pack.LearnMoreIndex = count; pack.GoodsEntity = packNode.Entity; }
private bool IsGoodsWithCrystals(PremiumGoodsNode sortedGood) => sortedGood.countableItemsPack.Pack.ContainsKey(-180272377L);