Craft
🛠️ Craft Class
Functions as a blueprint for crafts.
Namespace:
Esper.Inventool.Crafting
Access:public
Type:class
Inherits:InventoolObject
📦 Fields
private
pathInResources
string
(const)
The path used with Resources.LoadAll
to find craft assets.
public
searchableName
string
The name of this craft for the purposes of searching inside the editor.
public
combineItems
List<ItemStack>
The items required to craft the result item.
public
resultItem
ItemStack
The item that is created when the required items are combined.
public
cost
Currency
The amount this craft will cost.
🔍 Properties
public
DatabaseRecord
CraftRecord
The database record of this craft.
public
CraftingCode
string
A generated code created with crafting item combinations for craft lookups.
🧰 Methods
public
Clean()
void
Cleans the object by removing deleted items.
public
override Save()
void
Saves the object (editor only).
public
CanCraft(List<ItemStack> items)
bool
If this craft can be crafted with the provided list of items.
public
CanCraft(ItemStack[] items)
bool
If this craft can be crafted with the provided array of items.
public
SetData(Craft craft)
void
Sets the data from another craft.
public static
Create()
Craft
Creates a new instance of a craft (editor only).
public
UpdateAssetName()
void
Updates the name of the asset (editor only).
public static
CreateCopy(Craft original)
Craft
Creates a copy of another craft.
private static
GetID()
int
Returns an unused ID.
Creating Crafts
It's not at all recommended to create crafts at runtime, but it is possible. Craft
's are scriptable objects which cannot be created as assets at runtime for later use.
Craft myCraft = ScriptableObject.CreateInstance<Craft>();
Getting Crafts
Crafts created through the Crafting tab can be retrieved at runtime.
Get a Single Craft
You can get a Craft
by its ID, name, or code with the Inventool.GetCraft
method.
Craft myCraft = Inventool.GetCraft("My Craft Name");
Get All Crafts
var myCrafts = Inventool.GetAllCrafts();
Requirements Checking
You can check if a list of items matches the requirement of the Craft
to craft the result item.
bool result = myCraft.CanCraft(myListOfItemStacks);
Last updated