ObjectVisitStarted.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. namespace events
  14. {
  15. SubscriptionRegistry<ObjectVisitStarted> * ObjectVisitStarted::getRegistry()
  16. {
  17. static std::unique_ptr<Sub> Instance = make_unique<Sub>();
  18. return Instance.get();
  19. }
  20. void ObjectVisitStarted::defaultExecute(const EventBus * bus, const ExecHandler & execHandler,
  21. const PlayerColor & player, const ObjectInstanceID & heroId, const ObjectInstanceID & objId)
  22. {
  23. CObjectVisitStarted event(player, heroId, objId);
  24. bus->executeEvent(event, execHandler);
  25. }
  26. CObjectVisitStarted::CObjectVisitStarted(const PlayerColor & player_, const ObjectInstanceID & heroId_, const ObjectInstanceID & objId_)
  27. : player(player_),
  28. heroId(heroId_),
  29. objId(objId_),
  30. enabled(true)
  31. {
  32. }
  33. PlayerColor CObjectVisitStarted::getPlayer() const
  34. {
  35. return player;
  36. }
  37. ObjectInstanceID CObjectVisitStarted::getHero() const
  38. {
  39. return heroId;
  40. }
  41. ObjectInstanceID CObjectVisitStarted::getObject() const
  42. {
  43. return objId;
  44. }
  45. bool CObjectVisitStarted::isEnabled() const
  46. {
  47. return enabled;
  48. }
  49. void CObjectVisitStarted::setEnabled(bool enable)
  50. {
  51. enabled = enable;
  52. }
  53. }