Guest User

Untitled

a guest
Apr 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include "Event.hpp"
  2.  
  3. void Event::doEvent() {
  4. for (int i = 0; i < handlers.size(); i++) {
  5. handlers.at(i)->handle(this);
  6. }
  7.  
  8. if (!cancelled) {
  9. execute();
  10. }
  11. }
  12.  
  13. bool Event::setCancelled(bool cancelled) {
  14. bool cancellable = isCancellable();
  15. if (cancellable) {
  16. this->cancelled = cancelled;
  17. }
  18.  
  19. return cancellable;
  20. }
  21.  
  22. std::vector<std::shared_ptr<EventHandler>> Event::handlers;
  23.  
  24. void Event::addHandler(std::shared_ptr<EventHandler> handler) {
  25. if (handlers.size() == 0) {
  26. handlers.reserve(20);
  27. }
  28.  
  29. handlers.emplace_back(handler);
  30. }
Add Comment
Please, Sign In to add comment