Dayz 1.25
Dayz Code Explorer by KGB
Загрузка...
Поиск...
Не найдено
Класс PluginRecipesManagerBase

Защищенные члены

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 int RecipeIDFromClassname (string classname)
 

Защищенные данные

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
 

Закрытые члены

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 int GetMaxNumberOfRecipes ()
 

Закрытые данные

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 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>
 

Подробное описание

Конструктор(ы)

◆ ~PluginRecipesManager()

void ~PluginRecipesManager ( )
inlineprivate
62 {
63 }

Методы

◆ CallbackGenerateCache()

void CallbackGenerateCache ( )
inlineprivate
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:136
void GenerateRecipeCache()
Definition PluginRecipesManager.c:167

Перекрестные ссылки GenerateRecipeCache() и Debug::Log().

◆ CheckRecipe()

bool CheckRecipe ( int id,
ItemBase item1,
ItemBase item2,
PlayerBase player )
inlineprotected
432 {
434 return p_recipe.CheckRecipe(item1,item2, player);
435 }
Definition EntityAI.c:95
ref array< ref RecipeBase > m_RecipeList
Definition PluginRecipesManager.c:42
Definition RecipeBase.c:5

Используется в PerformRecipeServer().

◆ ClearResults()

void ClearResults ( )
inlineprotected
476 {
477 for (int i = 0; i < MAX_INGREDIENTS; i++)
478 {
479 m_BitsResults[i] = 0;
480 }
481
482 }
const int MAX_INGREDIENTS
Definition PluginRecipesManager.c:21
int m_BitsResults[MAX_INGREDIENTS]
Definition PluginRecipesManager.c:31

Перекрестные ссылки MAX_INGREDIENTS.

Используется в SortIngredientsInRecipe().

◆ CreateAllRecipes()

void CreateAllRecipes ( )
inlineprotected
615 {
617 }
void RegisterRecipies()
Please do not delete commented recipes, they are usually commented out for a reason.
Definition PluginRecipesManagerBase.c:14

Перекрестные ссылки RegisterRecipies().

Используется в PluginRecipesManager().

◆ GenerateHumanReadableRecipeList()

void GenerateHumanReadableRecipeList ( )
inlineprotected
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
void PluginRecipesManager()
Definition PluginRecipesManager.c:52
string GetRecipeName(int recipe_id)
Definition PluginRecipesManager.c:76
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition EnScript.c:345
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.

Перекрестные ссылки CacheObject(), CloseFile(), FPrintln(), GetRecipeName(), OpenFile(), PrintString() и x.

◆ GenerateRecipeCache()

void GenerateRecipeCache ( )
inlineprotected
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 }
void WalkRecipes()
Definition PluginRecipesManager.c:206
ref array< string > m_CachedItems
Definition PluginRecipesManager.c:40
void MatchItems(TStringArray full_path)
Definition PluginRecipesManager.c:250
proto native CGame GetGame()
array< string > TStringArray
Definition EnScript.c:685
const string CFG_VEHICLESPATH
Definition constants.c:209
const string CFG_WEAPONSPATH
Definition constants.c:210
const string CFG_MAGAZINESPATH
Definition constants.c:211

Перекрестные ссылки CFG_MAGAZINESPATH, CFG_VEHICLESPATH, CFG_WEAPONSPATH, GetGame(), MatchItems(), WalkRecipes() и x.

Используется в CallbackGenerateCache() и PluginRecipesManager().

◆ GetIsInstaRecipe()

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

◆ GetMaxNumberOfRecipes()

static int GetMaxNumberOfRecipes ( )
inlinestaticprivate
48 {
49 return 2048;
50 }

◆ GetRecipeIntersection()

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

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

