cacontinuouscraft.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. OnCompletePogress(action_data);
  48. return UA_FINISHED;
  49. }
  50. return UA_PROCESSING;
  51. }
  52. override float GetProgress()
  53. {
  54. if( m_AdjustedTimeToComplete > 0 )
  55. {
  56. //float progress = m_TimeElpased/m_AdjustedTimeToComplete;
  57. return m_TimeElpased/m_AdjustedTimeToComplete;
  58. }
  59. return 1;
  60. }
  61. };