DayZ 1.24
Loading...
Searching...
No Matches
PluginRecipesManagerBase Class Reference
Collaboration diagram for PluginRecipesManagerBase:
[legend]

Protected Member Functions

void GenerateRecipeCache ()
 
void WalkRecipes ()
 
void MatchItems (TStringArray full_path)
 
void PerformRecipeServer (int id, ItemBase item_a, ItemBase item_b, PlayerBase player)
 
void GenerateHumanReadableRecipeList ()
 
array< RecipeBaseGetRecipesForItem (string itemName)
 
bool RecipeSanityCheck (int num_of_ingredients, InventoryItemBase items[], PlayerBase player)
 
void RegisterRecipe (RecipeBase recipe)
 
void UnregisterRecipe (string clasname)
 
bool CheckRecipe (int id, ItemBase item1, ItemBase item2, PlayerBase player)
 
void PrintCache ()
 
bool SortIngredientsInRecipe (int id, int num_of_ingredients, ItemBase ingredients_unsorted[], ItemBase ingredients_sorted[])
 sorts ingredients correctly as either first or second ingredient based on their masks
 
void ClearResults ()
 
bool ResolveIngredients (int num_of_ingredients, int passes=0)
 
void PrintResultMasks (int num)
 
int GetRecipeIntersection (int num_of_ingredients, ItemBase items[])
 fills an array with recipe IDs which 'item_a' and 'item_b' share
 
int SortIngredients (int num_of_ingredients, ItemBase items_unsorted[], int resolved_recipes[])
 
void CreateAllRecipes ()
 
string GetSoundCategory (int recipeID, ItemBase item1, ItemBase item2)
 

Static Protected Member Functions

static int RecipeIDFromClassname (string classname)
 

Protected Attributes

ref array< intm_RcpsArray
 
string m_BaseName
 
int m_RecipeID
 
int item_mask
 
int m_BaseMask
 
string m_ItemName
 
ref CacheObject m_CoItem
 
ref CacheObject m_CoBase
 

Private Member Functions

void PluginRecipesManager ()
 
void ~PluginRecipesManager ()
 
bool IsEnableDebugCrafting ()
 
void SetEnableDebugCrafting (bool enable)
 
string GetRecipeName (int recipe_id)
 
int GetValidRecipes (ItemBase item1, ItemBase item2, array< int > ids, PlayerBase player)
 
int GetValidRecipesProper (int num_of_items, ItemBase items[], array< int > ids, PlayerBase player)
 
float GetRecipeLengthInSecs (int recipe_id)
 
float GetRecipeSpecialty (int recipe_id)
 
bool GetIsInstaRecipe (int recipe_id)
 
override void OnInit ()
 
void CallbackGenerateCache ()
 

Static Private Member Functions

static int GetMaxNumberOfRecipes ()
 

Private Attributes

ref Timer m_TestTimer
 
const int MAX_NUMBER_OF_RECIPES = GetMaxNumberOfRecipes()
 
const int MAX_CONCURENT_RECIPES = 128
 
const int MAX_INGREDIENTS = 5
 
int m_RegRecipeIndex
 
int m_ResolvedRecipes [MAX_CONCURENT_RECIPES]
 
bool m_EnableDebugCrafting = false
 
ItemBase m_Ingredients [MAX_INGREDIENTS]
 
int m_IngredientBitMask [MAX_INGREDIENTS]
 
int m_IngredientBitMaskSize [MAX_INGREDIENTS]
 
int m_BitsResults [MAX_INGREDIENTS]
 
ItemBase m_ingredient1 [MAX_CONCURENT_RECIPES]
 
ItemBase m_ingredient2 [MAX_CONCURENT_RECIPES]
 
ItemBase m_ingredient3 [MAX_CONCURENT_RECIPES]
 
ItemBase m_sortedIngredients [MAX_NUMBER_OF_INGREDIENTS]
 
ref array< intm_RecipesMatched = new array<int>
 
ref array< stringm_CachedItems = new array<string>
 
ref array< ref RecipeBasem_RecipeList = new array<ref RecipeBase>
 
ref Timer myTimer1
 

Static Private Attributes

static ref map< string, ref CacheObjectm_RecipeCache = new map<string, ref CacheObject >
 
static ref map< typename, boolm_RecipesInitializedItem = new ref map<typename, bool>
 
static ref map< string, intm_RecipeNamesList = new map<string, int>
 

