ActivateTrigger.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //============================================================================================
  2. // Spirenkov Maxim, 2006
  3. //============================================================================================
  4. // ActivateTrigger
  5. //============================================================================================
  6. #include "ActivateTrigger.h"
  7. ActivateTrigger::ActivateTrigger()
  8. {
  9. }
  10. ActivateTrigger::~ActivateTrigger()
  11. {
  12. }
  13. //Инициализировать объект
  14. bool ActivateTrigger::Create(MOPReader & reader)
  15. {
  16. Activate(reader.Bool());
  17. activateTrigger.Init(reader);
  18. deactivateTrigger.Init(reader);
  19. return true;
  20. }
  21. //Активировать/деактивировать объект
  22. void ActivateTrigger::Activate(bool isActive)
  23. {
  24. MissionObject::Activate(isActive);
  25. if(isActive)
  26. {
  27. Registry(ACTIVATE_EVENT_GROUP, &ActivateTrigger::ActivateEvent, 0);
  28. Registry(DEACTIVATE_EVENT_GROUP, &ActivateTrigger::DeactivateEvent, 0);
  29. }else{
  30. Unregistry(ACTIVATE_EVENT_GROUP);
  31. Unregistry(DEACTIVATE_EVENT_GROUP);
  32. }
  33. }
  34. //Исполнить событие
  35. void _cdecl ActivateTrigger::Action(float dltTime, long level)
  36. {
  37. DelUpdate(&ActivateTrigger::Action);
  38. if(!IsActive()) return;
  39. activateTrigger.Activate(Mission(), false);
  40. }
  41. //Выполнить событие активации
  42. void _cdecl ActivateTrigger::ActivateEvent(const char * group, MissionObject * sender)
  43. {
  44. SetUpdate(&ActivateTrigger::Action, ML_ACTIVATE_TRIGGER);
  45. }
  46. //Выполнить событие деактивации
  47. void _cdecl ActivateTrigger::DeactivateEvent(const char * group, MissionObject * sender)
  48. {
  49. deactivateTrigger.Activate(Mission(), false);
  50. }
  51. //Пересоздать объект
  52. void ActivateTrigger::Restart()
  53. {
  54. DelUpdate();
  55. Unregistry();
  56. ReCreate();
  57. };
  58. //Инициализировать объект
  59. bool ActivateTrigger::EditMode_Create(MOPReader & reader)
  60. {
  61. return true;
  62. }
  63. MOP_BEGINLISTCG(ActivateTrigger, "Activate trigger", '1.00', 0, "Mission activate/deactivate trigger", "Managment")
  64. MOP_BOOL("Active", true)
  65. MOP_MISSIONTRIGGERC("Activate", "Activate mission")
  66. MOP_MISSIONTRIGGERC("Deactivate", "Deactivate mission")
  67. MOP_ENDLIST(ActivateTrigger)