draw game improvement

This commit is contained in:
ProgramSnail 2021-04-11 20:14:23 +03:00
parent bee718ad9b
commit 220dd71d8f
15 changed files with 274 additions and 75 deletions

View file

@ -1,7 +1,7 @@
#include <vector>
#include <functional>
#include <string>
#include <unordered_map>
#include <map>
#pragma once
@ -25,13 +25,30 @@ namespace events {
bool operator!=(const EventId& eId) const {
return !operator==(eId);
}
bool operator<(const EventId& eId) const {
return nameHash < eId.nameHash ||
(nameHash == eId.nameHash && name < eId.name);
}
bool operator>(const EventId& eId) const {
return eId < *this;
}
bool operator<=(const EventId& eId) const {
return !operator>(eId);
}
bool operator>=(const EventId& eId) const {
return !operator<(eId);
}
};
class EventData { // may be changed
private:
using T = int;
std::unordered_map<std::string, T> data;
std::map<std::string, T> data;
public:
EventData() {}
@ -99,7 +116,7 @@ namespace events {
class EventCenter {
private:
std::unordered_map<EventId, std::vector<EventHandler>> handlers;
std::map<EventId, std::vector<EventHandler>> handlers;
public:
void addEventHandler(const EventHandler& handler) {
handlers[handler.getEventId()].push_back(handler);