Detailed Description

Definition at line 12 of file PluginRecipesManager.c.

Constructor & Destructor Documentation

◆ ~PluginRecipesManager()

void PluginRecipesManagerBase::~PluginRecipesManager ( )
inlineprivate

Definition at line 61 of file PluginRecipesManager.c.

62 {
63 }

Member Function Documentation

◆ CallbackGenerateCache()

void PluginRecipesManagerBase::CallbackGenerateCache ( )
inlineprivate

Definition at line 159 of file PluginRecipesManager.c.

160 {
161 Debug.Log("CallbackGenerateCache", "recipes");
163 //SaveCacheToFile(PATH_CACHE_FILE);//generate the cache and save it to a file
164 //ReadCacheFromFile(PATH_CACHE_FILE);
165 }
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133

References GenerateRecipeCache(), and Debug::Log().

◆ CheckRecipe()

bool PluginRecipesManagerBase::CheckRecipe ( int id,
ItemBase item1,
ItemBase item2,
PlayerBase player )
inlineprotected

Definition at line 419 of file PluginRecipesManager.c.

420 {
422 return p_recipe.CheckRecipe(item1, item2, player);
423 }
ref array< ref RecipeBase > m_RecipeList

Referenced by PerformRecipeServer().

◆ ClearResults()

void PluginRecipesManagerBase::ClearResults ( )
inlineprotected

Definition at line 463 of file PluginRecipesManager.c.

464 {
465 for (int i = 0; i < MAX_INGREDIENTS; i++)
466 m_BitsResults[i] = 0;
467
468 }
int m_BitsResults[MAX_INGREDIENTS]

References MAX_INGREDIENTS.

Referenced by SortIngredientsInRecipe().

◆ CreateAllRecipes()

void PluginRecipesManagerBase::CreateAllRecipes ( )
inlineprotected

Definition at line 596 of file PluginRecipesManager.c.

597 {
599 }
void RegisterRecipies()
Please do not delete commented recipes, they are usually commented out for a reason.

References RegisterRecipies().

Referenced by PluginRecipesManager().

◆ GenerateHumanReadableRecipeList()

void PluginRecipesManagerBase::GenerateHumanReadableRecipeList ( )
inlineprotected

Definition at line 315 of file PluginRecipesManager.c.

316 {
317 FileHandle file = OpenFile("$profile:RecipeDump.txt", FileMode.WRITE);
318 if (file == 0)
319 {
320 //error message
321 PrintString("failed to open file RecipeDump");
322 return;
323 }
325 for (int i = 0; i < PluginRecipesManager.m_RecipeCache.Count(); i++)
326 {
327 string key = PluginRecipesManager.m_RecipeCache.GetKey(i);
328 CacheObject value = PluginRecipesManager.m_RecipeCache.GetElement(i);
329
330 string line = key;
331 recipes.Clear();
332 recipes.InsertAll(value.GetRecipes());
333
334 //PrintString("Item: " + key);
335
336 for (int x = 0; x < recipes.Count(); x++)
337 {
338 int recipe_id = recipes.Get(x);
340 line += "," + recipe_name;
341 }
343 }
345 }
void CacheObject()
Definition CacheObject.c:35
Icon x
string GetRecipeName(int recipe_id)
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition EnScript.c:344
FileMode
Definition EnSystem.c:383
proto void CloseFile(FileHandle file)
Close the File.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
proto void FPrintln(FileHandle file, void var)
Write to file and add new line.

References CacheObject(), CloseFile(), FPrintln(), GetRecipeName(), OpenFile(), PrintString(), and x.

◆ GenerateRecipeCache()

void PluginRecipesManagerBase::GenerateRecipeCache ( )
inlineprotected

Definition at line 167 of file PluginRecipesManager.c.

