Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
30 class CacheObject
31 {
34  //RecipeCacheData data;
35  void CacheObject()
36  {
38  m_RecipeIDs = new array<int>;
39  }
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 
97  void DebugPrint()
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 }
DebugPrint
void DebugPrint()
Definition: cacheobject.c:97
m_Recipes
class RecipeCacheData m_Recipes
Print
proto void Print(void var)
Prints content of variable to console/log.
GetNumberOfRecipes
int GetNumberOfRecipes()
Definition: cacheobject.c:66
GetBitCountByRecipeID
int GetBitCountByRecipeID(int recipe_id)
Definition: cacheobject.c:89
map
map
Definition: controlsxboxnew.c:3
GetRecipes
array< int > GetRecipes()
Definition: cacheobject.c:71
IsContainRecipe
bool IsContainRecipe(int recipe_id)
Definition: cacheobject.c:76
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
CacheObject
void CacheObject()
Definition: cacheobject.c:35
AddRecipe
bool AddRecipe(int recipe_id, int mask)
Definition: cacheobject.c:41
UpdateMask
void UpdateMask(int recipe_id, int mask)
Definition: cacheobject.c:58
m_RecipeIDs
ref array< int > m_RecipeIDs
Definition: cacheobject.c:33
GetMaskByRecipeID
int GetMaskByRecipeID(int recipe_id)
Definition: cacheobject.c:81
Math
Definition: enmath.c:6
RecipeCacheData
Definition: cacheobject.c:2