95 if ( item1 == NULL || item2 == NULL )
103 if (ids) ids.Clear();
114 if (ids) ids.Clear();
123 if ( numOfRecipes == 0 )
return 0;
126 for (
int i = 0; i < numOfRecipes; i++)
132 if (ids) ids.Insert( p_recipe.GetID() );
174 Debug.
Log(
"CallbackGenerateCache",
"recipes");
182 g_Game.ProfilerStart(
"m_RecipeCache");
199 for (
int i = 0; i < all_config_paths.Count(); i++)
201 config_path = all_config_paths.
Get(i);
202 int children_count =
g_Game.ConfigGetChildrenCount(config_path);
204 for (
int x = 0;
x < children_count;
x++)
206 g_Game.ConfigGetChildName(config_path,
x, child_name);
207 scope =
g_Game.ConfigGetInt( config_path +
" " + child_name +
" scope" );
211 g_Game.ConfigGetFullPath(config_path +
" "+ child_name, full_path);
216 g_Game.ProfilerStop(
"m_RecipeCache");
228 int recipe_id = recipe.GetID();
233 for (
int x = 0;
x < list.Count();
x++)
235 string ingredient = list.Get(
x);
244 co.AddRecipe(recipe_id, mask);
273 for (
int i = 1; i < full_path.Count(); i++)
298 if ( !itemA || !itemB )
322 if ( !item_a || !item_b )
324 Error(
"PerformRecipeServer - one of the items null !!");
333 if ( !is_recipe_valid )
335 Error(
"PerformRecipeServer - recipe not valid !!");
338 if ( !passed_sanity_check )
340 Error(
"PerformRecipeServer - recipe failed to pass sanity check !!");
351 set<string> testset =
new set<string>;
368 recipes.InsertAll( value.GetRecipes() );
372 for (
int x = 0;
x < recipes.Count();
x++)
374 int recipe_id = recipes.Get(
x);
376 testset.Insert(recipe_name);
378 line +=
"," +recipe_name;
385 foreach (
string st : testset)
399 foreach (
int recipeID : ids)
411 for (
int i = 0; i < num_of_ingredients;i++)
414 Man item_owner_player = item.GetHierarchyRootPlayer();
415 vector item_pos = item.GetPosition();
416 vector player_pos = player.GetPosition();
418 if (item_owner_player == player)
423 if ( item_owner_player == NULL || item_owner_player == player || !item_owner_player.IsAlive() )
425 check_results[i] = check_results[i] |
ERecipeSanityCheck.NOT_OWNED_BY_ANOTHER_LIVE_PLAYER;
433 for (i = 0; i < num_of_ingredients;i++)
480 return p_recipe.CheckRecipe(item1,item2, player);
500 for (
int i = 0; i < num_of_ingredients; i++)
511 for (i = 0; i < num_of_ingredients; i++)
514 ingredients_sorted[index] = ingredients_unsorted[ i ];
533 int smallest = 99999;
534 int smallest_index = 0;
536 for (
int i = 0; i < num_of_ingredients; i++)
539 if ( count != 0 && count < smallest)
549 for (
int x = 0;
x < num_of_ingredients;
x++)
557 int check_sum_vertical = 0;
559 for (
int z = 0; z < num_of_ingredients; z++)
569 if ( check_sum_vertical != (
Math.
Pow(2, num_of_ingredients) - 1))
return false;
573 if (passes < num_of_ingredients)
583 for (
int i = 0; i < num; i++)
594 int smallest_index = 0;
604 for (
int i = 0; i < num_of_ingredients; i++)
611 if (cobject.GetNumberOfRecipes() < smallest)
613 smallest = cobject.GetNumberOfRecipes();
615 co_least_recipes = cobject;
620 array<int> recipes = co_least_recipes.GetRecipes();
621 for (
int x = 0;
x < recipes.Count();
x++)
623 int id = recipes.Get(
x);
624 for (
int z = 0; z < num_of_ingredients; z++)
626 if ( z!= smallest_index)
629 if ( cobject2.IsContainRecipe(
id) )
649 resolved_recipes[count] = recipe_id;
677 string soundCat = recipe.GetSoundCategory(0,sorted[0]);
681 soundCat = recipe.GetSoundCategory(1,sorted[1]);
690 return m_RecipeList[recipeID].GetRecipeAnimationInfo(player, mainItem, target);
eBleedingSourceType GetType()
ItemBase InventoryItemBase
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
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()
static int RecipeIDFromClassname(string classname)
void PluginRecipesManager()
bool IsEnableDebugCrafting()
void RegisterRecipe(RecipeBase recipe)
bool IsRecipePossibleToPerform(int id, ItemBase itemA, ItemBase itemB, PlayerBase player)
ItemBase m_sortedIngredients[MAX_NUMBER_OF_INGREDIENTS]
static ref map< typename, bool > m_RecipesInitializedItem
ItemBase m_ingredient1[MAX_CONCURENT_RECIPES]
const int MAX_NUMBER_OF_RECIPES
string GetRecipeClassName(int recipe_id)
ref array< int > m_RcpsArray
void ~PluginRecipesManager()
static ref map< string, ref CacheObject > m_RecipeCache
void CallbackGenerateCache()
void GenerateRecipeCache()
const int MAX_CONCURENT_RECIPES
ref array< ref RecipeBase > m_RecipeList
const int MAX_INGREDIENTS
int m_ResolvedRecipes[MAX_CONCURENT_RECIPES]
int m_IngredientBitMaskSize[MAX_INGREDIENTS]
static int GetMaxNumberOfRecipes()
void GenerateHumanReadableRecipeList()
bool GetIsRepeatable(int recipe_id)
void UnregisterRecipe(string clasname)
bool m_EnableDebugCrafting
bool ResolveIngredients(int num_of_ingredients, int passes=0)
void SetEnableDebugCrafting(bool enable)
void PerformRecipeServer(int id, ItemBase item_a, ItemBase item_b, PlayerBase player)
void PrintResultMasks(int num)
static ref map< string, int > m_RecipeNamesList
bool GetIsInstaRecipe(int recipe_id)
float GetRecipeSpecialty(int recipe_id)
ItemBase m_ingredient3[MAX_CONCURENT_RECIPES]
int GetValidRecipesProper(int num_of_items, ItemBase items[], array< int > ids, PlayerBase player)
ref array< int > m_RecipesMatched
int m_BitsResults[MAX_INGREDIENTS]
ref array< string > m_CachedItems
int GetAnimationCommandUID(int recipeID)
int GetRecipeIntersection(int num_of_ingredients, ItemBase items[])
fills an array with recipe IDs which 'item_a' and 'item_b' share
array< RecipeBase > GetRecipesForItem(string itemName)
bool CheckRecipe(int id, ItemBase item1, ItemBase item2, PlayerBase player)
float GetRecipeLengthInSecs(int recipe_id)
ItemBase m_ingredient2[MAX_CONCURENT_RECIPES]
int m_IngredientBitMask[MAX_INGREDIENTS]
bool RecipeSanityCheck(int num_of_ingredients, InventoryItemBase items[], PlayerBase player)
ItemBase m_Ingredients[MAX_INGREDIENTS]
string GetRecipeName(int recipe_id)
RecipeAnimationInfo GetRecipeAnimationInfo(int recipeID, PlayerBase player, ItemBase mainItem, ItemBase target)
string GetSoundCategory(int recipeID, ItemBase item1, ItemBase item2)
void MatchItems(TStringArray full_path)
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
int SortIngredients(int num_of_ingredients, ItemBase items_unsorted[], int resolved_recipes[])
int GetValidRecipes(ItemBase item1, ItemBase item2, array< int > ids, PlayerBase player)
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.
Obsolete Managed PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
class array< Class T > TStringArray
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.
proto string Get(int index)
Gets n-th character from string.