168 {
169 GetGame().ProfilerStart("m_RecipeCache");
170
171 //m_CacheBasesMap.Clear();
172 m_CachedItems.Clear();
173 PluginRecipesManager.m_RecipeCache.Clear();
174
176
180 //Debug.Log("Got here 0","caching");
181 string config_path;
182 string child_name;
183 int scope;
185 WalkRecipes();
186 for (int i = 0; i < all_config_paths.Count(); i++)
187 {
189 int children_count = GetGame().ConfigGetChildrenCount(config_path);
190
191 for (int x = 0; x < children_count; x++)
192 {
193 GetGame().ConfigGetChildName(config_path, x, child_name);
194 scope = GetGame().ConfigGetInt(config_path + " " + child_name + " scope");
195
196 if (scope == 2)
197 {
198 GetGame().ConfigGetFullPath(config_path + " " + child_name,/*out*/ full_path);
200 }
201 }
202 }
203 GetGame().ProfilerStop("m_RecipeCache");
204 }
ref array< string > m_CachedItems
void MatchItems(TStringArray full_path)
proto native CGame GetGame()
array< string > TStringArray
Definition EnScript.c:666
const string CFG_VEHICLESPATH
Definition constants.c:209
const string CFG_WEAPONSPATH
Definition constants.c:210
const string CFG_MAGAZINESPATH
Definition constants.c:211

References CFG_MAGAZINESPATH, CFG_VEHICLESPATH, CFG_WEAPONSPATH, GetGame(), MatchItems(), WalkRecipes(), and x.

Referenced by CallbackGenerateCache(), and PluginRecipesManager().

◆ GetIsInstaRecipe()

bool PluginRecipesManagerBase::GetIsInstaRecipe ( int recipe_id)
inlineprivate

Definition at line 145 of file PluginRecipesManager.c.

146 {
147 if (m_RecipeList[recipe_id]) return m_RecipeList[recipe_id].IsInstaRecipe();
148 else return false;
149 }

◆ GetMaxNumberOfRecipes()

static int PluginRecipesManagerBase::GetMaxNumberOfRecipes ( )
inlinestaticprivate

Definition at line 47 of file PluginRecipesManager.c.

48 {
49 return 2048;
50 }

◆ GetRecipeIntersection()

int PluginRecipesManagerBase::GetRecipeIntersection ( int num_of_ingredients,
ItemBase items[] )
inlineprotected

fills an array with recipe IDs which 'item_a' and 'item_b' share

Definition at line 528 of file PluginRecipesManager.c.

529 {
530 int count = 0;
531 int smallest = 9999;
532 int smallest_index = 0;
533 m_RecipesMatched.Clear();
534
535 /*
536 m_Ingredients[0] = item_a;
537 m_Ingredients[1] = item_b;
538 */
539 //find the item with smallest number of recipes
541
542 for (int i = 0; i < num_of_ingredients; i++)
543 {
544 CacheObject cobject = PluginRecipesManager.m_RecipeCache.Get(items[i].GetType());
545 if (!cobject)
546 return 0;
547 if (cobject.GetNumberOfRecipes() < smallest)
548 {
549 smallest = cobject.GetNumberOfRecipes();
552 }
553 }
554
555 //look for matches
556 array<int> recipes = co_least_recipes.GetRecipes();
557 for (int x = 0; x < recipes.Count(); x++)
558 {
559 int id = recipes.Get(x);
560 for (int z = 0; z < num_of_ingredients; z++)
561 {
562 if (z != smallest_index)
563 {
564 CacheObject cobject2 = PluginRecipesManager.m_RecipeCache.Get(items[z].GetType());
565 if (cobject2.IsContainRecipe(id))
566 {
567 m_RecipesMatched.Insert(id);
568 count++;
569 }
570 }
571 }
572 }
573 return count;
574 }
eBleedingSourceType GetType()

References CacheObject(), GetType(), and x.

Referenced by GetValidRecipesProper().

◆ GetRecipeLengthInSecs()

float PluginRecipesManagerBase::GetRecipeLengthInSecs ( int recipe_id)
inlineprivate

Definition at line 133 of file PluginRecipesManager.c.

134 {
135 if (m_RecipeList[recipe_id]) return m_RecipeList[recipe_id].GetLengthInSecs();
136 return 0;
137 }

◆ GetRecipeName()

string PluginRecipesManagerBase::GetRecipeName ( int recipe_id)
inlineprivate

Definition at line 76 of file PluginRecipesManager.c.

77 {
79 return m_RecipeList[recipe_id].GetName();
80
81 return "";
82 }

Referenced by GenerateHumanReadableRecipeList().

◆ GetRecipesForItem()

array< RecipeBase > PluginRecipesManagerBase::GetRecipesForItem ( string itemName)
inlineprotected

Definition at line 347 of file PluginRecipesManager.c.

348 {
349 CacheObject co = PluginRecipesManager.m_RecipeCache.Get(itemName);
350 array<int> ids = co.GetRecipes();
351
353 foreach (int recipeID : ids)
355
356 return recipes;
357 }