545 {
546 int count = 0;
547 int smallest = 9999;
548 int smallest_index = 0;
549 m_RecipesMatched.Clear();
550
551 /*
552 m_Ingredients[0] = item_a;
553 m_Ingredients[1] = item_b;
554 */
555 //find the item with smallest number of recipes
557
558 for (int i = 0; i < num_of_ingredients; i++)
559 {
560 CacheObject cobject = PluginRecipesManager.m_RecipeCache.Get( items[i].GetType() );
561 if (!cobject)
562 {
563 return 0;
564 }
565 if (cobject.GetNumberOfRecipes() < smallest)
566 {
567 smallest = cobject.GetNumberOfRecipes();
570 }
571 }
572
573 //look for matches
574 array<int> recipes = co_least_recipes.GetRecipes();
575 for (int x = 0; x < recipes.Count(); x++)
576 {
577 int id = recipes.Get(x);
578 for (int z = 0; z < num_of_ingredients; z++)
579 {
580 if ( z!= smallest_index)
581 {
582 CacheObject cobject2 = PluginRecipesManager.m_RecipeCache.Get( items[z].GetType() );
583 if ( cobject2.IsContainRecipe(id) )
584 {
585 m_RecipesMatched.Insert(id);
586 count++;
587 }
588 }
589 }
590 }
591 return count;
592 }
eBleedingSourceType GetType()
Definition BleedingSource.c:63
ref array< int > m_RecipesMatched
Definition PluginRecipesManager.c:39

Перекрестные ссылки CacheObject(), GetType() и x.

Используется в GetValidRecipesProper().

◆ GetRecipeLengthInSecs()

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

◆ GetRecipeName()

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

Используется в GenerateHumanReadableRecipeList().

◆ GetRecipesForItem()

array< RecipeBase > GetRecipesForItem ( string itemName)
inlineprotected
348 {
349 CacheObject co = PluginRecipesManager.m_RecipeCache.Get(itemName);
350 array<int> ids = co.GetRecipes();
351
353 foreach (int recipeID : ids)
354 {
356 }
357
358 return recipes;
359 }

Перекрестные ссылки CacheObject().

◆ GetRecipeSpecialty()

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

◆ GetSoundCategory()

string GetSoundCategory ( int recipeID,
ItemBase item1,
ItemBase item2 )
inlineprotected
621 {
623 ItemBase sorted[2];
624
625 unsorted[0] = item1;
626 unsorted[1] = item2;
627
629
631 string soundCat = recipe.GetSoundCategory(0,sorted[0]);
632
633 if (!soundCat)
634 {
635 soundCat = recipe.GetSoundCategory(1,sorted[1]);
636 }
637
638 return soundCat;
639 }
Definition InventoryItem.c:731
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
Definition PluginRecipesManager.c:450

Перекрестные ссылки SortIngredientsInRecipe().

◆ GetValidRecipes()

int GetValidRecipes ( ItemBase item1,
ItemBase item2,
array< int > ids,
PlayerBase player )
inlineprivate
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 }
ItemBase m_Ingredients[MAX_INGREDIENTS]
Definition PluginRecipesManager.c:27
int GetValidRecipesProper(int num_of_items, ItemBase items[], array< int > ids, PlayerBase player)
Definition PluginRecipesManager.c:105

Перекрестные ссылки GetValidRecipesProper().

◆ GetValidRecipesProper()

int GetValidRecipesProper ( int num_of_items,
ItemBase items[],
array< int > ids,
PlayerBase player )
inlineprivate
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 }
int GetRecipeIntersection(int num_of_ingredients, ItemBase items[])
fills an array with recipe IDs which 'item_a' and 'item_b' share
Definition PluginRecipesManager.c:544
int SortIngredients(int num_of_ingredients, ItemBase items_unsorted[], int resolved_recipes[])
Definition PluginRecipesManager.c:594
int m_ResolvedRecipes[MAX_CONCURENT_RECIPES]
Definition PluginRecipesManager.c:24
ItemBase m_ingredient2[MAX_CONCURENT_RECIPES]
Definition PluginRecipesManager.c:34
ItemBase m_ingredient1[MAX_CONCURENT_RECIPES]
Definition PluginRecipesManager.c:33

Перекрестные ссылки GetRecipeIntersection() и SortIngredients().

Используется в GetValidRecipes().

◆ IsEnableDebugCrafting()

bool IsEnableDebugCrafting ( )
inlineprivate
67 {
69 }
bool m_EnableDebugCrafting
Definition PluginRecipesManager.c:26

Перекрестные ссылки m_EnableDebugCrafting.

◆ MatchItems()

