Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
cacheobject.c
Go to the documentation of this file.
1
3{
4 int m_Mask;
5 int m_BitCount;
6
7 void RecipeCacheData(int mask)
8 {
9 SetMask(mask);
10 }
11
12 int GetMask()
13 {
14 return m_Mask;
15 }
16
17 int GetBitCount()
18 {
19 return m_BitCount;
20 }
21
22 void SetMask(int mask)
23 {
24 m_Mask = mask;
25 m_BitCount = Math.GetNumberOfSetBits(mask);
26 }
27
28}
29
30class CacheObject
31{
34 //RecipeCacheData data;
40
41 bool AddRecipe(int recipe_id, int mask)
42 {
43 RecipeCacheData data = m_Recipes.Get(recipe_id);
44 if(data)
45 {
46 UpdateMask(recipe_id, mask);
47 }
48 else
49 {
50 m_Recipes.Insert(recipe_id, new RecipeCacheData(mask));
51 m_RecipeIDs.Insert(recipe_id);
52
53 }
54 return true;
55 }
56
57
58 void UpdateMask(int recipe_id, int mask)
59 {
60 RecipeCacheData data = m_Recipes.Get(recipe_id);
61 data.SetMask(data.GetMask() | mask);
62
63 }
64
65
67 {
68 return m_Recipes.Count();
69 }
70
72 {
73 return m_RecipeIDs;
74 }
75
76 bool IsContainRecipe(int recipe_id)
77 {
78 return m_Recipes.Contains(recipe_id);
79 }
80
81 int GetMaskByRecipeID(int recipe_id)
82 {
83 RecipeCacheData cache_data = m_Recipes.Get(recipe_id);
84 if(cache_data)
85 return cache_data.GetMask();
86 return 0;
87 }
88
89 int GetBitCountByRecipeID(int recipe_id)
90 {
91 RecipeCacheData cache_data = m_Recipes.Get(recipe_id);
92 if(cache_data)
93 return cache_data.GetBitCount();
94 return 0;
95 }
96
98 {
99 for(int i = 0; i < m_Recipes.Count();i++)
100 {
101 Print("recipeID:"+m_Recipes.GetKey(i).ToString());
102 Print("mask:"+m_Recipes.GetElement(i).m_Mask.ToString());
103 Print("m_BitCount:"+m_Recipes.GetElement(i).m_BitCount.ToString());
104
105 }
106 }
107}
bool IsContainRecipe(int recipe_id)
Definition cacheobject.c:76
array< int > GetRecipes()
Definition cacheobject.c:71
ref array< int > m_RecipeIDs
Definition cacheobject.c:33
int GetBitCountByRecipeID(int recipe_id)
Definition cacheobject.c:89
int GetNumberOfRecipes()
Definition cacheobject.c:66
class RecipeCacheData m_Recipes
int GetMaskByRecipeID(int recipe_id)
Definition cacheobject.c:81
void DebugPrint()
Definition cacheobject.c:97
void CacheObject()
Definition cacheobject.c:35
void UpdateMask(int recipe_id, int mask)
Definition cacheobject.c:58
bool AddRecipe(int recipe_id, int mask)
Definition cacheobject.c:41
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto void Print(void var)
Prints content of variable to console/log.