References CacheObject().

◆ GetRecipeSpecialty()

float PluginRecipesManagerBase::GetRecipeSpecialty ( int recipe_id)
inlineprivate

Definition at line 139 of file PluginRecipesManager.c.

140 {
141 if (m_RecipeList[recipe_id]) return m_RecipeList[recipe_id].GetSpecialty();
142 return 0;
143 }

◆ GetSoundCategory()

string PluginRecipesManagerBase::GetSoundCategory ( int recipeID,
ItemBase item1,
ItemBase item2 )
inlineprotected

Definition at line 602 of file PluginRecipesManager.c.

603 {
605 ItemBase sorted[2];
606
607 unsorted[0] = item1;
608 unsorted[1] = item2;
609
611
613 string soundCat = recipe.GetSoundCategory(0, sorted[0]);
614
615 if (!soundCat)
616 soundCat = recipe.GetSoundCategory(1, sorted[1]);
617
618 return soundCat;
619 }
bool SortIngredientsInRecipe(int id, int num_of_ingredients, ItemBase ingredients_unsorted[], ItemBase ingredients_sorted[])
sorts ingredients correctly as either first or second ingredient based on their masks

References SortIngredientsInRecipe().

◆ GetValidRecipes()

int PluginRecipesManagerBase::GetValidRecipes ( ItemBase item1,
ItemBase item2,
array< int > ids,
PlayerBase player )
inlineprivate

Definition at line 86 of file PluginRecipesManager.c.

87 {
88 if (item1 == NULL || item2 == NULL)
89 {
90 if (ids) ids.Clear();
91 return 0;
92 }
93
94 if ((item1.GetInventory().IsAttachment() && item1.GetHierarchyParent().DisassembleOnLastDetach()) || (item2.GetInventory().IsAttachment() && item2.GetHierarchyParent().DisassembleOnLastDetach()))
95 {
96 if (ids) ids.Clear();
97 return 0;
98 }
100 m_Ingredients[1] = item2;
101
103 }
int GetValidRecipesProper(int num_of_items, ItemBase items[], array< int > ids, PlayerBase player)
ItemBase m_Ingredients[MAX_INGREDIENTS]

References GetValidRecipesProper().

◆ GetValidRecipesProper()

int PluginRecipesManagerBase::GetValidRecipesProper ( int num_of_items,
ItemBase items[],
array< int > ids,
PlayerBase player )
inlineprivate

Definition at line 105 of file PluginRecipesManager.c.

106 {
107 if (ids) ids.Clear();
110 //will return number of cached recipes for the 2 items being considered,
111 //and save their indexes in m_ResolvedRecipes, please note the m_ResolvedRecipes is a static array,
112 //and does not clear up with each query, so the number of recipes returned is critical to make sure we don't accidentally
113 //mix in some other indexes from previous queries(and obviously loop only as far as we have to)
114 //this also saves the ingredients in the correct assignment as ingredient 1/2 into m_ingredient1/m_ingredient2 arrays, these 3 arrays
115 //therefore provide you with information per each index with: recipeid,ingredient1,ingredient2
116 if (numOfRecipes == 0) return 0;
117 int found = 0;
119 for (int i = 0; i < numOfRecipes; i++)
120 {
122
123 if (p_recipe.CheckRecipe(m_ingredient1[i], m_ingredient2[i], player) == true)
124 {
125 if (ids) ids.Insert(p_recipe.GetID());
126 found++;
127 }
128 }
129 return found;
130 }
ItemBase m_ingredient1[MAX_CONCURENT_RECIPES]
int m_ResolvedRecipes[MAX_CONCURENT_RECIPES]
int GetRecipeIntersection(int num_of_ingredients, ItemBase items[])
fills an array with recipe IDs which 'item_a' and 'item_b' share
ItemBase m_ingredient2[MAX_CONCURENT_RECIPES]
int SortIngredients(int num_of_ingredients, ItemBase items_unsorted[], int resolved_recipes[])

References GetRecipeIntersection(), and SortIngredients().

Referenced by GetValidRecipes().

◆ IsEnableDebugCrafting()

bool PluginRecipesManagerBase::IsEnableDebugCrafting ( )
inlineprivate

Definition at line 66 of file PluginRecipesManager.c.

References m_EnableDebugCrafting.

