DayZ 1.24
Loading...
Searching...
No Matches
CraftingManager Class Reference

Client only - manage set up crafting on client. More...

Collaboration diagram for CraftingManager:
[legend]

Private Member Functions

void CraftingManager (PlayerBase player, PluginRecipesManager recipesManager)
 
void SetRecipeID (int recipeID)
 
int GetRecipeID ()
 
bool IsInventoryCraft ()
 
bool IsWorldCraft ()
 
int GetRecipesCount ()
 
void SetNextRecipe ()
 
void OnUpdate (Object item, Object target, int component_index)
 
bool SetInventoryCraft (int recipeID, ItemBase item1, ItemBase item2)
 
void ResetInventoryCraft ()
 
bool IsEnableDebugCrafting ()
 
int GetRecipeID (int action_index)
 

Private Attributes

const int CM_MODE_NONE = 0
 
const int CM_MODE_WORLD = 1
 
const int CM_MODE_INVENTORY = 2
 
PlayerBase m_player
 
PluginRecipesManager m_recipesManager
 
ActionVariantManager m_actionVariantManager
 
int m_recipeID
 
int m_contextualRecipeID
 
int m_recipeCount
 
int m_craftingMode
 
ItemBase m_item1
 
ItemBase m_item2
 
ref array< intm_recipes
 

Detailed Description

Client only - manage set up crafting on client.

Definition at line 2 of file CraftingManager.c.

Constructor & Destructor Documentation

◆ CraftingManager()

void CraftingManager::CraftingManager ( PlayerBase player,
PluginRecipesManager recipesManager )
inlineprivate

Definition at line 20 of file CraftingManager.c.

21 {
29 }
static ActionVariantManager GetVariantManager(typename actionName)
ScriptInvoker GetOnUpdateInvoker()
ref array< int > m_recipes
const int CM_MODE_NONE
PlayerBase m_player
PluginRecipesManager m_recipesManager
ActionVariantManager m_actionVariantManager
proto native void Clear()
remove all calls from list
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
proto native void OnUpdate()
Definition tools.c:333

References ScriptInvoker::Clear(), CM_MODE_NONE, ActionVariantManager::GetOnUpdateInvoker(), ActionManagerClient::GetVariantManager(), ScriptInvoker::Insert(), m_actionVariantManager, m_craftingMode, m_player, m_recipes, m_recipesManager, and OnUpdate().

Member Function Documentation

◆ GetRecipeID() [1/2]

int CraftingManager::GetRecipeID ( )
inlineprivate

Definition at line 36 of file CraftingManager.c.

37 {
38 return m_recipeID;
39 }

References m_recipeID.

◆ GetRecipeID() [2/2]

int CraftingManager::GetRecipeID ( int action_index)
inlineprivate

Definition at line 175 of file CraftingManager.c.

176 {
177 return m_recipes[action_index];
178 }

References m_recipes.

◆ GetRecipesCount()

int CraftingManager::GetRecipesCount ( )
inlineprivate

Definition at line 51 of file CraftingManager.c.

52 {
53 return m_recipeCount;
54 }

References m_recipeCount.

◆ IsEnableDebugCrafting()

bool CraftingManager::IsEnableDebugCrafting ( )
inlineprivate

Definition at line 170 of file CraftingManager.c.

171 {
172 return true;
173 }

◆ IsInventoryCraft()

bool CraftingManager::IsInventoryCraft ( )
inlineprivate

Definition at line 41 of file CraftingManager.c.

42 {
44 }
const int CM_MODE_INVENTORY

References CM_MODE_INVENTORY, and m_craftingMode.

◆ IsWorldCraft()

bool CraftingManager::IsWorldCraft ( )
inlineprivate

Definition at line 46 of file CraftingManager.c.

47 {
49 }
const int CM_MODE_WORLD

References CM_MODE_WORLD, and m_craftingMode.

◆ OnUpdate()

void CraftingManager::OnUpdate ( Object item,
Object target,
int component_index )
inlineprivate