void MatchItems ( TStringArray full_path)
inlineprotected
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 }
string m_BaseName
Definition PluginRecipesManager.c:241
static ref map< string, ref CacheObject > m_RecipeCache
Definition PluginRecipesManager.c:14
ref CacheObject m_CoItem
Definition PluginRecipesManager.c:246
ref CacheObject m_CoBase
Definition PluginRecipesManager.c:247
string m_ItemName
Definition PluginRecipesManager.c:245
int m_BaseMask
Definition PluginRecipesManager.c:244
ref array< int > m_RcpsArray
Definition PluginRecipesManager.c:240
int m_RecipeID
Definition PluginRecipesManager.c:242

Перекрестные ссылки CacheObject(), m_ItemName, m_RecipeID и x.

Используется в GenerateRecipeCache().

◆ OnInit()

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

◆ PerformRecipeServer()

void PerformRecipeServer ( int id,
ItemBase item_a,
ItemBase item_b,
PlayerBase player )
inlineprotected
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 }
304 if ( !passed_sanity_check )
305 {
306 Error("PerformRecipeServer - recipe failed to pass sanity check !!");
307 return;
308 }
311 //player.RequestCraftingDisable();
312
313 }
bool RecipeSanityCheck(int num_of_ingredients, InventoryItemBase items[], PlayerBase player)
Definition PluginRecipesManager.c:361
bool CheckRecipe(int id, ItemBase item1, ItemBase item2, PlayerBase player)
Definition PluginRecipesManager.c:431
ItemBase m_sortedIngredients[MAX_NUMBER_OF_INGREDIENTS]
Definition PluginRecipesManager.c:37
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

Перекрестные ссылки CheckRecipe(), Error(), RecipeSanityCheck() и SortIngredientsInRecipe().

◆ PluginRecipesManager()

void PluginRecipesManager ( )
inlineprivate
53 {
54
57
58 myTimer1 = new Timer();
59 }
void CreateAllRecipes()
Definition PluginRecipesManager.c:614
ref Timer myTimer1
Definition PluginRecipesManager.c:45
Definition DayZPlayerImplement.c:63

Перекрестные ссылки CreateAllRecipes(), GenerateRecipeCache() и myTimer1.

◆ PrintCache()

void PrintCache ( )
inlineprotected
438 {
439 for (int i = 0; i < PluginRecipesManager.m_RecipeCache.Count(); i++)
440 {
441 string key = PluginRecipesManager.m_RecipeCache.GetKey(i);
442 CacheObject co = PluginRecipesManager.m_RecipeCache.GetElement(i);
443
444 PrintString("Item: " + key);
445 co.DebugPrint();
446 PrintString("----------------");
447 }
448 }

Перекрестные ссылки CacheObject() и PrintString().

◆ PrintResultMasks()

void PrintResultMasks ( int num)
inlineprotected
536 {
537 for (int i = 0; i < num; i++)
538 {
539 Debug.Log("results mask("+i.ToString()+") = " +m_BitsResults[i].ToString() );
540 }
541 }

Перекрестные ссылки Debug::Log().

◆ RecipeIDFromClassname()

static int RecipeIDFromClassname ( string classname)
inlinestaticprotected
425 {
426 if (m_RecipeNamesList.Contains(classname))
427 return m_RecipeNamesList.Get(classname);
428 return -1;
429 }
static ref map< string, int > m_RecipeNamesList
Definition PluginRecipesManager.c:43

Используется в UnregisterRecipe().

◆ RecipeSanityCheck()

bool RecipeSanityCheck ( int num_of_ingredients,
InventoryItemBase items[],
PlayerBase player )
inlineprotected
362 {
364
365 for (int i = 0; i < num_of_ingredients;i++)
366 {
367 ItemBase item = items[i];
368 Man item_owner_player = item.GetHierarchyRootPlayer();
369 vector item_pos = item.GetPosition();
370 vector player_pos = player.GetPosition();
371
373 {
374 check_results[i] = check_results[i] | ERecipeSanityCheck.IS_IN_PLAYER_INVENTORY;
375 }
376
378 {
379 check_results[i] = check_results[i] | ERecipeSanityCheck.NOT_OWNED_BY_ANOTHER_LIVE_PLAYER;
380 }
381
383 {
385 }
386 }
387 for (i = 0; i < num_of_ingredients;i++)
388 {
390 {
391 return false;
392 }
393 }
394 return true;
395 }
const int SANITY_CHECK_ACCEPTABLE_RESULT
Definition PluginRecipesManager.c:10
ERecipeSanityCheck
Definition PluginRecipesManager.c:2
enum ERecipeSanityCheck ACCEPTABLE_DISTANCE
Definition EnConvert.c:106
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