◆ MatchItems()

void PluginRecipesManagerBase::MatchItems ( TStringArray full_path)
inlineprotected

Definition at line 250 of file PluginRecipesManager.c.

251 {
252 m_ItemName = full_path.Get(0);
254 //Print(m_ItemName);
255 if (!m_CoItem)
256 {
257 m_CoItem = new CacheObject;
259 }
260 for (int i = 1; i < full_path.Count(); i++)
261 {
262 m_BaseName = full_path.Get(i);
264 if (m_CoBase) //resolve new base classes
265 {
266 m_RcpsArray = m_RecipeCache.Get(m_BaseName).GetRecipes();
267
268 for (int x = 0; x < m_RcpsArray.Count(); x++) //base recipes
269 {
270 m_RecipeID = m_RcpsArray.Get(x);
271
272 //item_mask = m_CoItem.GetMaskByRecipeID(m_RecipeID);
273 m_BaseMask = m_CoBase.GetMaskByRecipeID(m_RecipeID);
274
275 m_CoItem.AddRecipe(m_RecipeID, m_BaseMask);
276 }
277 }
278 }
279
280
281 }
static ref map< string, ref CacheObject > m_RecipeCache

References CacheObject(), m_ItemName, m_RecipeID, and x.

Referenced by GenerateRecipeCache().

◆ OnInit()

override void PluginRecipesManagerBase::OnInit ( )
inlineprivate

Definition at line 151 of file PluginRecipesManager.c.

152 {
153 super.OnInit();
154 //ReadCacheFromFile(PATH_CACHE_FILE);//read the cache from a file
155 //GenerateHumanReadableRecipeList();
156 }

◆ PerformRecipeServer()

void PluginRecipesManagerBase::PerformRecipeServer ( int id,
ItemBase item_a,
ItemBase item_b,
PlayerBase player )
inlineprotected

Definition at line 283 of file PluginRecipesManager.c.

284 {
287
288 if (!item_a || !item_b)
289 {
290 Error("PerformRecipeServer - one of the items null !!");
291 return;
292 }
293
295
298
299 if (!is_recipe_valid)
300 {
301 Error("PerformRecipeServer - recipe not valid !!");
302 return;
303 }
305 {
306 Error("PerformRecipeServer - recipe failed to pass sanity check !!");
307 return;
308 }
311 //player.RequestCraftingDisable();
312
313 }
ItemBase m_sortedIngredients[MAX_NUMBER_OF_INGREDIENTS]
bool CheckRecipe(int id, ItemBase item1, ItemBase item2, PlayerBase player)
bool RecipeSanityCheck(int num_of_ingredients, InventoryItemBase items[], PlayerBase player)
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References CheckRecipe(), Error(), RecipeSanityCheck(), and SortIngredientsInRecipe().

◆ PluginRecipesManager()

void PluginRecipesManagerBase::PluginRecipesManager ( )
inlineprivate

◆ PrintCache()

void PluginRecipesManagerBase::PrintCache ( )
inlineprotected

Definition at line 425 of file PluginRecipesManager.c.

426 {
427 for (int i = 0; i < PluginRecipesManager.m_RecipeCache.Count(); i++)
428 {
429 string key = PluginRecipesManager.m_RecipeCache.GetKey(i);
430 CacheObject co = PluginRecipesManager.m_RecipeCache.GetElement(i);
431
432 PrintString("Item: " + key);
433 co.DebugPrint();
434 PrintString("----------------");
435 }
436 }

References CacheObject(), and PrintString().

◆ PrintResultMasks()

void PluginRecipesManagerBase::PrintResultMasks ( int num)
inlineprotected

Definition at line 521 of file PluginRecipesManager.c.

522 {
523 for (int i = 0; i < num; i++)
524 Debug.Log("results mask(" + i.ToString() + ") = " + m_BitsResults[i].ToString());
525 }

References Debug::Log().

◆ RecipeIDFromClassname()

static int PluginRecipesManagerBase::RecipeIDFromClassname ( string classname)
inlinestaticprotected

Definition at line 412 of file PluginRecipesManager.c.

413 {
414 if (m_RecipeNamesList.Contains(classname))
415 return m_RecipeNamesList.Get(classname);
416 return -1;
417 }
static ref map< string, int > m_RecipeNamesList

Referenced by UnregisterRecipe().

◆ RecipeSanityCheck()

