12 override void CreateActionComponent()
34 private string m_ActionPrompt;
46 ActionData action_data =
new WorldCraftActionData;
50 override void CreateConditionComponents()
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) );
63 override string GetText()
68 PluginRecipesManager module_recipes_manager;
69 Class.CastTo(module_recipes_manager,
GetPlugin(PluginRecipesManager) );
70 return module_recipes_manager.GetRecipeName( player.GetCraftingManager().GetRecipeID(
m_VariantID) );
73 return "Default worldcraft text";
79 if ( !
GetGame().IsDedicatedServer() )
85 if ( !target.GetObject() || !item )
92 override string GetSoundCategory(
ActionData action_data)
94 WorldCraftActionData actionDataWorldCraft = WorldCraftActionData.Cast(action_data);
97 ItemBase item = actionDataWorldCraft.m_MainItem;
99 PluginRecipesManager recipesManager = PluginRecipesManager.Cast(
GetPlugin(PluginRecipesManager));
101 string soundCat = recipesManager.GetSoundCategory(actionDataWorldCraft.m_RecipeID,target, item);
108 if (super.SetupAction(player, target, item, action_data, extra_data ))
110 if (!
GetGame().IsDedicatedServer())
112 WorldCraftActionData action_data_wc;
113 Class.CastTo(action_data_wc, action_data);
114 action_data_wc.m_RecipeID = player.GetCraftingManager().GetRecipeID(
m_VariantID);
123 super.Start(action_data);
124 if ( action_data.m_Player ) action_data.m_Player.TryHideItemInHands(
true);
127 override void OnEndServer(
ActionData action_data )
129 if ( action_data.m_Player ) action_data.m_Player.TryHideItemInHands(
false);
132 override void OnEndClient(
ActionData action_data )
134 if ( action_data.m_Player ) action_data.m_Player.TryHideItemInHands(
false);
137 override void OnFinishProgressServer(
ActionData action_data )
145 WorldCraftActionData action_data_wc;
146 PluginRecipesManager module_recipes_manager;
149 Class.CastTo(action_data_wc, action_data);
150 Class.CastTo(module_recipes_manager,
GetPlugin(PluginRecipesManager) );
151 Class.CastTo(item2, action_data.m_Target.GetObject() );
153 if( action_data.m_MainItem && item2 )
155 module_recipes_manager.PerformRecipeServer( action_data_wc.m_RecipeID, action_data.m_MainItem, item2, action_data.m_Player );
159 override void OnFinishProgressClient(
ActionData action_data )
167 super.WriteToContext(ctx, action_data);
169 WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
171 ctx.Write(action_data_wc.m_RecipeID);
174 override bool ReadFromContext(
ParamsReadContext ctx, out ActionReciveData action_recive_data )
176 if (!action_recive_data)
181 super.ReadFromContext(ctx, action_recive_data);
184 if (!ctx.Read(recipeID))
188 recive_data_wc.m_RecipeID = recipeID;
193 override void HandleReciveData(ActionReciveData action_recive_data,
ActionData action_data)
197 WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
199 action_data_wc.m_MainItem = recive_data_wc.m_MainItem;
200 if (!action_recive_data.m_Target)
206 action_data_wc.m_Target = recive_data_wc.m_Target;
208 action_data_wc.m_RecipeID = recive_data_wc.m_RecipeID;