20 const int MAX_CONCURENT_RECIPES = 128;
21 const int MAX_INGREDIENTS = 5;
26 bool m_EnableDebugCrafting =
false;
73 m_EnableDebugCrafting =
enable;
94 if ((
item1.GetInventory().IsAttachment() &&
item1.GetHierarchyParent().DisassembleOnLastDetach()) || (
item2.GetInventory().IsAttachment() &&
item2.GetHierarchyParent().DisassembleOnLastDetach()))
99 m_Ingredients[0] =
item1;
100 m_Ingredients[1] =
item2;
121 p_recipe = m_RecipeList[m_ResolvedRecipes[
i]];
123 if (
p_recipe.CheckRecipe(m_ingredient1[
i], m_ingredient2[
i],
player) ==
true)
161 Debug.
Log(
"CallbackGenerateCache",
"recipes");
169 GetGame().ProfilerStart(
"m_RecipeCache");
172 m_CachedItems.Clear();
173 PluginRecipesManager.m_RecipeCache.Clear();
203 GetGame().ProfilerStop(
"m_RecipeCache");
209 for (
int c = 0;
c < m_RecipeList.Count();
c++)
220 for (
int x = 0;
x <
list.Count();
x++)
263 m_CoBase = m_RecipeCache.Get(m_BaseName);
266 m_RcpsArray = m_RecipeCache.Get(m_BaseName).GetRecipes();
268 for (
int x = 0;
x < m_RcpsArray.Count();
x++)
273 m_BaseMask = m_CoBase.GetMaskByRecipeID(
m_RecipeID);
285 m_Ingredients[0] =
item_a;
286 m_Ingredients[1] =
item_b;
290 Error(
"PerformRecipeServer - one of the items null !!");
301 Error(
"PerformRecipeServer - recipe not valid !!");
306 Error(
"PerformRecipeServer - recipe failed to pass sanity check !!");
310 ptrRecipe.PerformRecipe(m_sortedIngredients[0], m_sortedIngredients[1],
player);
325 for (
int i = 0;
i < PluginRecipesManager.m_RecipeCache.Count();
i++)
327 string key = PluginRecipesManager.m_RecipeCache.GetKey(
i);
390 if (m_RegRecipeIndex >= MAX_NUMBER_OF_RECIPES)
391 Error(
"Exceeded max. number of recipes, max set to: " + MAX_NUMBER_OF_RECIPES.ToString());
393 m_RegRecipeIndex = m_RecipeList.Insert(
recipe);
394 recipe.SetID(m_RegRecipeIndex);
395 m_RecipeNamesList.Insert(
recipe.ClassName(), m_RegRecipeIndex);
414 if (m_RecipeNamesList.Contains(
classname))
427 for (
int i = 0;
i < PluginRecipesManager.m_RecipeCache.Count();
i++)
429 string key = PluginRecipesManager.m_RecipeCache.GetKey(
i);
430 CacheObject co = PluginRecipesManager.m_RecipeCache.GetElement(
i);
445 m_IngredientBitMask[
i] =
co_item.GetMaskByRecipeID(
id);
446 m_IngredientBitMaskSize[
i] =
co_item.GetBitCountByRecipeID(
id);
466 m_BitsResults[
i] = 0;
478 int count = m_IngredientBitMaskSize[
i];
503 if ((m_IngredientBitMask[z] | m_BitsResults[z]) == 0)
523 for (
int i = 0;
i <
num;
i++)
524 Debug.
Log(
"results mask(" +
i.ToString() +
") = " + m_BitsResults[
i].ToString());
533 m_RecipesMatched.Clear();
567 m_RecipesMatched.Insert(
id);
579 for (
int i = 0;
i < m_RecipesMatched.Count() &&
i < MAX_CONCURENT_RECIPES;
i++)
586 m_ingredient1[
count] = m_sortedIngredients[0];
587 m_ingredient2[
count] = m_sortedIngredients[1];
eBleedingSourceType GetType()
DetachActionData m_ItemName
WorldCraftActionReciveData m_RecipeID
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.
static int RecipeIDFromClassname(string classname)
void PluginRecipesManager()
bool IsEnableDebugCrafting()
void RegisterRecipe(RecipeBase recipe)
ref array< int > m_RcpsArray
void ~PluginRecipesManager()
void CallbackGenerateCache()
void GenerateRecipeCache()
const int MAX_CONCURENT_RECIPES
const int MAX_INGREDIENTS
static int GetMaxNumberOfRecipes()
void GenerateHumanReadableRecipeList()
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)
bool GetIsInstaRecipe(int recipe_id)
float GetRecipeSpecialty(int recipe_id)
int GetValidRecipesProper(int num_of_items, ItemBase items[], array< int > ids, PlayerBase player)
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)
bool RecipeSanityCheck(int num_of_ingredients, InventoryItemBase items[], PlayerBase player)
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)
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.