actionlightitemonfirewithblowtorch.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. class ActionLightItemOnFireWithBlowtorchCB : ActionLightItemOnFireCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.FIREPLACE_IGNITE);
  6. }
  7. }
  8. class ActionLightItemOnFireWithBlowtorch : ActionLightItemOnFire
  9. {
  10. void ActionLightItemOnFireWithBlowtorch()
  11. {
  12. m_CallbackClass = ActionLightItemOnFireWithBlowtorchCB;
  13. }
  14. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  15. {
  16. Blowtorch bt = Blowtorch.Cast(item);
  17. if (!bt.HasEnoughEnergyForRepair(UATimeSpent.FIREPLACE_IGNITE))
  18. {
  19. return false;
  20. }
  21. ItemBase target_item = ItemBase.Cast(target.GetObject());
  22. if (target_item && item)
  23. {
  24. // when igniting item on the ground with igniter in hands
  25. if (!target_item.IsIgnited() && !IsItemInCargoOfSomething(target_item) && target_item.CanBeIgnitedBy(item))
  26. {
  27. // oven stage of standard fireplace
  28. if (target_item.IsKindOf("Fireplace"))
  29. {
  30. if (Fireplace.Cast(target_item).IsOven())
  31. {
  32. return true;
  33. }
  34. if (Fireplace.CanIgniteEntityAsFireplace(target_item))
  35. {
  36. return true;
  37. }
  38. return false;
  39. }
  40. return true;
  41. }
  42. // when igniting item in hands from something on ground
  43. else if (!item.IsIgnited() && !IsItemInCargoOfSomething(item) && target_item.CanIgniteItem(item) && item.CanBeIgnitedBy(target_item))
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. override void OnUpdateServer(ActionData action_data)
  51. {
  52. super.OnUpdate(action_data);
  53. if (action_data.m_State == UA_PROCESSING && !action_data.m_MainItem.GetCompEM().IsWorking())
  54. {
  55. Interrupt(action_data);
  56. }
  57. }
  58. override void OnExecuteServer(ActionData action_data)
  59. {
  60. super.OnExecuteServer(action_data);
  61. action_data.m_MainItem.GetCompEM().SwitchOn();
  62. }
  63. override void OnFinishProgressServer(ActionData action_data)
  64. {
  65. super.OnFinishProgressServer(action_data);
  66. action_data.m_MainItem.GetCompEM().SwitchOff();
  67. }
  68. override void OnEndServer(ActionData action_data)
  69. {
  70. super.OnEndServer(action_data);
  71. action_data.m_MainItem.GetCompEM().SwitchOff();
  72. }
  73. }