bool PluginRecipesManagerBase::RecipeSanityCheck ( int num_of_ingredients,
InventoryItemBase items[],
PlayerBase player )
inlineprotected

Definition at line 359 of file PluginRecipesManager.c.

360 {
362
363 for (int i = 0; i < num_of_ingredients; i++)
364 {
365 ItemBase item = items[i];
366 Man item_owner_player = item.GetHierarchyRootPlayer();
367 vector item_pos = item.GetPosition();
368 vector player_pos = player.GetPosition();
369
371 check_results[i] = check_results[i] | ERecipeSanityCheck.IS_IN_PLAYER_INVENTORY;
372
374 check_results[i] = check_results[i] | ERecipeSanityCheck.NOT_OWNED_BY_ANOTHER_LIVE_PLAYER;
375
378 }
379 for (i = 0; i < num_of_ingredients; i++)
380 {
382 return false;
383 }
384 return true;
385 }
const int SANITY_CHECK_ACCEPTABLE_RESULT
ERecipeSanityCheck
enum ERecipeSanityCheck ACCEPTABLE_DISTANCE
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

References ACCEPTABLE_DISTANCE, vector::Distance(), MAX_INGREDIENTS, and SANITY_CHECK_ACCEPTABLE_RESULT.

Referenced by PerformRecipeServer().

◆ RegisterRecipe()

void PluginRecipesManagerBase::RegisterRecipe ( RecipeBase recipe)
inlineprotected

Definition at line 387 of file PluginRecipesManager.c.

388 {
389
391 Error("Exceeded max. number of recipes, max set to: " + MAX_NUMBER_OF_RECIPES.ToString());
392
395 m_RecipeNamesList.Insert(recipe.ClassName(), m_RegRecipeIndex);
396 //Print("RegisterRecipe: " +recipe.ClassName() + ", "+ m_RegRecipeIndex.ToString());
397 }

References Error().

Referenced by RegisterRecipies().

◆ ResolveIngredients()

bool PluginRecipesManagerBase::ResolveIngredients ( int num_of_ingredients,
int passes = 0 )
inlineprotected

Definition at line 470 of file PluginRecipesManager.c.

471 {
472 int rightmost_bit;
473 int smallest = 99999;
474 int smallest_index = 0;
475
476 for (int i = 0; i < num_of_ingredients; i++)
477 {
479 if (count != 0 && count < smallest)
480 {
483 }
484 }
485
488
489 for (int x = 0; x < num_of_ingredients; x++)
490 {
494 }
495
496 // check validity
497 int check_sum_vertical = 0;
498
499 for (int z = 0; z < num_of_ingredients; z++)
500 {
503 if ((m_IngredientBitMask[z] | m_BitsResults[z]) == 0)
504 {
505 return false;//horizontal check
506 }
507 }
508
509 if (check_sum_vertical != (Math.Pow(2, num_of_ingredients) - 1)) return false; //vertical check
510
511 passes++;
512
514 {
515 if (!ResolveIngredients(num_of_ingredients, passes)) return false;
516 }
517 return true;
518 }
Definition EnMath.c:7
int m_IngredientBitMaskSize[MAX_INGREDIENTS]
bool ResolveIngredients(int num_of_ingredients, int passes=0)
int m_IngredientBitMask[MAX_INGREDIENTS]
static proto float Pow(float v, float power)
Return power of v ^ power.

References Math::Pow(), ResolveIngredients(), and x.

Referenced by ResolveIngredients(), and SortIngredientsInRecipe().

◆ SetEnableDebugCrafting()

void PluginRecipesManagerBase::SetEnableDebugCrafting ( bool enable)
inlineprivate

Definition at line 71 of file PluginRecipesManager.c.

72 {
74 }

◆ SortIngredients()

int PluginRecipesManagerBase::SortIngredients ( int num_of_ingredients,
ItemBase items_unsorted[],
int resolved_recipes[] )
inlineprotected

Definition at line 576 of file PluginRecipesManager.c.

577 {
578 int count = 0;
579 for (int i = 0; i < m_RecipesMatched.Count() && i < MAX_CONCURENT_RECIPES; i++)
580 {
581 int recipe_id = m_RecipesMatched.Get(i);
582
583 if (SortIngredientsInRecipe(recipe_id, num_of_ingredients, items_unsorted, m_sortedIngredients))//...and now we need to determine which item will be which ingredient number
584 {
588 //m_ingredient3[count] = m_sortedIngredients[2];
589 count++;
590 }
591 }
592 return count;
593 }

