Planeshift
|
00001 /* 00002 * recipetreenode.h 00003 * 00004 * Copyright (C) 2011 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 00020 #ifndef __RECIPETREENODE_H__ 00021 #define __RECIPETREENODE_H__ 00022 00023 //============================================================================= 00024 // Crystal Space Includes 00025 //============================================================================= 00026 #include <csutil/array.h> 00027 //============================================================================= 00028 // Project Includes 00029 //============================================================================= 00030 00031 //============================================================================= 00032 // Local Includes 00033 //============================================================================= 00034 #include "tribe.h" 00035 #include "recipe.h" 00036 00041 class Recipe; 00042 00043 #define CYCLIC_RECIPE_PRIORITY 100 00044 00052 class RecipeTreeNode 00053 { 00054 public: 00055 typedef enum 00056 { 00057 REQ_CONCENTRATED, 00058 REQ_DISTRIBUTED 00059 } RequirementParseType; 00060 static const char* RequirementParseTypeString[]; 00061 00062 00063 Recipe* recipe; 00064 int priority; 00065 int wait; 00066 int nextStep; 00067 int cost; 00068 00069 RequirementParseType requirementParseType; 00070 int nextReq; 00071 00072 RecipeTreeNode* parent; 00073 csArray<RecipeTreeNode*> children; 00074 00076 RecipeTreeNode(Recipe* newRecipe, int newCost, RecipeTreeNode* parent = NULL); 00077 ~RecipeTreeNode(); 00078 00080 void AddChild(RecipeTreeNode* child); 00081 00083 bool AddChild(RecipeTreeNode* child, Recipe* parent); 00084 00086 bool RemoveChild(RecipeTreeNode* child); 00087 00089 bool RemoveChild(Recipe* child); 00090 00092 bool IsRoot() 00093 { 00094 return parent == NULL; 00095 }; 00096 00098 bool IsLeaf() 00099 { 00100 return children.GetSize() == 0; 00101 } 00102 00104 RecipeTreeNode* GetTreeRecipe(Recipe* searchRecipe); 00105 00110 RecipeTreeNode* GetNextRecipe(); 00111 00113 bool ModifyWait(Recipe* theRecipe, int delta); 00114 00116 void UpdateWaitTimes(int delta); 00117 00119 void DumpRecipeTree() 00120 { 00121 DumpRecipeTree(1); 00122 } 00123 void DumpRecipeTree(int index); 00124 void DumpRecipeTreeRecipes() 00125 { 00126 DumpRecipeTreeRecipes(1); 00127 } 00128 void DumpRecipeTreeRecipes(int index); 00129 }; 00130 00133 #endif