private static bool Pre_CheckIfItemNeedsGate(Player player, GatedItemTypeMode mode, string itemName, ref bool __result) { if (ZNet.instance && ZNet.instance.IsServer()) { __result = PlayerDataSyncManager.CheckIfItemNeedsGate(mode, itemName); return(false); } return(true); }
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); }
private static bool CheckIfItemNeedsGate(Player player, GatedItemTypeMode mode, string itemName) { Debug.Log($"Checking if item ({itemName}) needs gating..."); switch (mode) { case GatedItemTypeMode.MustKnowRecipe: return(!player.IsRecipeKnown(itemName)); case GatedItemTypeMode.MustHaveCrafted: return(!player.m_knownMaterial.Contains(itemName)); default: return(false); } }
private static bool CheckIfItemNeedsGate(GatedItemTypeMode mode, string itemName) { //EpicLoot.Log($"Checking if item ({itemName}) needs gating..."); switch (mode) { case GatedItemTypeMode.MustKnowRecipe: return(!PlayerKnownManager.IsRecipeKnown(itemName)); case GatedItemTypeMode.MustHaveCrafted: return(!PlayerKnownManager.IsItemKnown(itemName)); default: return(false); } }
public static bool CheckIfItemNeedsGate(GatedItemTypeMode mode, string itemName) { bool result; switch (mode) { case GatedItemTypeMode.MustKnowRecipe: result = !playerKnownRecipes.Values.Any(recipes => recipes.Contains(itemName)); break; case GatedItemTypeMode.MustHaveCrafted: result = !playerKnownMaterial.Values.Any(material => material.Contains(itemName)); break; default: result = false; break; } Plugin.logger.LogInfo($"Overriding CheckIfItemNeedsGate (mode {mode} / item {itemName} / result {result}"); return(result); }
public static bool Prefix(ref GatedItemTypeMode __result) { __result = _gatedItemTypeModeConfig.Value; return(false); }