Planeshift
|
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. | |
bool | AddChild (RecipeTreeNode *child, Recipe *parent) |
Add a new child to a parent descending from this node. | |
void | DumpRecipeTree () |
Dump tree to console. | |
void | DumpRecipeTree (int index) |
void | DumpRecipeTreeRecipes (int index) |
void | DumpRecipeTreeRecipes () |
RecipeTreeNode * | GetNextRecipe () |
Gets Next Recipe. | |
RecipeTreeNode * | GetTreeRecipe (Recipe *searchRecipe) |
Gets a recipe from this tree. | |
bool | IsLeaf () |
Returns true if it's a leaf. | |
bool | IsRoot () |
Returns true if it's root. | |
bool | ModifyWait (Recipe *theRecipe, int delta) |
Updates a wait time on one recipe. | |
RecipeTreeNode (Recipe *newRecipe, int newCost, RecipeTreeNode *parent=NULL) | |
Constructor. | |
bool | RemoveChild (Recipe *child) |
Remove a child based on recipe data. | |
bool | RemoveChild (RecipeTreeNode *child) |
Remove a descendant. | |
void | UpdateWaitTimes (int delta) |
Update wait times. | |
~RecipeTreeNode () | |
Public Attributes | |
csArray< RecipeTreeNode * > | children |
Link to children nodes. | |
int | cost |
Computed cost for this recipe. In regard of tribe. | |
int | nextReq |
Next requirement that should be met. | |
int | nextStep |
The next step which needs to be executed. | |
RecipeTreeNode * | parent |
Link to parent node. | |
int | priority |
The priority of this recipe. (Level in tree, where root = 0) | |
Recipe * | recipe |
The recipe this leaf is about. | |
RequirementParseType | requirementParseType |
Holds the way the Recipe Manager should meet requirements. | |
int | wait |
Wait time. | |
Static Public Attributes | |
static const char * | RequirementParseTypeString [] |
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.
Definition at line 55 of file recipetreenode.h.
RecipeTreeNode::RecipeTreeNode | ( | Recipe * | newRecipe, |
int | newCost, | ||
RecipeTreeNode * | parent = NULL |
||
) |
Constructor.
RecipeTreeNode::~RecipeTreeNode | ( | ) |
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.
Updates a wait time on one recipe.
bool RecipeTreeNode::RemoveChild | ( | Recipe * | child | ) |
Remove a child based on recipe data.
True if successful
bool RecipeTreeNode::RemoveChild | ( | RecipeTreeNode * | child | ) |
Remove a descendant.
void RecipeTreeNode::UpdateWaitTimes | ( | int | delta | ) |
Update wait times.
Link to children nodes.
Definition at line 73 of file recipetreenode.h.
Computed cost for this recipe. In regard of tribe.
Definition at line 67 of file recipetreenode.h.
Next requirement that should be met.
Definition at line 70 of file recipetreenode.h.
The next step which needs to be executed.
Definition at line 66 of file recipetreenode.h.
Link to parent node.
Definition at line 72 of file recipetreenode.h.
The priority of this recipe. (Level in tree, where root = 0)
Definition at line 64 of file recipetreenode.h.
The recipe this leaf is about.
Definition at line 63 of file recipetreenode.h.
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.
Wait time.
Definition at line 65 of file recipetreenode.h.