References SortIngredientsInRecipe().

Referenced by GetValidRecipesProper().

◆ SortIngredientsInRecipe()

bool PluginRecipesManagerBase::SortIngredientsInRecipe ( int id,
int num_of_ingredients,
ItemBase ingredients_unsorted[],
ItemBase ingredients_sorted[] )
inlineprotected

sorts ingredients correctly as either first or second ingredient based on their masks

Definition at line 438 of file PluginRecipesManager.c.

439 {
440 ClearResults();
441
442 for (int i = 0; i < num_of_ingredients; i++)
443 {
445 m_IngredientBitMask[i] = co_item.GetMaskByRecipeID(id);
446 m_IngredientBitMaskSize[i] = co_item.GetBitCountByRecipeID(id);
447 }
448
450
451 if (result)
452 {
453 for (i = 0; i < num_of_ingredients; i++)
454 {
455 int index = Math.Log2(m_BitsResults[i]);
457 }
458 }
459 //PrintResultMasks(num_of_ingredients);
460 return result;
461 }
static proto float Log2(float x)
Returns the binary (base-2) logarithm of x.

References CacheObject(), ClearResults(), GetType(), Math::Log2(), and ResolveIngredients().

Referenced by GetSoundCategory(), PerformRecipeServer(), and SortIngredients().

◆ UnregisterRecipe()

void PluginRecipesManagerBase::UnregisterRecipe ( string clasname)
inlineprotected

Definition at line 399 of file PluginRecipesManager.c.

400 {
402 //Print("UnregisterRecipe: " + recipe_id.ToString());
403 if (recipe_id != -1)
404 {
406 //Print(m_RecipeList[recipe_id]);
408 //Print(m_RecipeList[recipe_id]);
409 }
410 }
static int RecipeIDFromClassname(string classname)

References RecipeIDFromClassname().

◆ WalkRecipes()

void PluginRecipesManagerBase::WalkRecipes ( )
inlineprotected

Definition at line 206 of file PluginRecipesManager.c.

207 {
208 //Print("------------- WalkRecipes --------------");
209 for (int c = 0; c < m_RecipeList.Count(); c++)
210 {
212 if (recipe)
213 {
214 //Print(recipe.ClassName());
215 int recipe_id = recipe.GetID();
216 for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
217 {
218 array<string> list = recipe.m_Ingredients[i];
219
220 for (int x = 0; x < list.Count(); x++)
221 {
222 string ingredient = list.Get(x);
223 int mask = Math.Pow(2, i);
225
226 if (!co)
227 {
228 co = new CacheObject;
229 m_RecipeCache.Insert(ingredient, co);
230 }
231 co.AddRecipe(recipe_id, mask);
232 }
233 }
234 }
235 }
236 }
const int MAX_NUMBER_OF_INGREDIENTS
Definition RecipeBase.c:1

References CacheObject(), MAX_NUMBER_OF_INGREDIENTS, Math::Pow(), and x.

Referenced by GenerateRecipeCache().

Member Data Documentation

◆ item_mask

int PluginRecipesManagerBase::item_mask
protected

Definition at line 243 of file PluginRecipesManager.c.

◆ m_BaseMask

int PluginRecipesManagerBase::m_BaseMask
protected

Definition at line 244 of file PluginRecipesManager.c.

◆ m_BaseName

string PluginRecipesManagerBase::m_BaseName
protected

Definition at line 241 of file PluginRecipesManager.c.

◆ m_BitsResults

int PluginRecipesManagerBase::m_BitsResults[MAX_INGREDIENTS]
private

Definition at line 31 of file PluginRecipesManager.c.

◆ m_CachedItems

ref array<string> PluginRecipesManagerBase::m_CachedItems = new array<string>
private

Definition at line 40 of file PluginRecipesManager.c.

◆ m_CoBase

ref CacheObject PluginRecipesManagerBase::m_CoBase
protected

Definition at line 247 of file PluginRecipesManager.c.

◆ m_CoItem

ref CacheObject PluginRecipesManagerBase::m_CoItem
protected

Definition at line 246 of file PluginRecipesManager.c.

◆ m_EnableDebugCrafting

bool PluginRecipesManagerBase::m_EnableDebugCrafting = false
private

Definition at line 26 of file PluginRecipesManager.c.

