Skip to content

Instantly share code, notes, and snippets.

@TheKiiiing
Last active March 10, 2025 21:06
Show Gist options
  • Save TheKiiiing/53a37e8bbb48d8a24c8e8b21b9da37ac to your computer and use it in GitHub Desktop.
Save TheKiiiing/53a37e8bbb48d8a24c8e8b21b9da37ac to your computer and use it in GitHub Desktop.
// <auto-generated />
/*
© Copyright the_kiiiing
You are free to use this code in your own plugins.
*/
using JetBrains.Annotations;
using Oxide.Core.Plugins;
using UnityEngine;
namespace PluginComponents.LoottableApi
{
/// <summary>
/// Provides a strongly typed interface for Loottable
/// </summary>
public static class LoottableApi
{
private static Plugin PluginInstance => Oxide.Core.Interface.Oxide.RootPluginManager.GetPlugin("Loottable");
/// <summary>
/// Clear all presets previously registered by this plugin.
/// If a preset is registered with a key that has been used by another preset in the past,
/// the config of the old preset will be restored upon registration.
/// This allows you to remove presets and re-register them later without losing the config
/// </summary>
/// <param name="plugin">The calling plugin</param>
public static void ClearPresets(Plugin plugin)
{
PluginInstance?.Call("ClearPresets", plugin);
}
/// <summary>
/// Creates a new category. All presets created below will be in this category
/// </summary>
/// <param name="plugin">The calling plugin</param>
/// <param name="displayName">Name of the category. Set to <c>null</c> for no category</param>
public static void CreatePresetCategory(Plugin plugin, string displayName)
{
PluginInstance?.Call("CreatePresetCategory", plugin, displayName);
}
/// <summary>
/// Create a new loot preset for this plugin
/// </summary>
/// <param name="plugin">The calling plugin</param>
/// <param name="key">The key of this preset. Use it to reference this preset when adding lootables</param>
/// <param name="displayName">Name of the preset that will be displayed in the Loottable UI</param>
/// <param name="iconOrUrl">Image for this preset. Can be an icon key or a URL</param>
/// <param name="isNpc">Enables additional NPC specific config options when set to <c>true</c></param>
public static void CreatePreset(Plugin plugin, string key, string displayName, string iconOrUrl, bool isNpc = false)
{
PluginInstance?.Call("CreatePreset", plugin, key, displayName, iconOrUrl, isNpc);
}
/// <summary>
/// Assign a preset to the given container.
/// If the container has already spawned, its current loot will be replaced.
/// </summary>
/// <param name="plugin">The calling plugin</param>
/// <param name="key">The key of the preset</param>
/// <param name="container">The item container to assign the preset</param>
/// <returns><c>true</c> when preset was applied successfully, otherwise <c>false</c>.
/// Also returns <c>false</c> if preset was disabled by the user in Loottable</returns>
public static bool AssignPreset(Plugin plugin, string key, ItemContainer container)
{
return PluginInstance?.Call<bool>("AssignPreset", plugin, key, container) ?? false;
}
/// <summary>
/// Assign a preset to the given NPC.
/// </summary>
/// <param name="plugin">The calling plugin</param>
/// <param name="npc">The NPC to assign the preset</param>
/// <param name="key">The key of the preset</param>
/// <returns><c>true</c> when preset was applied successfully, otherwise <c>false</c>.
/// Also returns <c>false</c> if preset was disabled by the user in Loottable</returns>
public static bool AssignPreset(Plugin plugin, string key, ScientistNPC npc)
{
return PluginInstance?.Call<bool>("AssignPreset", plugin, key, npc) ?? false;
}
/// <summary>
/// Assign a preset to the given NPC.
/// </summary>
/// <param name="plugin">The calling plugin</param>
/// <param name="npc">The NPC to assign the preset</param>
/// <param name="key">The key of the preset</param>
/// <returns><c>true</c> when preset was applied successfully, otherwise <c>false</c>.
/// Also returns <c>false</c> if preset was disabled by the user in Loottable</returns>
public static bool AssignPreset(Plugin plugin, string key, ScarecrowNPC npc)
{
return PluginInstance?.Call<bool>("AssignPreset", plugin, key, npc) ?? false;
}
/// <summary>
/// Assign a preset to the given container.
/// If the container has already spawned, its current loot will be replaced.
/// </summary>
/// <param name="plugin">The calling plugin</param>
/// <param name="container">The container to assign the preset</param>
/// <param name="key">The key of the preset</param>
/// <returns><c>true</c> when preset was applied successfully, otherwise <c>false</c>.
/// Also returns <c>false</c> if preset was disabled by the user in Loottable</returns>
public static bool AssignPreset(Plugin plugin, string key, StorageContainer container)
{
return PluginInstance?.Call<bool>("AssignPreset", plugin, key, container) ?? false;
}
/// <summary>
/// Remove all custom items previously registered by this plugin. Also removes persistent items
/// </summary>
/// <param name="plugin">The creator plugin of the custom items</param>
public static void ClearCustomItems(Plugin plugin)
{
PluginInstance?.Call("ClearCustomItems", plugin);
}
/// <summary>
/// Add a new custom item
/// </summary>
/// <param name="plugin">The creator plugin of the custom item</param>
/// <param name="itemId">Item id of the custom item</param>
/// <param name="skinId">Skin id of the custom item</param>
/// <param name="customName">Custom display name of the item</param>
/// <param name="persistent">If set to true, the custom item will remain after the creator plugin has been unloaded</param>
public static void AddCustomItem(Plugin plugin, int itemId, ulong skinId, string customName = null, bool persistent = false)
{
PluginInstance?.Call("AddCustomItem", plugin, itemId, skinId, customName, persistent);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment