Planeshift
RecipeTreeNode Class Reference

This class represents a leaf in a recipe tree. More...

#include <recipetreenode.h>

Public Types

enum  RequirementParseType { REQ_CONCENTRATED, REQ_DISTRIBUTED }
 

Public Member Functions

void AddChild (RecipeTreeNode *child)
 Add a new child. More...
 
bool AddChild (RecipeTreeNode *child, Recipe *parent)
 Add a new child to a parent descending from this node. More...
 
void DumpRecipeTree ()
 Dump tree to console. More...
 
void DumpRecipeTree (int index)
 
void DumpRecipeTreeRecipes ()
 
void DumpRecipeTreeRecipes (int index)
 
RecipeTreeNodeGetNextRecipe ()
 Gets Next Recipe. More...
 
RecipeTreeNodeGetTreeRecipe (Recipe *searchRecipe)
 Gets a recipe from this tree. More...
 
bool IsLeaf ()
 Returns true if it's a leaf. More...
 
bool IsRoot ()
 Returns true if it's root. More...
 
bool ModifyWait (Recipe *theRecipe, int delta)
 Updates a wait time on one recipe. More...
 
 RecipeTreeNode (Recipe *newRecipe, int newCost, RecipeTreeNode *parent=NULL)
 Constructor. More...
 
bool RemoveChild (RecipeTreeNode *child)
 Remove a descendant. More...
 
bool RemoveChild (Recipe *child)
 Remove a child based on recipe data. More...
 
void UpdateWaitTimes (int delta)
 Update wait times. More...
 
 ~RecipeTreeNode ()
 

Public Attributes

csArray< RecipeTreeNode * > children
 Link to children nodes. More...
 
int cost
 Computed cost for this recipe. In regard of tribe. More...
 
int nextReq
 Next requirement that should be met. More...
 
int nextStep
 The next step which needs to be executed. More...
 
RecipeTreeNodeparent
 Link to parent node. More...
 
int priority
 The priority of this recipe. (Level in tree, where root = 0) More...
 
Reciperecipe
 The recipe this leaf is about. More...
 
RequirementParseType requirementParseType
 Holds the way the Recipe Manager should meet requirements. More...
 
int wait
 Wait time. More...
 

Static Public Attributes

static const char * RequirementParseTypeString []
 

Detailed Description

This class represents a leaf in a recipe tree.

The recipe tree is used by tribes to decide which action to take and in which order. It's more useful than a normal array because the recipes we want to execute first are nodes with no wait time and no children. Besides, it keeps the relations between recipes.

Definition at line 52 of file recipetreenode.h.

Member Enumeration Documentation

Enumerator
REQ_CONCENTRATED 
REQ_DISTRIBUTED 

Definition at line 55 of file recipetreenode.h.

Constructor & Destructor Documentation

RecipeTreeNode::RecipeTreeNode ( Recipe newRecipe,
int  newCost,
RecipeTreeNode parent = NULL 
)

Constructor.

RecipeTreeNode::~RecipeTreeNode ( )

Member Function Documentation

void RecipeTreeNode::AddChild ( RecipeTreeNode child)

Add a new child.

bool RecipeTreeNode::AddChild ( RecipeTreeNode child,
Recipe parent 
)

Add a new child to a parent descending from this node.

True if successful

void RecipeTreeNode::DumpRecipeTree ( )
inline

Dump tree to console.

Definition at line 119 of file recipetreenode.h.

void RecipeTreeNode::DumpRecipeTree ( int  index)
void RecipeTreeNode::DumpRecipeTreeRecipes ( )
inline

Definition at line 124 of file recipetreenode.h.

void RecipeTreeNode::DumpRecipeTreeRecipes ( int  index)
RecipeTreeNode* RecipeTreeNode::GetNextRecipe ( )

Gets Next Recipe.

(highest level leaf with no wait time) It's best to use it on the root node, since it runs a BFS and can ignore recipes otherwise.

RecipeTreeNode* RecipeTreeNode::GetTreeRecipe ( Recipe searchRecipe)

Gets a recipe from this tree.

bool RecipeTreeNode::IsLeaf ( )
inline

Returns true if it's a leaf.

Definition at line 98 of file recipetreenode.h.

bool RecipeTreeNode::IsRoot ( )
inline

Returns true if it's root.

Definition at line 92 of file recipetreenode.h.

bool RecipeTreeNode::ModifyWait ( Recipe theRecipe,
int  delta 
)

Updates a wait time on one recipe.

bool RecipeTreeNode::RemoveChild ( RecipeTreeNode child)

Remove a descendant.

bool RecipeTreeNode::RemoveChild ( Recipe child)

Remove a child based on recipe data.

True if successful

void RecipeTreeNode::UpdateWaitTimes ( int  delta)

Update wait times.

Member Data Documentation

csArray<RecipeTreeNode*> RecipeTreeNode::children

Link to children nodes.

Definition at line 73 of file recipetreenode.h.

int RecipeTreeNode::cost

Computed cost for this recipe. In regard of tribe.

Definition at line 67 of file recipetreenode.h.

int RecipeTreeNode::nextReq

Next requirement that should be met.

Definition at line 70 of file recipetreenode.h.

int RecipeTreeNode::nextStep

The next step which needs to be executed.

Definition at line 66 of file recipetreenode.h.

RecipeTreeNode* RecipeTreeNode::parent

Link to parent node.

Definition at line 72 of file recipetreenode.h.

int RecipeTreeNode::priority

The priority of this recipe. (Level in tree, where root = 0)

Definition at line 64 of file recipetreenode.h.

Recipe* RecipeTreeNode::recipe

The recipe this leaf is about.

Definition at line 63 of file recipetreenode.h.

RequirementParseType RecipeTreeNode::requirementParseType

Holds the way the Recipe Manager should meet requirements.

Definition at line 69 of file recipetreenode.h.

const char* RecipeTreeNode::RequirementParseTypeString[]
static

Definition at line 60 of file recipetreenode.h.

int RecipeTreeNode::wait

Wait time.

Definition at line 65 of file recipetreenode.h.


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