cacontinuouscraft.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. class CAContinuousCraft : CAContinuousTime
  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. WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
  16. PluginRecipesManager module_recipes_manager;
  17. Class.CastTo(module_recipes_manager, GetPlugin(PluginRecipesManager));
  18. if( module_recipes_manager )
  19. {
  20. m_AdjustedTimeToComplete = module_recipes_manager.GetRecipeLengthInSecs( action_data_wc.m_RecipeID );
  21. if( module_recipes_manager.GetIsInstaRecipe( action_data_wc.m_RecipeID) || module_recipes_manager.IsEnableDebugCrafting() )
  22. {
  23. m_AdjustedTimeToComplete = 0;
  24. }
  25. float specialty_weight = module_recipes_manager.GetRecipeSpecialty( action_data_wc.m_RecipeID );
  26. m_AdjustedTimeToComplete = m_AdjustedTimeToComplete;//removed softskills
  27. //PrintString("ttc:" + m_AdjustedTimeToComplete.ToString());
  28. }
  29. }
  30. override int Execute( ActionData action_data )
  31. {
  32. if ( !action_data.m_Player )
  33. {
  34. return UA_ERROR;
  35. }
  36. if ( m_TimeElpased < m_AdjustedTimeToComplete )
  37. {
  38. m_TimeElpased += action_data.m_Player.GetDeltaT();
  39. }
  40. else
  41. {
  42. if ( m_SpentUnits )
  43. {
  44. m_SpentUnits.param1 = m_TimeElpased;
  45. SetACData(m_SpentUnits);
  46. }
  47. m_TimeElpased = m_AdjustedTimeToComplete - m_TimeElpased;
  48. OnCompletePogress(action_data);
  49. WorldCraftActionData action_data_wc = WorldCraftActionData.Cast(action_data);
  50. PluginRecipesManager module_recipes_manager;
  51. Class.CastTo(module_recipes_manager, GetPlugin(PluginRecipesManager));
  52. if (module_recipes_manager)
  53. {
  54. if(module_recipes_manager.GetIsRepeatable(action_data_wc.m_RecipeID))
  55. {
  56. return UA_PROCESSING;
  57. }
  58. }
  59. return UA_FINISHED;
  60. }
  61. return UA_PROCESSING;
  62. }
  63. override float GetProgress()
  64. {
  65. if( m_AdjustedTimeToComplete > 0 )
  66. {
  67. //float progress = m_TimeElpased/m_AdjustedTimeToComplete;
  68. return m_TimeElpased/m_AdjustedTimeToComplete;
  69. }
  70. return 1;
  71. }
  72. };