Перекрестные ссылки ACCEPTABLE_DISTANCE, vector::Distance(), MAX_INGREDIENTS и SANITY_CHECK_ACCEPTABLE_RESULT.

Используется в PerformRecipeServer().

◆ RegisterRecipe()

void RegisterRecipe ( RecipeBase recipe)
inlineprotected
398 {
399
401 {
402 Error("Exceeded max. number of recipes, max set to: "+MAX_NUMBER_OF_RECIPES.ToString());
403 }
404
407 m_RecipeNamesList.Insert(recipe.ClassName(), m_RegRecipeIndex);
408 //Print("RegisterRecipe: " +recipe.ClassName() + ", "+ m_RegRecipeIndex.ToString());
409 }
int m_RegRecipeIndex
Definition PluginRecipesManager.c:23
const int MAX_NUMBER_OF_RECIPES
Definition PluginRecipesManager.c:19

Перекрестные ссылки Error().

Используется в RegisterRecipies().

◆ ResolveIngredients()

bool ResolveIngredients ( int num_of_ingredients,
int passes = 0 )
inlineprotected
485 {
486 int rightmost_bit;
487 int smallest = 99999;
488 int smallest_index = 0;
489
490 for (int i = 0; i < num_of_ingredients; i++)
491 {
493 if ( count != 0 && count < smallest)
494 {
497 }
498 }
499
502
503 for (int x = 0; x < num_of_ingredients; x++)
504 {
508 }
509
510 // check validity
511 int check_sum_vertical = 0;
512
513 for (int z = 0; z < num_of_ingredients; z++)
514 {
517 if ((m_IngredientBitMask[z] | m_BitsResults[z]) == 0)
518 {
519 return false;//horizontal check
520 }
521 }
522
523 if ( check_sum_vertical != (Math.Pow(2, num_of_ingredients) - 1)) return false;//vertical check
524
525 passes++;
526
528 {
529 if ( !ResolveIngredients(num_of_ingredients, passes) ) return false;
530 }
531 return true;
532 }
Definition EnMath.c:7
int m_IngredientBitMask[MAX_INGREDIENTS]
Definition PluginRecipesManager.c:28
int m_IngredientBitMaskSize[MAX_INGREDIENTS]
Definition PluginRecipesManager.c:29
bool ResolveIngredients(int num_of_ingredients, int passes=0)
Definition PluginRecipesManager.c:484
static proto float Pow(float v, float power)
Return power of v ^ power.

Перекрестные ссылки Math::Pow(), ResolveIngredients() и x.

Используется в ResolveIngredients() и SortIngredientsInRecipe().

◆ SetEnableDebugCrafting()

void SetEnableDebugCrafting ( bool enable)
inlineprivate
72 {
74 }

◆ SortIngredients()

int SortIngredients ( int num_of_ingredients,
ItemBase items_unsorted[],
int resolved_recipes[] )
inlineprotected
595 {
596 int count = 0;
597 for (int i = 0; i < m_RecipesMatched.Count() && i < MAX_CONCURENT_RECIPES; i++)
598 {
599 int recipe_id = m_RecipesMatched.Get(i);
600
601 if (SortIngredientsInRecipe(recipe_id, num_of_ingredients, items_unsorted, m_sortedIngredients))//...and now we need to determine which item will be which ingredient number
602 {
606 //m_ingredient3[count] = m_sortedIngredients[2];
607 count++;
608 }
609 }
610 return count;
611 }
const int MAX_CONCURENT_RECIPES
Definition PluginRecipesManager.c:20

Перекрестные ссылки SortIngredientsInRecipe().

Используется в GetValidRecipesProper().

◆ SortIngredientsInRecipe()

bool 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

