88 if ( item1 == NULL || item2 == NULL )
107 if (ids) ids.Clear();
116 if ( numOfRecipes == 0 )
return 0;
119 for (
int i = 0; i < numOfRecipes; i++)
125 if (ids) ids.Insert( p_recipe.GetID() );
167 Debug.
Log(
"CallbackGenerateCache",
"recipes");
175 g_Game.ProfilerStart(
"m_RecipeCache");
192 for (
int i = 0; i < all_config_paths.Count(); i++)
194 config_path = all_config_paths.Get(i);
195 int children_count =
g_Game.ConfigGetChildrenCount(config_path);
197 for (
int x = 0;
x < children_count;
x++)
199 g_Game.ConfigGetChildName(config_path,
x, child_name);
200 scope =
g_Game.ConfigGetInt( config_path +
" " + child_name +
" scope" );
204 g_Game.ConfigGetFullPath(config_path +
" "+ child_name, full_path);
209 g_Game.ProfilerStop(
"m_RecipeCache");
221 int recipe_id = recipe.GetID();
226 for (
int x = 0;
x < list.Count();
x++)
228 string ingredient = list.Get(
x);
237 co.AddRecipe(recipe_id, mask);
266 for (
int i = 1; i < full_path.Count(); i++)
291 if ( !itemA || !itemB )
315 if ( !item_a || !item_b )
317 Error(
"PerformRecipeServer - one of the items null !!");
326 if ( !is_recipe_valid )
328 Error(
"PerformRecipeServer - recipe not valid !!");
331 if ( !passed_sanity_check )
333 Error(
"PerformRecipeServer - recipe failed to pass sanity check !!");
344 set<string> testset =
new set<string>;
361 recipes.InsertAll( value.GetRecipes() );
365 for (
int x = 0;
x < recipes.Count();
x++)
367 int recipe_id = recipes.Get(
x);
369 testset.Insert(recipe_name);
371 line +=
"," +recipe_name;
378 foreach (
string st : testset)
392 foreach (
int recipeID : ids)
404 for (
int i = 0; i < num_of_ingredients;i++)
407 Man item_owner_player = item.GetHierarchyRootPlayer();
408 vector item_pos = item.GetPosition();
409 vector player_pos = player.GetPosition();
411 if (item_owner_player == player)
416 if ( item_owner_player == NULL || item_owner_player == player || !item_owner_player.IsAlive() )
418 check_results[i] = check_results[i] |
ERecipeSanityCheck.NOT_OWNED_BY_ANOTHER_LIVE_PLAYER;
426 for (i = 0; i < num_of_ingredients;i++)
473 return p_recipe.CheckRecipe(item1,item2, player);
493 for (
int i = 0; i < num_of_ingredients; i++)
504 for (i = 0; i < num_of_ingredients; i++)
507 ingredients_sorted[index] = ingredients_unsorted[ i ];
526 int smallest = 99999;
527 int smallest_index = 0;
529 for (
int i = 0; i < num_of_ingredients; i++)
532 if ( count != 0 && count < smallest)
542 for (
int x = 0;
x < num_of_ingredients;
x++)
550 int check_sum_vertical = 0;
552 for (
int z = 0; z < num_of_ingredients; z++)
562 if ( check_sum_vertical != (
Math.
Pow(2, num_of_ingredients) - 1))
return false;
566 if (passes < num_of_ingredients)
576 for (
int i = 0; i < num; i++)
587 int smallest_index = 0;
597 for (
int i = 0; i < num_of_ingredients; i++)
604 if (cobject.GetNumberOfRecipes() < smallest)
606 smallest = cobject.GetNumberOfRecipes();
608 co_least_recipes = cobject;
613 array<int> recipes = co_least_recipes.GetRecipes();
614 for (
int x = 0;
x < recipes.Count();
x++)
616 int id = recipes.Get(
x);
617 for (
int z = 0; z < num_of_ingredients; z++)
619 if ( z!= smallest_index)
622 if ( cobject2.IsContainRecipe(
id) )
642 resolved_recipes[count] = recipe_id;
670 string soundCat = recipe.GetSoundCategory(0,sorted[0]);
674 soundCat = recipe.GetSoundCategory(1,sorted[1]);
683 return m_RecipeList[recipeID].GetRecipeAnimationInfo(player, mainItem, target);
eBleedingSourceType GetType()
ItemBase InventoryItemBase
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.
override bool DisassembleOnLastDetach()
void ~PluginRecipesManager()
bool GetIsRepeatable(int recipe_id)
int GetValidRecipes(ItemBase item1, ItemBase item2, array< int > ids, PlayerBase player)
void GenerateRecipeCache()
bool RecipeSanityCheck(int num_of_ingredients, InventoryItemBase items[], PlayerBase player)
ItemBase m_Ingredients[MAX_INGREDIENTS]
static ref map< string, int > m_RecipeNamesList
int GetRecipeIntersection(int num_of_ingredients, ItemBase items[])
fills an array with recipe IDs which 'item_a' and 'item_b' share
const int MAX_INGREDIENTS
int GetValidRecipesProper(int num_of_items, ItemBase items[], array< int > ids, PlayerBase player)
static ref map< typename, bool > m_RecipesInitializedItem
int SortIngredients(int num_of_ingredients, ItemBase items_unsorted[], int resolved_recipes[])
void RegisterRecipe(RecipeBase recipe)
static ref map< string, ref CacheObject > m_RecipeCache
int m_ResolvedRecipes[MAX_CONCURENT_RECIPES]
const int MAX_CONCURENT_RECIPES
RecipeAnimationInfo GetRecipeAnimationInfo(int recipeID, PlayerBase player, ItemBase mainItem, ItemBase target)
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
ItemBase m_ingredient3[MAX_CONCURENT_RECIPES]
void PluginRecipesManager()
void UnregisterRecipe(string clasname)
void GenerateHumanReadableRecipeList()
bool CheckRecipe(int id, ItemBase item1, ItemBase item2, PlayerBase player)
ref array< ref RecipeBase > m_RecipeList
bool m_EnableDebugCrafting
ref array< string > m_CachedItems
bool IsRecipePossibleToPerform(int id, ItemBase itemA, ItemBase itemB, PlayerBase player)
void PrintResultMasks(int num)
void PerformRecipeServer(int id, ItemBase item_a, ItemBase item_b, PlayerBase player)
bool IsEnableDebugCrafting()
float GetRecipeSpecialty(int recipe_id)
ItemBase m_ingredient2[MAX_CONCURENT_RECIPES]
ItemBase m_ingredient1[MAX_CONCURENT_RECIPES]
array< RecipeBase > GetRecipesForItem(string itemName)
static int GetMaxNumberOfRecipes()
int m_IngredientBitMask[MAX_INGREDIENTS]
static int RecipeIDFromClassname(string classname)
void MatchItems(TStringArray full_path)
int m_BitsResults[MAX_INGREDIENTS]
int GetAnimationCommandUID(int recipeID)
ref array< int > m_RcpsArray
string GetRecipeName(int recipe_id)
int m_IngredientBitMaskSize[MAX_INGREDIENTS]
void SetEnableDebugCrafting(bool enable)
string GetSoundCategory(int recipeID, ItemBase item1, ItemBase item2)
bool GetIsInstaRecipe(int recipe_id)
bool ResolveIngredients(int num_of_ingredients, int passes=0)
const int MAX_NUMBER_OF_RECIPES
ItemBase m_sortedIngredients[MAX_NUMBER_OF_INGREDIENTS]
void CallbackGenerateCache()
float GetRecipeLengthInSecs(int recipe_id)
ref array< int > m_RecipesMatched
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
void Error(string err)
Messagebox with error message.
array< string > TStringArray
class array< Class T > PrintString
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.
static proto float Log2(float x)
Returns the binary (base-2) logarithm of x.
static proto float Pow(float v, float power)
Return power of v ^ power.
const int SANITY_CHECK_ACCEPTABLE_RESULT
@ NOT_OWNED_BY_ANOTHER_LIVE_PLAYER
enum ERecipeSanityCheck ACCEPTABLE_DISTANCE
void RegisterRecipies()
Please do not delete commented recipes, they are usually commented out for a reason.
const int MAX_NUMBER_OF_INGREDIENTS