ObjectVisitStarted.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * ObjectVisitStarted.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "ObjectVisitStarted.h"
  12. #include <vcmi/events/EventBus.h>
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. namespace events
  15. {
  16. SubscriptionRegistry<ObjectVisitStarted> * ObjectVisitStarted::getRegistry()
  17. {
  18. static std::unique_ptr<Sub> Instance = std::make_unique<Sub>();
  19. return Instance.get();
  20. }
  21. void ObjectVisitStarted::defaultExecute(const EventBus * bus, const ExecHandler & execHandler,
  22. const PlayerColor & player, const ObjectInstanceID & heroId, const ObjectInstanceID & objId)
  23. {
  24. CObjectVisitStarted event(player, heroId, objId);
  25. bus->executeEvent(event, execHandler);
  26. }
  27. CObjectVisitStarted::CObjectVisitStarted(const PlayerColor & player_, const ObjectInstanceID & heroId_, const ObjectInstanceID & objId_)
  28. : player(player_),
  29. heroId(heroId_),
  30. objId(objId_),
  31. enabled(true)
  32. {
  33. }
  34. PlayerColor CObjectVisitStarted::getPlayer() const
  35. {
  36. return player;
  37. }
  38. ObjectInstanceID CObjectVisitStarted::getHero() const
  39. {
  40. return heroId;
  41. }
  42. ObjectInstanceID CObjectVisitStarted::getObject() const
  43. {
  44. return objId;
  45. }
  46. bool CObjectVisitStarted::isEnabled() const
  47. {
  48. return enabled;
  49. }
  50. void CObjectVisitStarted::setEnabled(bool enable)
  51. {
  52. enabled = enable;
  53. }
  54. }
  55. VCMI_LIB_NAMESPACE_END