DayZ 1.24
Loading...
Searching...
No Matches
ActionWorldCraft.c
Go to the documentation of this file.
1class WorldCraftActionReciveData : ActionReciveData
2{
4}
6{
8}
9
11{
12 override void CreateActionComponent()
13 {
14 m_ActionData.m_ActionComponent = new CAContinuousCraft(UATimeSpent.DEFAULT_CRAFT); //default value can be set in recipes
15 }
16
17 /*override void OnFinish(bool pCanceled)
18 {
19 super.OnFinish(pCanceled);
20 if( !GetGame().IsDedicatedServer() )
21 {
22 PlayerBase player;
23 if( Class.CastTo(player, GetGame().GetPlayer()) )
24 {
25 if( player.GetCraftingManager().IsInventoryCraft() )
26 player.GetCraftingManager().CancelInventoryCraft();
27 }
28 }
29 }*/
30};
31
33{
34 private string m_ActionPrompt;
35
37 {
39 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
40 m_FullBody = true;
41 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
42 }
43
49
55
57 {
58 PluginRecipesManager module_recipes_manager;
59 Class.CastTo(module_recipes_manager, GetPlugin(PluginRecipesManager));
60 m_Text = module_recipes_manager.GetRecipeName(player.GetCraftingManager().GetRecipeID(m_VariantID));
61 }
62
63 override string GetText()
64 {
67 {
68 PluginRecipesManager module_recipes_manager;
69 Class.CastTo(module_recipes_manager, GetPlugin(PluginRecipesManager));
70 return module_recipes_manager.GetRecipeName(player.GetCraftingManager().GetRecipeID(m_VariantID));
71 }
72
73 return "Default worldcraft text";
74 }
75
76 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
77 {
78 //Client
79 if (!GetGame().IsDedicatedServer())
80 return true;
81 else //Server
82 {
83 if (!target.GetObject() || !item)
84 return false;
85 }
86
87 return true;
88 }
89
91 {
93
94 ItemBase target = ItemBase.Cast(actionDataWorldCraft.m_Target.GetObject());
96
97 PluginRecipesManager recipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
98
99 string soundCat = recipesManager.GetSoundCategory(actionDataWorldCraft.m_RecipeID, target, item);
100
101 return soundCat;
102 }
103
105 {
106 if (super.SetupAction(player, target, item, action_data, extra_data))
107 {
108 if (!GetGame().IsDedicatedServer())
109 {
112 action_data_wc.m_RecipeID = player.GetCraftingManager().GetRecipeID(m_VariantID);
113 }
114 return true;
115 }
116 return false;
117 }
118
119 override void Start(ActionData action_data) //Setup on start of action
120 {
121 super.Start(action_data);
122 if (action_data.m_Player) action_data.m_Player.TryHideItemInHands(true);
123 }
124
126 {
127 if (action_data.m_Player) action_data.m_Player.TryHideItemInHands(false);
128 }
129
131 {
132 if (action_data.m_Player) action_data.m_Player.TryHideItemInHands(false);
133 }
134
136 {
137 /*if (!GetGame().IsMultiplayer())
138 {
139 ActionManagerClient am = ActionManagerClient.Cast(action_data.m_Player.GetActionManager());
140 am.UnlockInventory(action_data);
141 }*/
142
144 PluginRecipesManager module_recipes_manager;
146
148 Class.CastTo(module_recipes_manager, GetPlugin(PluginRecipesManager));
149 Class.CastTo(item2, action_data.m_Target.GetObject());
150
151 if (action_data.m_MainItem && item2)
152 module_recipes_manager.PerformRecipeServer(action_data_wc.m_RecipeID, action_data.m_MainItem, item2, action_data.m_Player);
153 }
154
156 {
157 /*ActionManagerClient am = ActionManagerClient.Cast(action_data.m_Player.GetActionManager());
158 am.UnlockInventory(action_data);*/
159 }
160
162 {
163 super.WriteToContext(ctx, action_data);
164
166
167 ctx.Write(action_data_wc.m_RecipeID);
168 }
169
171 {
174
175 super.ReadFromContext(ctx, action_recive_data);
176
177 int recipeID;
178 if (!ctx.Read(recipeID))
179 return false;
180
182 recive_data_wc.m_RecipeID = recipeID;
183
184 return true;
185 }
186
188 {
189
192
193 action_data_wc.m_MainItem = recive_data_wc.m_MainItem;
194 if (!action_recive_data.m_Target)
195 action_data.m_Target = new ActionTarget(NULL, NULL, -1, vector.Zero, 0);
196 else
197 action_data_wc.m_Target = recive_data_wc.m_Target;
198 action_data_wc.m_RecipeID = recive_data_wc.m_RecipeID;
199 }
200};
201
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
int m_VariantID
Definition ActionBase.c:59
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
WorldCraftActionReciveData m_RecipeID
PlayerBase GetPlayer()
PluginBase GetPlugin(typename plugin_type)
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
override void CreateActionComponent()
override void OnFinishProgressClient(ActionData action_data)
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
override void CreateConditionComponents()
override string GetText()
override void OnFinishProgressServer(ActionData action_data)
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
override void OnEndServer(ActionData action_data)
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
override ActionData CreateActionData()
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
override string GetSoundCategory(ActionData action_data)
override void OnEndClient(ActionData action_data)
override void Start(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
const float DEFAULT
const float DEFAULT_CRAFT
static const vector Zero
Definition EnConvert.c:110
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.