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

#include <SlotArea.h>

Inheritance diagram for cSlotAreaCrafting:
Inheritance graph
[legend]
Collaboration diagram for cSlotAreaCrafting:
Collaboration graph
[legend]

Public Member Functions

void ClearCraftingGrid (cPlayer &a_Player)
 Clear the crafting grid. More...
 
virtual void Clicked (cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
 Called when a player clicks in the window. More...
 
 cSlotAreaCrafting (int a_GridSize, cWindow &a_ParentWindow)
 a_GridSize is allowed to be only 2 or 3 More...
 
virtual void DblClicked (cPlayer &a_Player, int a_SlotNum) override
 Called from Clicked when the action is a caDblClick. More...
 
virtual void DistributeStack (cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
 Called to store as much of a_ItemStack in the area as possible. More...
 
void LoadRecipe (cPlayer &a_Player, UInt32 a_RecipeId)
 Loads the given Recipe into the crafting grid. More...
 
virtual void OnPlayerRemoved (cPlayer &a_Player) override
 Called when one of the players closes the parent window. More...
 
virtual void SetSlot (int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
 Called to set an item in the specified slot for the specified player. More...
 
- Public Member Functions inherited from cSlotAreaTemporary
 cSlotAreaTemporary (int a_NumSlots, cWindow &a_ParentWindow)
 
virtual const cItemGetSlot (int a_SlotNum, cPlayer &a_Player) const override
 Called to retrieve an item in the specified slot for the specified player. More...
 
virtual void OnPlayerAdded (cPlayer &a_Player) override
 Called when a new player opens the same parent window. More...
 
void TossItems (cPlayer &a_Player, int a_Begin, int a_End)
 Tosses the player's items in slots [a_Begin, a_End) (ie. More...
 
- Public Member Functions inherited from cSlotArea
virtual bool CollectItemsToHand (cItem &a_Dragging, cPlayer &a_Player, bool a_CollectFullStacks)
 Called on DblClicking to collect all stackable items into hand. More...
 
 cSlotArea (int a_NumSlots, cWindow &a_ParentWindow)
 
virtual void DropClicked (cPlayer &a_Player, int a_SlotNum, bool a_DropStack)
 Called from Clicked when the action is a drop click. More...
 
int GetNumSlots (void) const
 
virtual void MiddleClicked (cPlayer &a_Player, int a_SlotNum)
 Called from Clicked when the action is a middleclick. More...
 
virtual void NumberClicked (cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction)
 Called from Clicked when the action is a number click. More...
 
virtual void ShiftClicked (cPlayer &a_Player, int a_SlotNum, const cItem &a_ClickedItem)
 Called from Clicked when the action is a shiftclick (left or right) More...
 
virtual ~cSlotArea ()
 

Protected Types

typedef std::list< std::pair< UInt32, cCraftingRecipe > > cRecipeMap
 Maps player's EntityID -> current recipe. More...
 
- Protected Types inherited from cSlotAreaTemporary
using cItemMap = std::map< UInt32, std::vector< cItem > >
 

Protected Member Functions

void ClickedResult (cPlayer &a_Player)
 Handles a click in the result slot. More...
 
void DropClickedResult (cPlayer &a_Player)
 Handles a drop-click in the result slot. More...
 
cCraftingRecipeGetRecipeForPlayer (cPlayer &a_Player)
 Retrieves the recipe for the specified player from the map, or creates one if not found. More...
 
void HandleCraftItem (const cItem &a_Result, cPlayer &a_Player)
 Called after an item has been crafted to handle statistics e.t.c. More...
 
void ShiftClickedResult (cPlayer &a_Player)
 Handles a shift-click in the result slot. More...
 
void UpdateRecipe (cPlayer &a_Player)
 Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player. More...
 
- Protected Member Functions inherited from cSlotAreaTemporary
cItemGetPlayerSlots (cPlayer &a_Player)
 Returns the pointer to the slot array for the player specified. More...
 

Protected Attributes

int m_GridSize
 
cRecipeMap m_Recipes
 
- Protected Attributes inherited from cSlotAreaTemporary
cItemMap m_Items
 
- Protected Attributes inherited from cSlotArea
int m_NumSlots
 
cWindowm_ParentWindow
 

Private Types

using Super = cSlotAreaTemporary
 

Detailed Description

Definition at line 257 of file SlotArea.h.

Member Typedef Documentation

◆ cRecipeMap

typedef std::list<std::pair<UInt32, cCraftingRecipe> > cSlotAreaCrafting::cRecipeMap
protected

Maps player's EntityID -> current recipe.

Not a std::map because cCraftingGrid needs proper constructor params.

Definition at line 285 of file SlotArea.h.

◆ Super

Definition at line 260 of file SlotArea.h.

Constructor & Destructor Documentation

◆ cSlotAreaCrafting()

cSlotAreaCrafting::cSlotAreaCrafting ( int  a_GridSize,
cWindow a_ParentWindow 
)

a_GridSize is allowed to be only 2 or 3

Definition at line 507 of file SlotArea.cpp.

Member Function Documentation

◆ ClearCraftingGrid()

void cSlotAreaCrafting::ClearCraftingGrid ( cPlayer a_Player)

Clear the crafting grid.

Definition at line 833 of file SlotArea.cpp.

◆ Clicked()

void cSlotAreaCrafting::Clicked ( cPlayer a_Player,
int  a_SlotNum,
eClickAction  a_ClickAction,
const cItem a_ClickedItem 
)
overridevirtual

Called when a player clicks in the window.

Parameters taken from the click packet.

Reimplemented from cSlotArea.

Definition at line 518 of file SlotArea.cpp.

◆ ClickedResult()

void cSlotAreaCrafting::ClickedResult ( cPlayer a_Player)
protected

Handles a click in the result slot.

Crafts using the current recipe, if possible.

Definition at line 615 of file SlotArea.cpp.

◆ DblClicked()

void cSlotAreaCrafting::DblClicked ( cPlayer a_Player,
int  a_SlotNum 
)
overridevirtual

Called from Clicked when the action is a caDblClick.

Reimplemented from cSlotArea.

Definition at line 552 of file SlotArea.cpp.

◆ DistributeStack()

void cSlotAreaCrafting::DistributeStack ( cItem a_ItemStack,
cPlayer a_Player,
bool  a_ShouldApply,
bool  a_KeepEmptySlots,
bool  a_BackFill 
)
overridevirtual

Called to store as much of a_ItemStack in the area as possible.

a_ItemStack is modified to reflect the change. The default implementation searches each slot for available space and distributes the stack there. if a_ShouldApply is true, the changes are written into the slots; if a_ShouldApply is false, only a_ItemStack is modified to reflect the number of fits (for fit-testing purposes) If a_KeepEmptySlots is true, empty slots will be skipped and won't be filled

Reimplemented from cSlotArea.

Definition at line 602 of file SlotArea.cpp.

◆ DropClickedResult()

void cSlotAreaCrafting::DropClickedResult ( cPlayer a_Player)
protected

Handles a drop-click in the result slot.

Definition at line 707 of file SlotArea.cpp.

◆ GetRecipeForPlayer()

cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer ( cPlayer a_Player)
protected

Retrieves the recipe for the specified player from the map, or creates one if not found.

Definition at line 740 of file SlotArea.cpp.

◆ HandleCraftItem()

void cSlotAreaCrafting::HandleCraftItem ( const cItem a_Result,
cPlayer a_Player 
)
protected

Called after an item has been crafted to handle statistics e.t.c.

Definition at line 762 of file SlotArea.cpp.

◆ LoadRecipe()

void cSlotAreaCrafting::LoadRecipe ( cPlayer a_Player,
UInt32  a_RecipeId 
)

Loads the given Recipe into the crafting grid.

Definition at line 784 of file SlotArea.cpp.

◆ OnPlayerRemoved()

void cSlotAreaCrafting::OnPlayerRemoved ( cPlayer a_Player)
overridevirtual

Called when one of the players closes the parent window.

The window already doesn't track the player. CS-locked.

Reimplemented from cSlotAreaTemporary.

Definition at line 566 of file SlotArea.cpp.

◆ SetSlot()

void cSlotAreaCrafting::SetSlot ( int  a_SlotNum,
cPlayer a_Player,
const cItem a_Item 
)
overridevirtual

Called to set an item in the specified slot for the specified player.

Reimplemented from cSlotAreaTemporary.

Definition at line 588 of file SlotArea.cpp.

◆ ShiftClickedResult()

void cSlotAreaCrafting::ShiftClickedResult ( cPlayer a_Player)
protected

Handles a shift-click in the result slot.

Crafts using the current recipe until it changes or no more space for result.

Definition at line 658 of file SlotArea.cpp.

◆ UpdateRecipe()

void cSlotAreaCrafting::UpdateRecipe ( cPlayer a_Player)
protected

Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player.

Definition at line 728 of file SlotArea.cpp.

Member Data Documentation

◆ m_GridSize

int cSlotAreaCrafting::m_GridSize
protected

Definition at line 287 of file SlotArea.h.

◆ m_Recipes

cRecipeMap cSlotAreaCrafting::m_Recipes
protected

Definition at line 288 of file SlotArea.h.


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