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");
192 for (
int i = 0; i < all_config_paths.Count(); i++)
194 config_path = all_config_paths.Get(i);
197 for (
int x = 0;
x < children_count;
x++)
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++)
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;
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
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native void ConfigGetFullPath(string path, out TStringArray full_path)
proto native void ProfilerStop(string name)
Use for profiling code from start to stop, they must match have same name, look wiki pages for more i...
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto native void ProfilerStart(string name)
Use for profiling code from start to stop, they must match have same name, look wiki pages for more i...
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
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
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)
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)
string GetSoundCategory(int ingredientIndex, ItemBase item)
ref array< string > m_Ingredients[MAX_NUMBER_OF_INGREDIENTS]
void PerformRecipe(ItemBase item1, ItemBase item2, PlayerBase player)
bool CheckRecipe(ItemBase item1, ItemBase item2, 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.
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
array< string > TStringArray
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
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.