DayZ 1.24
Loading...
Searching...
No Matches
CraftingManager.c
Go to the documentation of this file.
1
3{
4 const int CM_MODE_NONE = 0;
5 const int CM_MODE_WORLD = 1;
6 const int CM_MODE_INVENTORY = 2;
7
9 PluginRecipesManager m_recipesManager;
17
19
30
32 {
34 }
35
37 {
38 return m_recipeID;
39 }
40
42 {
44 }
45
47 {
49 }
50
52 {
53 return m_recipeCount;
54 }
55 // deprecated
57 {
58
59 }
60
62 {
65
66 if (m_player.GetActionManager().GetRunningAction())
67 return;
68
69 ItemBase item_in_hands = m_player.GetItemInHands();
70
71 if (!item1 || !item2)
72 {
73 m_recipeCount = 0;
76 return;
77 }
78 else
79 {
80
82 {
85
86 item1.GetInventory().GetCurrentInventoryLocation(il1);
87 item2.GetInventory().GetCurrentInventoryLocation(il2);
88
89 Error("Crafting manager - both of items are out of hands - item1: " + il1.DumpToString() + " item2: " + il2.DumpToString() + " / item in hands: - " + item_in_hands);
90 }
91 }
92
93 int recipeCount = 0;
94
96 {
100 return;
101 }
102
104
105 if (recipeCount == 0)
106 {
107 m_recipeCount = 0;
110 }
111 else
112 {
114 {
118 m_item1 = item1;
119 m_item2 = item2;
120
122 }
124 }
125
126 }
127
129 {
130 int recipeCount = m_recipesManager.GetValidRecipes(item1, item2, m_recipes, m_player);
131
132 for (int i = 0; i < recipeCount; i++)
133 {
134 if (recipeID == -1 || m_recipes.Get(i) == recipeID)
135 {
136 if (m_recipesManager.GetIsInstaRecipe(m_recipes.Get(i)) || m_recipesManager.IsEnableDebugCrafting())
137 {
139 m_player.RPCSingleParam(ERPCs.RPC_CRAFTING_INVENTORY_INSTANT, craftParam, true, m_player.GetIdentity());
140 return true;
141 }
142 else
143 {
147 m_item1 = item1;
148 m_item2 = item2;
149 m_recipeID = m_recipes.Get(i);
150
151 ActionManagerClient am = ActionManagerClient.Cast(m_player.GetActionManager());
152
153 if (m_player.GetItemInHands() == item1) am.SetInventoryAction(am.GetAction(ActionWorldCraft), item2, item1);
154 else am.SetInventoryAction(am.GetAction(ActionWorldCraft), item1, item2);
155
156 return true;
157 }
158 }
159
160 }
161 return false;
162 }
163
169
171 {
172 return true;
173 }
174
176 {
177 return m_recipes[action_index];
178 }
179}
ERPCs
Definition ERPCs.c:2
static ActionVariantManager GetVariantManager(typename actionName)
ScriptInvoker GetOnUpdateInvoker()
void SetActionVariantCount(int count)
Client only - manage set up crafting on client.
ref array< int > m_recipes
void CraftingManager(PlayerBase player, PluginRecipesManager recipesManager)
bool SetInventoryCraft(int recipeID, ItemBase item1, ItemBase item2)
const int CM_MODE_WORLD
void OnUpdate(Object item, Object target, int component_index)
const int CM_MODE_NONE
const int CM_MODE_INVENTORY
PlayerBase m_player
PluginRecipesManager m_recipesManager
int GetRecipeID(int action_index)
void SetRecipeID(int recipeID)
ActionVariantManager m_actionVariantManager
InventoryLocation.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
proto native void Clear()
remove all calls from list
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto native void OnUpdate()
Definition tools.c:333