/// <summary>Get the fertilizer info for a dirt tile and fertilizer type.</summary> /// <param name="dirt">The dirt tile to check.</param> /// <param name="type">The fertilizer type to check for.</param> /// <param name="fertilizer">The fertilizer data.</param> /// <returns>Returns whether a valid fertilizer was found.</returns> public static bool TryGetFertilizer(this HoeDirt dirt, string type, out FertilizerData fertilizer) { fertilizer = null; return (dirt.modData.TryGetValue(type, out string rawLevel) && int.TryParse(rawLevel, out int level) && DirtHelper.TryGetFertilizer(type, level, out fertilizer)); }
/// <summary>Get the fertilizer info for an item ID.</summary> /// <param name="itemId">The item ID.</param> /// <param name="fertilizer">The fertilizer data.</param> /// <returns>Returns whether the item is a recognized fertilizer.</returns> public static bool TryGetFertilizer(int itemId, out FertilizerData fertilizer) { return(DirtHelper.FertilizersById.TryGetValue(itemId, out fertilizer)); }
/// <summary>Get the fertilizer info for a fertilizer type and level.</summary> /// <param name="key">The fertilizer type key.</param> /// <param name="level">The fertilizer level.</param> /// <param name="fertilizer">The fertilizer data.</param> /// <returns>Returns whether a valid fertilizer was found.</returns> public static bool TryGetFertilizer(string key, int level, out FertilizerData fertilizer) { return(DirtHelper.FertilizersByKeyAndLevel.TryGetValue($"{key}:{level}", out fertilizer)); }
/// <summary>Get whether the dirt has any fertilizer of the given type.</summary> /// <param name="dirt">The dirt to check.</param> /// <param name="fertilizer">The fertilizer data.</param> public static bool HasFertilizer(this HoeDirt dirt, FertilizerData fertilizer) { return(fertilizer != null && dirt.HasFertilizer(fertilizer.Key)); }