Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuouscraft.c
Go to the documentation of this file.
2 {
3  override void Setup( ActionData action_data )
4  {
5  m_TimeElpased = 0;
6  m_AdjustedTimeToComplete = 1000; //indication of arror if somting will be craft 1000 sec
7  if ( !m_SpentUnits )
8  {
9  m_SpentUnits = new Param1<float>(0);
10  }
11  else
12  {
13  m_SpentUnits.param1 = 0;
14  }
15 
16  WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
17 
18  PluginRecipesManager module_recipes_manager;
19  Class.CastTo(module_recipes_manager, GetPlugin(PluginRecipesManager));
20  if( module_recipes_manager )
21  {
22  m_AdjustedTimeToComplete = module_recipes_manager.GetRecipeLengthInSecs( action_data_wc.m_RecipeID );
23  if( module_recipes_manager.GetIsInstaRecipe( action_data_wc.m_RecipeID) || module_recipes_manager.IsEnableDebugCrafting() )
24  {
25  m_AdjustedTimeToComplete = 0;
26  }
27  float specialty_weight = module_recipes_manager.GetRecipeSpecialty( action_data_wc.m_RecipeID );
28  m_AdjustedTimeToComplete = action_data.m_Player.GetSoftSkillsManager().AdjustCraftingTime( m_AdjustedTimeToComplete, specialty_weight );
29 
30  //PrintString("ttc:" + m_AdjustedTimeToComplete.ToString());
31  }
32  }
33 
34  override int Execute( ActionData action_data )
35  {
36  if ( !action_data.m_Player )
37  {
38  return UA_ERROR;
39  }
40 
41  if ( m_TimeElpased < m_AdjustedTimeToComplete )
42  {
43  m_TimeElpased += action_data.m_Player.GetDeltaT();
44  }
45  else
46  {
47  if ( m_SpentUnits )
48  {
49  m_SpentUnits.param1 = m_TimeElpased;
50  SetACData(m_SpentUnits);
51  }
52  OnCompletePogress(action_data);
53  return UA_FINISHED;
54  }
55  return UA_PROCESSING;
56  }
57 
58  override float GetProgress()
59  {
60  if( m_AdjustedTimeToComplete > 0 )
61  {
62  //float progress = m_TimeElpased/m_AdjustedTimeToComplete;
63  return m_TimeElpased/m_AdjustedTimeToComplete;
64  }
65  return 1;
66  }
67 };
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
CAContinuousTime
Definition: cacontinuoustime.c:1
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
CAContinuousCraft
Definition: cacontinuouscraft.c:1
ActionData
Definition: actionbase.c:20
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10