36 private string m_ActionPrompt;
46 override ActionData CreateActionData()
48 ActionData action_data =
new WorldCraftActionData;
52 override void CreateConditionComponents()
58 override void OnActionInfoUpdate(
PlayerBase player, ActionTarget target,
ItemBase item )
60 PluginRecipesManager module_recipes_manager;
61 Class.CastTo(module_recipes_manager,
GetPlugin(PluginRecipesManager) );
62 m_Text = module_recipes_manager.GetRecipeName( player.GetCraftingManager().GetRecipeID(
m_VariantID) );
65 override string GetText()
70 PluginRecipesManager moduleRecipesManager;
71 Class.CastTo(moduleRecipesManager,
GetPlugin(PluginRecipesManager) );
72 return moduleRecipesManager.GetRecipeName( player.GetCraftingManager().GetRecipeID(
m_VariantID) );
75 return "Default worldcraft text";
82 if (!target.GetObject() || !item)
89 override bool ActionConditionContinue(ActionData action_data)
93 if (!action_data.m_Target.GetObject() || !action_data.m_MainItem)
96 PluginRecipesManager moduleRecipesManager;
97 Class.CastTo(moduleRecipesManager,
GetPlugin(PluginRecipesManager) );
99 WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
102 Class.CastTo(item2, action_data_wc.m_Target.GetObject());
103 if(!moduleRecipesManager.IsRecipePossibleToPerform(action_data_wc.m_RecipeID, action_data.m_MainItem, item2, action_data.m_Player))
112 override string GetSoundCategory(ActionData action_data)
114 WorldCraftActionData actionDataWorldCraft = WorldCraftActionData.Cast(action_data);
117 ItemBase item = actionDataWorldCraft.m_MainItem;
119 PluginRecipesManager recipesManager = PluginRecipesManager.Cast(
GetPlugin(PluginRecipesManager));
121 string soundCat = recipesManager.GetSoundCategory(actionDataWorldCraft.m_RecipeID,target, item);
126 override bool SetupAction(
PlayerBase player, ActionTarget target,
ItemBase item, out ActionData action_data,
Param extra_data = NULL )
128 if (super.SetupAction(player, target, item, action_data, extra_data ))
130 WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
132 if (!
GetGame().IsDedicatedServer())
133 action_data_wc.m_RecipeID = player.GetCraftingManager().GetRecipeID(
m_VariantID);
135 PluginRecipesManager moduleRecipesManager;
136 Class.CastTo(moduleRecipesManager,
GetPlugin(PluginRecipesManager));
138 RecipeAnimationInfo recipeAnimationInfo = moduleRecipesManager.GetRecipeAnimationInfo(action_data_wc.m_RecipeID, player, action_data_wc.m_MainItem,
ItemBase.Cast(action_data_wc.m_Target.GetObject()));
140 action_data_wc.m_AnimationID = recipeAnimationInfo.m_AnimationUID;
141 action_data_wc.m_ShowItem = recipeAnimationInfo.m_ItemVisible;
150 override void Start( ActionData action_data )
152 super.Start(action_data);
153 WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
154 if ( action_data_wc.m_Player && !action_data_wc.m_ShowItem )
155 action_data.m_Player.TryHideItemInHands(
true);
158 override void OnEndServer( ActionData action_data )
160 if ( action_data.m_Player ) action_data.m_Player.TryHideItemInHands(
false);
162 super.OnEndServer(action_data);
165 override void OnEndClient( ActionData action_data )
167 if ( action_data.m_Player ) action_data.m_Player.TryHideItemInHands(
false);
170 override void OnFinishProgressServer(ActionData action_data)
172 WorldCraftActionData action_data_wc;
173 PluginRecipesManager module_recipes_manager;
176 Class.CastTo(action_data_wc, action_data);
177 Class.CastTo(module_recipes_manager,
GetPlugin(PluginRecipesManager));
178 Class.CastTo(item2, action_data.m_Target.GetObject());
180 if (action_data.m_MainItem && item2)
187 module_recipes_manager.PerformRecipeServer(action_data_wc.m_RecipeID, action_data.m_MainItem, item2, action_data.m_Player);
198 super.WriteToContext(ctx, action_data);
200 WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
202 ctx.Write(action_data_wc.m_RecipeID);
205 override bool ReadFromContext(
ParamsReadContext ctx, out ActionReciveData action_recive_data )
207 if (!action_recive_data)
212 super.ReadFromContext(ctx, action_recive_data);
215 if (!ctx.Read(recipeID))
219 recive_data_wc.m_RecipeID = recipeID;
224 override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
228 WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
230 action_data_wc.m_MainItem = recive_data_wc.m_MainItem;
231 if (!action_recive_data.m_Target)
233 action_data.m_Target =
new ActionTarget(NULL, NULL, -1,
vector.Zero, 0);
237 action_data_wc.m_Target = recive_data_wc.m_Target;
239 action_data_wc.m_RecipeID = recive_data_wc.m_RecipeID;