API

Assembly: Spark.Crafting Interface: ICraftingPlugin Implementation: CraftingPlugin

Interface

public interface ICraftingPlugin
{
    IReadOnlyList<CraftingRecipeEntry> GetAllRecipes();
    CraftingRecipeEntry FindRecipeById(string recipeId);
    CraftingRecipeEntry FindRecipeForItem(ItemEntry craftedItem);
    IReadOnlyList<CraftingRecipeEntry> FindRecipesForItem(ItemEntry craftedItem);
}

Methods

GetAllRecipes

IReadOnlyList<CraftingRecipeEntry> GetAllRecipes()

Returns all crafting recipes in the database.

FindRecipeById

CraftingRecipeEntry FindRecipeById(string recipeId)

Returns a specific recipe by ID, or null if not found.

FindRecipeForItem / FindRecipesForItem

Find recipes that produce a given item. FindRecipeForItem returns the first match; FindRecipesForItem returns all matches.

CraftingRecipeEntry

Extends SparkDatabaseEntry. Defines a crafting recipe.

Field
Type
Description

recipeCategory

CraftingRecipeCategoryEntry

Recipe category

craftedItem

ItemEntry

Item produced

craftDuration

float

Time to craft (seconds)

autoLearn

bool

Automatically known

requiredComponents

List<RecipeComponent>

Materials needed

onCraftTriggers

List<TriggerEntry>

Triggers executed on craft

RecipeComponent

Field
Type
Description

item

ItemEntry

Required material

amount

int

Quantity needed

CraftingRecipeCategoryEntry

Extends SparkDatabaseEntry. Groups recipes into categories for UI organization.

Events

Event
Description

RecipeLockedEvent

Recipe locked for a character

RecipeUnlockedEvent

Recipe unlocked for a character

RecipeCraftedEvent

Recipe successfully crafted

Commands

Command
Fields
Description

CraftItemCommand

crafter (GameObject), recipe (CraftingRecipeEntry)

Execute a craft

Save Data

CraftingSaveData

Extends SaveDataEntry. Tracks which recipes are unlocked.

Methods:

On InitializeDefaults(), all recipes with autoLearn = true are automatically unlocked.

Usage

Last updated

Was this helpful?