451 {
452 ClearResults();
453
454 for (int i = 0; i < num_of_ingredients; i++)
455 {
457 m_IngredientBitMask[i] = co_item.GetMaskByRecipeID(id);
458 m_IngredientBitMaskSize[i] = co_item.GetBitCountByRecipeID(id);
459 }
460
462
463 if (result)
464 {
465 for (i = 0; i < num_of_ingredients; i++)
466 {
467 int index = Math.Log2( m_BitsResults[i]);
469 }
470 }
471 //PrintResultMasks(num_of_ingredients);
472 return result;
473 }
void ClearResults()
Definition PluginRecipesManager.c:475
static proto float Log2(float x)
Returns the binary (base-2) logarithm of x.

Перекрестные ссылки CacheObject(), ClearResults(), GetType(), Math::Log2() и ResolveIngredients().

Используется в GetSoundCategory(), PerformRecipeServer() и SortIngredients().

◆ UnregisterRecipe()

void UnregisterRecipe ( string clasname)
inlineprotected
412 {
414 //Print("UnregisterRecipe: " + recipe_id.ToString());
415 if (recipe_id != -1)
416 {
418 //Print(m_RecipeList[recipe_id]);
420 //Print(m_RecipeList[recipe_id]);
421 }
422 }
static int RecipeIDFromClassname(string classname)
Definition PluginRecipesManager.c:424

Перекрестные ссылки RecipeIDFromClassname().

◆ WalkRecipes()

void WalkRecipes ( )
inlineprotected
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;
230 }
231 co.AddRecipe(recipe_id, mask);
232 }
233 }
234 }
235 }
236 }
const int MAX_NUMBER_OF_INGREDIENTS
Definition RecipeBase.c:1

Перекрестные ссылки CacheObject(), MAX_NUMBER_OF_INGREDIENTS, Math::Pow() и x.

Используется в GenerateRecipeCache().

Поля

◆ item_mask

int item_mask
protected

◆ m_BaseMask

int m_BaseMask
protected

◆ m_BaseName

string m_BaseName
protected

◆ m_BitsResults

int m_BitsResults[MAX_INGREDIENTS]
private

◆ m_CachedItems

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

◆ m_CoBase

ref CacheObject m_CoBase
protected

◆ m_CoItem

ref CacheObject m_CoItem
protected

◆ m_EnableDebugCrafting

bool m_EnableDebugCrafting = false
private

Используется в IsEnableDebugCrafting().

◆ m_ingredient1

ItemBase m_ingredient1[MAX_CONCURENT_RECIPES]
private

◆ m_ingredient2

ItemBase m_ingredient2[MAX_CONCURENT_RECIPES]
private

◆ m_ingredient3

ItemBase m_ingredient3[MAX_CONCURENT_RECIPES]
private

◆ m_IngredientBitMask

int m_IngredientBitMask[MAX_INGREDIENTS]
private

◆ m_IngredientBitMaskSize

int m_IngredientBitMaskSize[MAX_INGREDIENTS]
private

◆ m_Ingredients

ItemBase m_Ingredients[MAX_INGREDIENTS]
private

◆ m_ItemName

string m_ItemName
protected

◆ m_RcpsArray

ref array<int> m_RcpsArray
protected

◆ m_RecipeCache

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

◆ m_RecipeID

int m_RecipeID
protected

◆ m_RecipeList

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

◆ m_RecipeNamesList

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

◆ m_RecipesInitializedItem

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

◆ m_RecipesMatched

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

◆ m_RegRecipeIndex

int m_RegRecipeIndex
private

◆ m_ResolvedRecipes

int m_ResolvedRecipes[MAX_CONCURENT_RECIPES]
private

◆ m_sortedIngredients

ItemBase m_sortedIngredients[MAX_NUMBER_OF_INGREDIENTS]
private

◆ m_TestTimer

ref Timer m_TestTimer
private

◆ MAX_CONCURENT_RECIPES

const int MAX_CONCURENT_RECIPES = 128
private

◆ MAX_INGREDIENTS

const int MAX_INGREDIENTS = 5
private

Используется в ClearResults() и RecipeSanityCheck().

◆ MAX_NUMBER_OF_RECIPES

const int MAX_NUMBER_OF_RECIPES = GetMaxNumberOfRecipes()
private

◆ myTimer1

ref Timer myTimer1
private

Объявления и описания членов класса находятся в файле: