コード例 #1
0
 static void Postfix(Shop __instance, ShopDefItem item, Shop.ShopType shopType, ref int __result)
 {
     try {
         if (shopType == Shop.ShopType.Faction)
         {
             DescriptionDef itemDescription = __instance.GetItemDescription(item);
             __result = Mathf.CeilToInt(itemDescription.Cost * item.DiscountModifier);
         }
     }
     catch (Exception e) {
         PersistentMapClient.Logger.LogError(e);
     }
 }
コード例 #2
0
        public List <ProcGenStoreItem> GenerateItemsForStore(Shop.ShopType shopType, string starSystemName, string ownerName,
                                                             DateTime currentDate, List <string> planetTags, List <ProcGenStoreContentFeatureSettings.PlanetTagModifier> planetTagModifiers,
                                                             ProcGenStoreContentFeatureSettings settings)
        {
            _logger.Debug($"Generating shop inventory for [{starSystemName} - {shopType.ToString()} - {ownerName}]...");
            var potentialInventoryItems = IdentifyPotentialInventoryItems(shopType, ownerName, planetTags, currentDate, settings);

            _logger.Debug(
                $"Potential Inventory Items = {string.Join("\r\n", potentialInventoryItems.Select(item => $"[{item.StoreItem.Id}] - Bonus [{item.BracketBonus}]"))}");
            var storeInventory = ProduceStoreInventoryFromPotentialItemList(shopType, ownerName, currentDate, settings,
                                                                            planetTagModifiers, potentialInventoryItems);

            _logger.Debug(
                $"Final Inventory Items = \r\n{string.Join("\r\n", storeInventory.Select(item => $"{item.Id} @ {item.Quantity} units"))}");

            return(storeInventory);
        }