Referenced by IsEnableDebugCrafting().

◆ m_ingredient1

ItemBase PluginRecipesManagerBase::m_ingredient1[MAX_CONCURENT_RECIPES]
private

Definition at line 33 of file PluginRecipesManager.c.

◆ m_ingredient2

ItemBase PluginRecipesManagerBase::m_ingredient2[MAX_CONCURENT_RECIPES]
private

Definition at line 34 of file PluginRecipesManager.c.

◆ m_ingredient3

ItemBase PluginRecipesManagerBase::m_ingredient3[MAX_CONCURENT_RECIPES]
private

Definition at line 35 of file PluginRecipesManager.c.

◆ m_IngredientBitMask

int PluginRecipesManagerBase::m_IngredientBitMask[MAX_INGREDIENTS]
private

Definition at line 28 of file PluginRecipesManager.c.

◆ m_IngredientBitMaskSize

int PluginRecipesManagerBase::m_IngredientBitMaskSize[MAX_INGREDIENTS]
private

Definition at line 29 of file PluginRecipesManager.c.

◆ m_Ingredients

ItemBase PluginRecipesManagerBase::m_Ingredients[MAX_INGREDIENTS]
private

Definition at line 27 of file PluginRecipesManager.c.

◆ m_ItemName

string PluginRecipesManagerBase::m_ItemName
protected

Definition at line 245 of file PluginRecipesManager.c.

◆ m_RcpsArray

ref array<int> PluginRecipesManagerBase::m_RcpsArray
protected

Definition at line 240 of file PluginRecipesManager.c.

◆ m_RecipeCache

ref map<string, ref CacheObject > PluginRecipesManagerBase::m_RecipeCache = new map<string, ref CacheObject >
staticprivate

Definition at line 14 of file PluginRecipesManager.c.

◆ m_RecipeID

int PluginRecipesManagerBase::m_RecipeID
protected

Definition at line 242 of file PluginRecipesManager.c.

◆ m_RecipeList

ref array<ref RecipeBase> PluginRecipesManagerBase::m_RecipeList = new array<ref RecipeBase>
private

Definition at line 42 of file PluginRecipesManager.c.

◆ m_RecipeNamesList

ref map<string, int> PluginRecipesManagerBase::m_RecipeNamesList = new map<string, int>
staticprivate

Definition at line 43 of file PluginRecipesManager.c.

◆ m_RecipesInitializedItem

ref map<typename, bool> PluginRecipesManagerBase::m_RecipesInitializedItem = new ref map<typename, bool>
staticprivate

Definition at line 15 of file PluginRecipesManager.c.

◆ m_RecipesMatched

ref array<int> PluginRecipesManagerBase::m_RecipesMatched = new array<int>
private

Definition at line 39 of file PluginRecipesManager.c.

◆ m_RegRecipeIndex

int PluginRecipesManagerBase::m_RegRecipeIndex
private

Definition at line 23 of file PluginRecipesManager.c.

◆ m_ResolvedRecipes

int PluginRecipesManagerBase::m_ResolvedRecipes[MAX_CONCURENT_RECIPES]
private

Definition at line 24 of file PluginRecipesManager.c.

◆ m_sortedIngredients

ItemBase PluginRecipesManagerBase::m_sortedIngredients[MAX_NUMBER_OF_INGREDIENTS]
private

Definition at line 37 of file PluginRecipesManager.c.

◆ m_TestTimer

ref Timer PluginRecipesManagerBase::m_TestTimer
private

Definition at line 18 of file PluginRecipesManager.c.

◆ MAX_CONCURENT_RECIPES

const int PluginRecipesManagerBase::MAX_CONCURENT_RECIPES = 128
private

Definition at line 20 of file PluginRecipesManager.c.

◆ MAX_INGREDIENTS

const int PluginRecipesManagerBase::MAX_INGREDIENTS = 5
private

Definition at line 21 of file PluginRecipesManager.c.

Referenced by ClearResults(), and RecipeSanityCheck().

◆ MAX_NUMBER_OF_RECIPES

const int PluginRecipesManagerBase::MAX_NUMBER_OF_RECIPES = GetMaxNumberOfRecipes()
private

Definition at line 19 of file PluginRecipesManager.c.

◆ myTimer1

ref Timer PluginRecipesManagerBase::myTimer1
private

Definition at line 45 of file PluginRecipesManager.c.


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