Definition at line 61 of file CraftingManager.c.

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 }
void SetActionVariantCount(int count)
InventoryLocation.
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References ActionVariantManager::Clear(), CM_MODE_INVENTORY, CM_MODE_NONE, CM_MODE_WORLD, Error(), m_actionVariantManager, m_contextualRecipeID, m_craftingMode, m_item1, m_item2, m_player, m_recipeCount, m_recipeID, m_recipes, m_recipesManager, and ActionVariantManager::SetActionVariantCount().

◆ ResetInventoryCraft()

void CraftingManager::ResetInventoryCraft ( )
inlineprivate

Definition at line 164 of file CraftingManager.c.

165 {
166 m_recipeCount = 0;
168 }

References CM_MODE_NONE, m_craftingMode, and m_recipeCount.

◆ SetInventoryCraft()

bool CraftingManager::SetInventoryCraft ( int recipeID,
ItemBase item1,
ItemBase item2 )
inlineprivate

Definition at line 128 of file CraftingManager.c.

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 }
ERPCs
Definition ERPCs.c:2
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12

References CM_MODE_INVENTORY, m_contextualRecipeID, m_craftingMode, m_item1, m_item2, m_player, m_recipeCount, m_recipeID, m_recipes, and m_recipesManager.

◆ SetNextRecipe()

void CraftingManager::SetNextRecipe ( )
inlineprivate

Definition at line 56 of file CraftingManager.c.

57 {
58
59 }

◆ SetRecipeID()

void CraftingManager::SetRecipeID ( int recipeID)
inlineprivate

Definition at line 31 of file CraftingManager.c.

32 {
34 }

References m_recipeID.

Member Data Documentation

◆ CM_MODE_INVENTORY

const int CraftingManager::CM_MODE_INVENTORY = 2
private

Definition at line 6 of file CraftingManager.c.

Referenced by IsInventoryCraft(), OnUpdate(), and SetInventoryCraft().

◆ CM_MODE_NONE

const int CraftingManager::CM_MODE_NONE = 0
private

Definition at line 4 of file CraftingManager.c.

Referenced by CraftingManager(), OnUpdate(), and ResetInventoryCraft().

◆ CM_MODE_WORLD

const int CraftingManager::CM_MODE_WORLD = 1
private

Definition at line 5 of file CraftingManager.c.

Referenced by IsWorldCraft(), and OnUpdate().

◆ m_actionVariantManager

ActionVariantManager CraftingManager::m_actionVariantManager
private

Definition at line 10 of file CraftingManager.c.

Referenced by CraftingManager(), and OnUpdate().

◆ m_contextualRecipeID

int CraftingManager::m_contextualRecipeID
private

Definition at line 12 of file CraftingManager.c.

Referenced by OnUpdate(), and SetInventoryCraft().

◆ m_craftingMode

int CraftingManager::m_craftingMode
private

◆ m_item1

ItemBase CraftingManager::m_item1
private

Definition at line 15 of file CraftingManager.c.

Referenced by OnUpdate(), and SetInventoryCraft().

◆ m_item2

ItemBase CraftingManager::m_item2
private

Definition at line 16 of file CraftingManager.c.

Referenced by OnUpdate(), and SetInventoryCraft().

◆ m_player

PlayerBase CraftingManager::m_player
private

Definition at line 8 of file CraftingManager.c.

Referenced by CraftingManager(), OnUpdate(), and SetInventoryCraft().

◆ m_recipeCount

int CraftingManager::m_recipeCount
private

◆ m_recipeID

int CraftingManager::m_recipeID
private

Definition at line 11 of file CraftingManager.c.

Referenced by GetRecipeID(), OnUpdate(), SetInventoryCraft(), and SetRecipeID().

◆ m_recipes

ref array<int> CraftingManager::m_recipes
private

Definition at line 18 of file CraftingManager.c.

Referenced by CraftingManager(), GetRecipeID(), OnUpdate(), and SetInventoryCraft().

◆ m_recipesManager

PluginRecipesManager CraftingManager::m_recipesManager
private

Definition at line 9 of file CraftingManager.c.

Referenced by CraftingManager(), OnUpdate(), and SetInventoryCraft().


The documentation for this class was generated from the following file: