Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
CCraftDefManager Class Reference
+ Inheritance diagram for CCraftDefManager:
+ Collaboration diagram for CCraftDefManager:

Public Member Functions

 CCraftDefManager ()
 
virtual ~CCraftDefManager ()
 
virtual bool getCraftResult (CraftInput &input, CraftOutput &output, std::vector< ItemStack > &output_replacement, bool decrementInput, IGameDef *gamedef) const
 The main crafting function.
 
virtual std::vector< CraftDefinition * > getCraftRecipes (CraftOutput &output, IGameDef *gamedef, unsigned limit=0) const
 
virtual bool clearCraftsByOutput (const CraftOutput &output, IGameDef *gamedef)
 
virtual bool clearCraftsByInput (const CraftInput &input, IGameDef *gamedef)
 
virtual std::string dump () const
 
virtual void registerCraft (CraftDefinition *def, IGameDef *gamedef)
 
virtual void clear ()
 
virtual void initHashes (IGameDef *gamedef)
 
- Public Member Functions inherited from IWritableCraftDefManager
 IWritableCraftDefManager ()=default
 
virtual ~IWritableCraftDefManager ()=default
 
- Public Member Functions inherited from ICraftDefManager
 ICraftDefManager ()=default
 
virtual ~ICraftDefManager ()=default
 

Private Attributes

std::vector< std::unordered_map< u64, std::vector< CraftDefinition * > > > m_craft_defs
 
std::unordered_map< std::string, std::vector< CraftDefinition * > > m_output_craft_definitions
 

Constructor & Destructor Documentation

◆ CCraftDefManager()

CCraftDefManager::CCraftDefManager ( )
inline

◆ ~CCraftDefManager()

virtual CCraftDefManager::~CCraftDefManager ( )
inlinevirtual

References clear().

+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

virtual void CCraftDefManager::clear ( )
inlinevirtual

Implements IWritableCraftDefManager.

References craft_hash_type_max, m_craft_defs, and m_output_craft_definitions.

Referenced by ~CCraftDefManager().

+ Here is the caller graph for this function:

◆ clearCraftsByInput()

virtual bool CCraftDefManager::clearCraftsByInput ( const CraftInput & input,
IGameDef * gamedef )
inlinevirtual

Implements IWritableCraftDefManager.

References CRAFT_HASH_TYPE_UNHASHED, CraftInput::empty(), m_craft_defs, and m_output_craft_definitions.

+ Here is the call graph for this function:

◆ clearCraftsByOutput()

virtual bool CCraftDefManager::clearCraftsByOutput ( const CraftOutput & output,
IGameDef * gamedef )
inlinevirtual

◆ dump()

virtual std::string CCraftDefManager::dump ( ) const
inlinevirtual

◆ getCraftRecipes()

virtual std::vector< CraftDefinition * > CCraftDefManager::getCraftRecipes ( CraftOutput & output,
IGameDef * gamedef,
unsigned limit = 0 ) const
inlinevirtual

◆ getCraftResult()

virtual bool CCraftDefManager::getCraftResult ( CraftInput & input,
CraftOutput & output,
std::vector< ItemStack > & output_replacements,
bool decrementInput,
IGameDef * gamedef ) const
inlinevirtual

The main crafting function.

Parameters
inputThe input grid.
outputCraftOutput where the result is placed.
output_replacementsA vector of ItemStacks where replacements are placed if they cannot be placed in the input. Replacements can be placed in the input if the stack of the replaced item has a count of 1.
decrementInputIf true, consume or replace input items.
gamedef
Returns
true if a result was found, otherwise false.

Implements IWritableCraftDefManager.

References CraftDefinition::check(), craft_hash_type_max, craftGetItemNames(), CraftDefinition::decrementInput(), ItemStack::deSerialize(), CraftInput::empty(), getHashForGrid(), CraftDefinition::getOutput(), CraftDefinition::getPriority(), hash(), IGameDef::idef(), infostream, ItemStack::isKnown(), CraftOutput::item, CraftInput::items, m_craft_defs, and CraftDefinition::PRIORITY_NO_RECIPE.

+ Here is the call graph for this function:

◆ initHashes()

virtual void CCraftDefManager::initHashes ( IGameDef * gamedef)
inlinevirtual

Implements IWritableCraftDefManager.

References CRAFT_HASH_TYPE_UNHASHED, hash(), and m_craft_defs.

+ Here is the call graph for this function:

◆ registerCraft()

virtual void CCraftDefManager::registerCraft ( CraftDefinition * def,
IGameDef * gamedef )
inlinevirtual

Implements IWritableCraftDefManager.

References CRAFT_HASH_TYPE_UNHASHED, craftGetItemName(), CraftDefinition::dump(), CraftDefinition::getOutput(), CraftOutput::item, m_craft_defs, m_output_craft_definitions, and TRACESTREAM.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_craft_defs

std::vector<std::unordered_map<u64, std::vector<CraftDefinition*> > > CCraftDefManager::m_craft_defs
private

◆ m_output_craft_definitions

std::unordered_map<std::string, std::vector<CraftDefinition*> > CCraftDefManager::m_output_craft_definitions
private

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