Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
cCraftingRecipes Class Reference

#include <CraftingRecipes.h>

Classes

struct  cRecipe
 A single recipe, stored. More...
 
struct  cRecipeSlot
 

Public Member Functions

 cCraftingRecipes (void)
 
void GetRecipe (cPlayer &a_Player, cCraftingGrid &a_CraftingGrid, cCraftingRecipe &a_Recipe)
 Returns the recipe for current crafting grid. More...
 
 ~cCraftingRecipes ()
 

Static Public Attributes

static const int MAX_GRID_HEIGHT = 3
 
static const int MAX_GRID_WIDTH = 3
 

Protected Types

typedef std::vector< cRecipe * > cRecipes
 
typedef std::vector< cRecipeSlotcRecipeSlots
 

Protected Member Functions

void AddRecipeLine (int a_LineNum, const AString &a_RecipeLine)
 Parses the recipe line and adds it into m_Recipes. More...
 
void ClearRecipes (void)
 
cRecipeFindRecipe (const cItem *a_CraftingGrid, int a_GridWidth, int a_GridHeight)
 Finds a recipe matching the crafting grid. More...
 
cRecipeFindRecipeCropped (const cItem *a_CraftingGrid, int a_GridWidth, int a_GridHeight, int a_GridStride)
 Same as FindRecipe, but the grid is guaranteed to be of minimal dimensions needed. More...
 
void HandleDyedLeather (const cItem *a_CraftingGrid, cCraftingRecipes::cRecipe *a_Recipe, int a_GridStride, int a_GridWidth, int a_GridHeight)
 Searches for anything dye related for leather, calculates the appropriate color value, and sets the resulting value. More...
 
void HandleFireworks (const cItem *a_CraftingGrid, cCraftingRecipes::cRecipe *a_Recipe, int a_GridStride, int a_OffsetX, int a_OffsetY)
 Searches for anything firework related, and does the data setting if appropriate. More...
 
void LoadRecipes (void)
 
cRecipeMatchRecipe (const cItem *a_CraftingGrid, int a_GridWidth, int a_GridHeight, int a_GridStride, const cRecipe *a_Recipe, int a_OffsetX, int a_OffsetY)
 Checks if the grid matches the specified recipe, offset by the specified offsets. More...
 
void NormalizeIngredients (cRecipe *a_Recipe)
 Moves the recipe to top-left corner, sets its MinWidth / MinHeight. More...
 
bool ParseIngredient (const AString &a_String, cRecipe *a_Recipe)
 Parses one ingredient and adds it to the specified recipe. More...
 
bool ParseItem (const AString &a_String, cItem &a_Item)
 Parses an item string in the format "<ItemType>[^<Damage>]", returns true if successful. More...
 

Protected Attributes

cRecipes m_Recipes
 

Detailed Description

Definition at line 108 of file CraftingRecipes.h.

Member Typedef Documentation

typedef std::vector<cRecipe *> cCraftingRecipes::cRecipes
protected

Definition at line 140 of file CraftingRecipes.h.

typedef std::vector<cRecipeSlot> cCraftingRecipes::cRecipeSlots
protected

Definition at line 127 of file CraftingRecipes.h.

Constructor & Destructor Documentation

cCraftingRecipes::cCraftingRecipes ( void  )

Definition at line 272 of file CraftingRecipes.cpp.

cCraftingRecipes::~cCraftingRecipes ( )

Definition at line 281 of file CraftingRecipes.cpp.

Member Function Documentation

void cCraftingRecipes::AddRecipeLine ( int  a_LineNum,
const AString a_RecipeLine 
)
protected

Parses the recipe line and adds it into m_Recipes.

a_LineNum is used for diagnostic warnings only

Definition at line 375 of file CraftingRecipes.cpp.

void cCraftingRecipes::ClearRecipes ( void  )
protected

Definition at line 362 of file CraftingRecipes.cpp.

cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe ( const cItem a_CraftingGrid,
int  a_GridWidth,
int  a_GridHeight 
)
protected

Finds a recipe matching the crafting grid.

Returns a newly allocated recipe (with all its coords set) or nullptr if not found. Caller must delete return value!

Definition at line 591 of file CraftingRecipes.cpp.

cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipeCropped ( const cItem a_CraftingGrid,
int  a_GridWidth,
int  a_GridHeight,
int  a_GridStride 
)
protected

Same as FindRecipe, but the grid is guaranteed to be of minimal dimensions needed.

Definition at line 634 of file CraftingRecipes.cpp.

void cCraftingRecipes::GetRecipe ( cPlayer a_Player,
cCraftingGrid a_CraftingGrid,
cCraftingRecipe a_Recipe 
)

Returns the recipe for current crafting grid.

Doesn't modify the grid. Clears a_Recipe if no recipe found.

Definition at line 290 of file CraftingRecipes.cpp.

void cCraftingRecipes::HandleDyedLeather ( const cItem a_CraftingGrid,
cCraftingRecipes::cRecipe a_Recipe,
int  a_GridStride,
int  a_GridWidth,
int  a_GridHeight 
)
protected

Searches for anything dye related for leather, calculates the appropriate color value, and sets the resulting value.

Definition at line 882 of file CraftingRecipes.cpp.

void cCraftingRecipes::HandleFireworks ( const cItem a_CraftingGrid,
cCraftingRecipes::cRecipe a_Recipe,
int  a_GridStride,
int  a_OffsetX,
int  a_OffsetY 
)
protected

Searches for anything firework related, and does the data setting if appropriate.

Definition at line 801 of file CraftingRecipes.cpp.

void cCraftingRecipes::LoadRecipes ( void  )
protected

Definition at line 321 of file CraftingRecipes.cpp.

cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe ( const cItem a_CraftingGrid,
int  a_GridWidth,
int  a_GridHeight,
int  a_GridStride,
const cRecipe a_Recipe,
int  a_OffsetX,
int  a_OffsetY 
)
protected

Checks if the grid matches the specified recipe, offset by the specified offsets.

Returns a matched cRecipe * if so, or nullptr if not matching. Caller must delete the return value!

Definition at line 664 of file CraftingRecipes.cpp.

void cCraftingRecipes::NormalizeIngredients ( cCraftingRecipes::cRecipe a_Recipe)
protected

Moves the recipe to top-left corner, sets its MinWidth / MinHeight.

Definition at line 550 of file CraftingRecipes.cpp.

bool cCraftingRecipes::ParseIngredient ( const AString a_String,
cRecipe a_Recipe 
)
protected

Parses one ingredient and adds it to the specified recipe.

Returns true if successful.

Definition at line 474 of file CraftingRecipes.cpp.

bool cCraftingRecipes::ParseItem ( const AString a_String,
cItem a_Item 
)
protected

Parses an item string in the format "<ItemType>[^<Damage>]", returns true if successful.

Definition at line 441 of file CraftingRecipes.cpp.

Member Data Documentation

cRecipes cCraftingRecipes::m_Recipes
protected

Definition at line 142 of file CraftingRecipes.h.

const int cCraftingRecipes::MAX_GRID_HEIGHT = 3
static

Definition at line 112 of file CraftingRecipes.h.

const int cCraftingRecipes::MAX_GRID_WIDTH = 3
static

Definition at line 111 of file CraftingRecipes.h.


The documentation for this class was generated from the following files: