Пример #1
0
        public static void Initialize(RecipesConfig config)
        {
            Config = config;

            if (EpicLoot.IsObjectDBReady())
            {
                SetupRecipes();
            }
        }
Пример #2
0
        public static string GetGatedItemID(string itemID, GatedItemTypeMode mode)
        {
            if (string.IsNullOrEmpty(itemID))
            {
                EpicLoot.LogError($"Tried to get gated itemID with null or empty itemID!");
                return(null);
            }

            if (mode == GatedItemTypeMode.Unlimited)
            {
                return(itemID);
            }

            if (!EpicLoot.IsObjectDBReady())
            {
                EpicLoot.LogError($"Tried to get gated itemID ({itemID}) but ObjectDB is not initialized!");
                return(null);
            }

            if (!ItemInfoByID.TryGetValue(itemID, out var info))
            {
                return(itemID);
            }

            var itemName = GetItemName(itemID);

            if (string.IsNullOrEmpty(itemName))
            {
                return(null);
            }

            while (CheckIfItemNeedsGate(mode, itemName))
            {
                //EpicLoot.Log("Yes...");
                var index = info.Items.IndexOf(itemID);
                if (index < 0)
                {
                    // Items list is empty, no need to gate any items from of this type
                    return(itemID);
                }
                if (index == 0)
                {
                    //EpicLoot.Log($"Reached end of gated list. Fallback is ({info.Fallback}), returning ({(string.IsNullOrEmpty(info.Fallback) ? itemID : info.Fallback)}){(string.IsNullOrEmpty(info.Fallback) ? "" : " (fallback)")}");
                    return(string.IsNullOrEmpty(info.Fallback) ? itemID : info.Fallback);
                }

                itemID   = info.Items[index - 1];
                itemName = GetItemName(itemID);
                //EpicLoot.Log($"Next lower tier item is ({itemID})");
            }

            //EpicLoot.Log($"No, return ({itemID})");
            return(itemID);
        }