public static CustomItem SetItem(string id, Sprite sprite, CustomNameInfo name, CustomNameInfo description, Action<InvItem> setupDetails);
// Creating a sprite from byte[] (.png image)
Sprite sprite = RogueUtilities.ConvertToSprite(Properties.Resources.MoneyContainer);
CustomItem moneyContainer = RogueLibs.SetItem("money-container", sprite,
new CustomNameInfo("Money Container"),
new CustomNameInfo("Gives you some money."),
item =>
{ // See InvItem.SetupDetails() for more info
item.itemType = "Consumable";
item.Categories.Add("Technology");
item.itemValue = 20;
item.initCount = 10;
item.rewardCount = 10;
item.stackable = true;
item.goesInToolbar = true;
item.cantBeCloned = true;
// item.LoadItemSprite("my-item"); - RogueLibs loads the sprite automatically
});
public static bool DeleteItem(string id);
public static bool DeleteItem(CustomItem customItem);
You probably won't need these.
You can get your CustomItem's Id:
public string Id { get; }
You can get/set your CustomItem's SetupDetails delegate:
public Action<InvItem> SetupDetails { get; set; }
You can get/set your CustomItem's Sprite:
public Sprite Sprite { get; set; }
And your CustomItem's Name and Description:
public CustomName Name { get; set; }
public CustomName Description { get; set; }
public Action<InvItem, Agent> UseItem { get; set; }
CustomItem moneyContainer = RogueLibs.SetItem(...);
moneyContainer.UseItem = (item, agent) =>
{
agent.inventory.AddItem("Money", UnityEngine.Random.Range(5, 40));
item.database.SubtractFromItemCount(item, 1);
new ItemFunctions().UseItemAnim(item, agent);
};
public Func<InvItem, Agent, InvItem, bool> CombineFilter { get; set; }
public Action<InvItem, Agent, InvItem, int> CombineItem { get; set; }
CustomItem repairer = RogueLibs.SetItem(...);
repairer.CombineFilter = (item, agent, otherItem) => otherItem.itemType == "WeaponMelee" && otherItem.invItemCount < otherItem.rewardCount;
// Item can be repaired only if it is a melee weapon and has less than 200 (default) durability
repairer.CombineItem = (item, agent, otherItem, slotNum) =>
{
otherItem.invItemCount += UnityEngine.Random.Range(30, 50); // Repair by a random amount
if (otherItem.invItemCount > otherItem.rewardCount)
otherItem.invItemCount = otherItem.rewardCount;
if (!item.gc.challenges.Contains("NoLimits"))
agent.agentInvDatabase.SubtractFromItemCount(item, 1);
item.gc.audioHandler.Play(agent, "CombineItem");
if (item.invItemCount < 1) // Stop combining if the repairer has 0 uses left
{
agent.mainGUI.invInterface.HideDraggedItem();
agent.mainGUI.invInterface.HideTarget();
}
};
public Func<InvItem, Agent, PlayfieldObject, bool> TargetFilter { get; set; }
public Action<InvItem, Agent, PlayfieldObject> TargetObject { get; set; }
public CustomName HoverText { get; set; }
public void SetHoverText(CustomNameInfo info);
CustomItem remoteGiantizer = RogueLibs.SetItem(...);
remoteGiantizer.TargetFilter = (item, agent, target) => target is Agent a && !a.dead;
// Object can be targeted only if it is an Agent and is not dead
remoteGiantizer.TargetObject = (item, agent, target) =>
{
item.invInterface.HideTarget();
Agent a = (Agent)target;
a.statusEffects.AddStatusEffect("Giant", true, true, 999999);
item.database.SubtractFromItemCount(item, 1);
}
remoteGiantizer.SetHoverText(new CustomNameInfo("Giantize!"));
public Dictionary<string, int> SpawnDictionary { get; set; }
public void AddSpawnList(string listName, int spawnChance);
CustomItem vodka = RogueLibs.SetItem(...);
vodka.AddSpawnList("Alcohol2", 3);
vodka.AddSpawnList("DefaultChallenge", 3);
// For more info, see RandomItems.fillItems()
Or, you can edit SpawnDictionary directly:
CustomItem vodka = RogueLibs.SetItem(...);
vodka.SpawnDictionary.Add("Alcohol2", 3);
vodka.SpawnDictionary.Add("DefaultChallenge", 1);
You can also use ECTD (Edit Characters Through Description) mod to quickly test your items, just type ++<Your Item ID>
in your custom character's description.