DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CraftingManager.c
См. документацию.
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
20 void CraftingManager(PlayerBase player, PluginRecipesManager recipesManager)
21 {
22 m_recipesManager = recipesManager;
23 m_player = player;
26 m_actionVariantManager.GetOnUpdateInvoker().Clear();
27 m_actionVariantManager.GetOnUpdateInvoker().Insert(OnUpdate);
29 }
30
32 {
34 {
35 m_actionVariantManager.GetOnUpdateInvoker().Remove(OnUpdate);
36 }
37 }
38
39 void SetRecipeID(int recipeID)
40 {
41 m_recipeID = recipeID;
42 }
43
45 {
46 return m_recipeID;
47 }
48
50 {
52 }
53
55 {
57 }
58
60 {
61 return m_recipeCount;
62 }
63 // deprecated
65 {
66
67 }
68
69 void OnUpdate( Object item, Object target, int component_index )
70 {
71 ItemBase item1 = ItemBase.Cast( item );
72 ItemBase item2 = ItemBase.Cast( target );
73
74 if ( m_player.GetActionManager().GetRunningAction() )
75 return;
76
77 ItemBase item_in_hands = m_player.GetItemInHands();
78
79 if (!item1 || !item2)
80 {
81 m_recipeCount = 0;
84 return;
85 }
86 else
87 {
88
89 if ( item1 != item_in_hands && item2 != item_in_hands )
90 {
93
94 item1.GetInventory().GetCurrentInventoryLocation(il1);
95 item2.GetInventory().GetCurrentInventoryLocation(il2);
96
97 Error("Crafting manager - both of items are out of hands - item1: " + il1.DumpToString() + " item2: " + il2.DumpToString() + " / item in hands: - " + item_in_hands);
98 }
99 }
100
101 int recipeCount = 0;
102
104 {
105 recipeCount = m_recipesManager.GetValidRecipes(m_item1, m_item2, m_recipes, m_player);
106 m_recipeCount = recipeCount;
108 return;
109 }
110
111 recipeCount = m_recipesManager.GetValidRecipes(item1, item2, m_recipes, m_player);
112
113 if (recipeCount == 0)
114 {
115 m_recipeCount = 0;
118 }
119 else
120 {
121 if ( m_craftingMode == CM_MODE_NONE || m_recipeCount != recipeCount || m_item1 != item1 || m_item2 != item2 )
122 {
124 m_recipeCount = recipeCount;
126 m_item1 = item1;
127 m_item2 = item2;
128
129 m_actionVariantManager.SetActionVariantCount(m_recipeCount);
130 }
132 }
133
134 }
135
136 bool SetInventoryCraft(int recipeID, ItemBase item1, ItemBase item2)
137 {
138 int recipeCount = m_recipesManager.GetValidRecipes(item1,item2,m_recipes, m_player);
139
140 for ( int i = 0; i < recipeCount; i++ )
141 {
142 if (recipeID == -1 || m_recipes.Get(i) == recipeID)
143 {
144 if ( m_recipesManager.GetIsInstaRecipe(m_recipes.Get(i)) || m_recipesManager.IsEnableDebugCrafting() )
145 {
146 Param craftParam = new Param3<int, ItemBase, ItemBase>(m_recipes.Get(i), item1, item2);
147 m_player.RPCSingleParam(ERPCs.RPC_CRAFTING_INVENTORY_INSTANT, craftParam, true, m_player.GetIdentity());
148 return true;
149 }
150 else
151 {
153 m_recipeCount = recipeCount;
155 m_item1 = item1;
156 m_item2 = item2;
157 m_recipeID = m_recipes.Get(i);
158
159 ActionManagerClient am = ActionManagerClient.Cast(m_player.GetActionManager());
160
161 if ( m_player.GetItemInHands() == item1) am.SetInventoryAction( am.GetAction(ActionWorldCraft), item2, item1);
162 else am.SetInventoryAction( am.GetAction(ActionWorldCraft), item1, item2);
163
164 return true;
165 }
166 }
167
168 }
169 return false;
170 }
171
177
179 {
180 return true;
181 }
182
183 int GetRecipeID( int action_index )
184 {
185 return m_recipes[action_index];
186 }
187}
ERPCs
Определения ERPCs.c:2
void SetInventoryAction(ActionBase action_name, ItemBase target_item, ItemBase main_item)
Определения ActionManagerClient.c:788
static ActionVariantManager GetVariantManager(typename actionName)
Определения ActionManagerClient.c:255
ref array< int > m_recipes
Определения CraftingManager.c:18
void CraftingManager(PlayerBase player, PluginRecipesManager recipesManager)
Определения CraftingManager.c:20
int m_recipeID
Определения CraftingManager.c:11
ItemBase m_item2
Определения CraftingManager.c:16
bool SetInventoryCraft(int recipeID, ItemBase item1, ItemBase item2)
Определения CraftingManager.c:136
int GetRecipesCount()
Определения CraftingManager.c:59
bool IsInventoryCraft()
Определения CraftingManager.c:49
const int CM_MODE_WORLD
Определения CraftingManager.c:5
void OnUpdate(Object item, Object target, int component_index)
Определения CraftingManager.c:69
bool IsWorldCraft()
Определения CraftingManager.c:54
void SetNextRecipe()
Определения CraftingManager.c:64
int m_contextualRecipeID
Определения CraftingManager.c:12
int m_craftingMode
Определения CraftingManager.c:14
void ~CraftingManager()
Определения CraftingManager.c:31
const int CM_MODE_NONE
Определения CraftingManager.c:4
int GetRecipeID()
Определения CraftingManager.c:44
void ResetInventoryCraft()
Определения CraftingManager.c:172
const int CM_MODE_INVENTORY
Определения CraftingManager.c:6
bool IsEnableDebugCrafting()
Определения CraftingManager.c:178
PlayerBase m_player
Определения CraftingManager.c:8
int m_recipeCount
Определения CraftingManager.c:13
ItemBase m_item1
Определения CraftingManager.c:15
PluginRecipesManager m_recipesManager
Определения CraftingManager.c:9
int GetRecipeID(int action_index)
Определения CraftingManager.c:183
void SetRecipeID(int recipeID)
Определения CraftingManager.c:39
ActionVariantManager m_actionVariantManager
Определения CraftingManager.c:10
string DumpToString()
Определения InventoryLocation.c:233
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
Определения ObjectTyped.c:2
Определения EntityAI.c:95
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
Определения PlayerBaseClient.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90