Skip to main content

RecipeContext

Trait RecipeContext 

Source
pub trait RecipeContext {
    // Required methods
    fn unlock(&self, id: &RecipeId, reason: UnlockReason);
    fn lock(&self, id: &RecipeId);
    fn has(&self, id: &RecipeId) -> bool;
    fn unlocked(&self) -> Vec<RecipeId>;
}
Expand description

Per-player recipe-book state.

Plugins use this to grant or revoke recipes for the current player — the dispatch context’s player. Mutations queue a deferred response that the game loop translates into the appropriate S2C recipe-book packet and dispatches RecipeUnlockedEvent / RecipeLockedEvent after commit.

has and unlocked are synchronous reads against the player’s KnownRecipes component.

Required Methods§

Source

fn unlock(&self, id: &RecipeId, reason: UnlockReason)

Unlocks the recipe for the current player.

Queues a Recipe Book Add packet, inserts into the player’s KnownRecipes, and dispatches RecipeUnlockedEvent at Post. No-op if the recipe is already unlocked.

Source

fn lock(&self, id: &RecipeId)

Locks the recipe for the current player.

Queues a Recipe Book Remove packet, removes from the player’s KnownRecipes, and dispatches RecipeLockedEvent at Post. No-op if the recipe is not currently unlocked.

Source

fn has(&self, id: &RecipeId) -> bool

Returns true if the recipe is unlocked for the current player.

Source

fn unlocked(&self) -> Vec<RecipeId>

Returns a snapshot of every recipe id the player has unlocked.

Allocates a new Vec — callers that only need to test for membership should prefer has.

Implementors§