コード例 #3
0
 static bool Prefix(Shop __instance, Shop.ShopType shopType)
 {
     try {
         if (shopType == Shop.ShopType.Faction)
         {
             Traverse.Create(__instance).Property("ThisShopType").SetValue(shopType);
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception e) {
         PersistentMapClient.Logger.LogError(e);
         return(true);
     }
 }
コード例 #4
0
        public (bool result, int bracketBonus) IsValidForAppearance(DateTime currentDate, string ownerValueName,
                                                                    Shop.ShopType shopType,
                                                                    List <string> planetTags,
                                                                    ProcGenStoreContentFeatureSettings settings)
        {
            // Check tags...
            if (RequiredTags.Any())
            {
                // Check at least one required tag is present...
                // Unless we're populating a black market, and they're configured to circumvent required restrictions...
                if (RequiredTags.Any() && !planetTags.Any(s => RequiredTags.Contains(s)) &&
                    !(shopType == Shop.ShopType.BlackMarket &&
                      settings.BlackMarketSettings.CircumventRequiredPlanetTags))
                {
                    return(false, 0);
                }
            }

            if (RestrictedTags.Any() && planetTags.Any(s => RestrictedTags.Contains(s)) &&
                !(shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventRestrictedPlanetTags))
            {
                return(false, 0);
            }

            if (MinAppearanceDate.HasValue && MinAppearanceDate > currentDate)
            {
                return(false, 0);
            }

            if (!Purchasable)
            {
                return(false, 0);
            }

            return(true, 0);
        }
コード例 #5
0
            public static bool Prefix(Shop __instance, ref int __result, ShopDefItem item, Shop.PurchaseType purchaseType, Shop.ShopType shopType)
            {
                DescriptionDef itemDescription = __instance.GetItemDescription(item);

                if (itemDescription == null)
                {
                    Debug.LogError("Error :: Shop.GetPrice() GetItemDescription on: " + item.ID + " returned a NULL");
                    __result = 0;
                    return(false);
                }
                var   this_system = Traverse.Create(__instance).Field("system").GetValue <StarSystem>();
                float num         = (float)itemDescription.Cost;
                float shop        = this_system.Discount.Shop;

                if (num <= 0)
                {
                    __result = Mathf.RoundToInt(num);
                    return(false);
                }
                if (purchaseType != Shop.PurchaseType.Normal)
                {
                    num *= item.DiscountModifier;
                }
                int   num2 = Mathf.RoundToInt(num + (num * shop));
                float num3;
                var   this_shop = Traverse.Create(__instance).Field("Sim").GetValue <SimGameState>();

                if (shopType != Shop.ShopType.Faction)
                {
                    if (shopType != Shop.ShopType.BlackMarket)
                    {
                        num3 = this_shop.GetReputationShopAdjustment(this_system.Def.OwnerValue) * num;
                    }
                    else
                    {
                        num3 = this_shop.GetReputationShopAdjustment(FactionEnumeration.GetAuriganPiratesFactionValue()) * num;
                    }
                }
                else
                {
                    num3 = this_shop.GetReputationShopAdjustment(this_system.Def.FactionShopOwnerValue) * num;
                }
                __result = Mathf.CeilToInt(Mathf.Clamp((float)num2 + num3, 0f, 1E+09f));
                return(false);
            }
コード例 #6
0
        public (bool result, int bracketBonus) IsValidForAppearance(DateTime currentDate, string ownerValueName,
                                                                    Shop.ShopType shopType,
                                                                    List <string> planetTags,
                                                                    ProcGenStoreContentFeatureSettings settings)
        {
            // Check tags...
            if (RequiredPlanetTags.Any())
            {
                // Check at least one required tag is present...
                // Unless we're populating a black market, and they're configured to circumvent required restrictions...
                if (RequiredPlanetTags.Any() && !planetTags.Any(s => RequiredPlanetTags.Contains(s)) && !(shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventRequiredPlanetTags))
                {
                    return(false, 0);
                }
            }

            if (RestrictedPlanetTags.Any() && planetTags.Any(s => RestrictedPlanetTags.Contains(s)) && !(shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventRestrictedPlanetTags))
            {
                return(false, 0);
            }

            var wasPrototypedByOwner   = PrototypeDate != null && ownerValueName == PrototypeFaction;
            var wasProducedByOwner     = ProductionDate != null && ownerValueName == ProductionFaction;
            var wentExtinct            = ExtinctionDate != null;
            var wasReintroduced        = ReintroductionDate != null || CommonDate != null;
            var wasReintroducedByOwner = wasReintroduced && ownerValueName == ReintroductionFaction;
            var isNowCommon            = CommonDate == null ? false : currentDate >= CommonDate;

            // Careful... if it has no reintro details, we're inferring it was made common without having reintro, hence order of testing is important...
            if (wentExtinct && currentDate >= ExtinctionDate)
            {
                if (isNowCommon)
                {
                    return(true, 0);
                }

                if (wasReintroduced && currentDate >= ReintroductionDate)
                {
                    if (wasReintroducedByOwner)
                    {
                        return(true, 2);
                    }

                    if (shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventFactionRestrictions)
                    {
                        return(true, 0);
                    }
                }

                // Went extinct, and was either never reintroduced by the owner, or never went common (Skipped reintro)
                return(false, 0);
            }

            // Check prototype and production parameters...
            if (PrototypeDate == null && ProductionDate == null)
            {
                if (CommonDate == null)
                {
                    return(true, 0);
                }

                // Never went extinct, has no prototype or production date. If it's now common, return true with a bracket roll bonus, else fall through to false.
                return(isNowCommon, 2);
            }

            if (PrototypeDate != null)
            {
                if (currentDate < PrototypeDate)
                {
                    // Before it was ever prototyped...
                    return(false, 0);
                }

                if (ProductionDate != null && currentDate >= ProductionDate)
                {
                    // It was prototyped and subsequently produced, or it went common
                    if (!isNowCommon)
                    {
                        // Not common yet, not produced by owner, but black market stores can circumvent that requirement...
                        if (!wasProducedByOwner && shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventFactionRestrictions)
                        {
                            return(true, 0);
                        }

                        // Not common yet, but produced by owner...
                        return(wasProducedByOwner, 2);
                    }

                    // It's now common
                    return(true, 2);
                }

                // We're in the prototype period, the item was not produced by the owner, but blackmarkets can circumvent that (maybe)...
                if (!wasPrototypedByOwner && shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventFactionRestrictions)
                {
                    return(true, 0);
                }

                // We're in the prototype period, return true if the owner of the store is the prototype agent...
                return(wasPrototypedByOwner, 2);
            }

            // No valid periods or matching owners...
            return(false, 0);
        }
コード例 #7
0
        public static int GetPrice(this Shop shop, ShopDefItem item, Shop.PurchaseType purchaseType, Shop.ShopType shopType)
        {
            var price = UIControler.GetPrice(item);

            //Control.LogDebug(DInfo.Price, $"get_price for {item.ID}: {price}");
            return(price);
        }
コード例 #8
0
 private List <ProcGenStoreItem> ProduceStoreInventoryFromPotentialItemList(Shop.ShopType shopType, string ownerName,
                                                                            DateTime currentDate, ProcGenStoreContentFeatureSettings settings,
                                                                            List <ProcGenStoreContentFeatureSettings.PlanetTagModifier> planetTagModifiers,
                                                                            List <(ProcGenStoreItem StoreItem, int BracketBonus)> potentialInventoryItems)
コード例 #9
0
 static void Prefix(SG_Shop_Screen __instance, SG_Shop_Screen.StoreType newType, Shop.ShopType ___shopType, StarSystem ___theSystem, SimGameState ___simState)
 {
     try {
         if (newType == SG_Shop_Screen.StoreType.FactionStore && ___simState.IsFactionAlly(___theSystem.Owner, null))
         {
             ___theSystem.FactionShop.RefreshShop();
         }
     }
     catch (Exception e) {
         PersistentMapClient.Logger.LogError(e);
     }
 }