本文整理汇总了C++中GlobalEvent::getEventType方法的典型用法代码示例。如果您正苦于以下问题:C++ GlobalEvent::getEventType方法的具体用法?C++ GlobalEvent::getEventType怎么用?C++ GlobalEvent::getEventType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalEvent
的用法示例。
在下文中一共展示了GlobalEvent::getEventType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerEvent
bool GlobalEvents::registerEvent(Event* event, const pugi::xml_node&)
{
GlobalEvent* globalEvent = static_cast<GlobalEvent*>(event); //event is guaranteed to be a GlobalEvent
if (globalEvent->getEventType() == GLOBALEVENT_TIMER) {
auto result = timerMap.emplace(globalEvent->getName(), globalEvent);
if (result.second) {
if (timerEventId == 0) {
timerEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::timer, this)));
}
return true;
}
} else if (globalEvent->getEventType() != GLOBALEVENT_NONE) {
auto result = serverMap.emplace(globalEvent->getName(), globalEvent);
if (result.second) {
return true;
}
} else { // think event
auto result = thinkMap.emplace(globalEvent->getName(), globalEvent);
if (result.second) {
if (thinkEventId == 0) {
thinkEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::think, this)));
}
return true;
}
}
std::cout << "[Warning - GlobalEvents::configureEvent] Duplicate registered globalevent with name: " << globalEvent->getName() << std::endl;
return false;
}
示例2: registerEvent
bool GlobalEvents::registerEvent(Event* event, const pugi::xml_node&)
{
GlobalEvent* globalEvent = reinterpret_cast<GlobalEvent*>(event);
if (globalEvent->getEventType() == GLOBALEVENT_TIMER) {
GlobalEventMap::iterator it = timerMap.find(globalEvent->getName());
if (it == timerMap.end()) {
timerMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
if (timerEventId == 0) {
timerEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::timer, this)));
}
return true;
}
} else if (globalEvent->getEventType() != GLOBALEVENT_NONE) {
GlobalEventMap::iterator it = serverMap.find(globalEvent->getName());
if (it == serverMap.end()) {
serverMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
return true;
}
} else { // think event
auto it = thinkMap.find(globalEvent->getName());
if (it == thinkMap.end()) {
thinkMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
if (thinkEventId == 0) {
thinkEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::think, this)));
}
return true;
}
}
std::cout << "[Warning - GlobalEvents::configureEvent] Duplicate registered globalevent with name: " << globalEvent->getName() << std::endl;
return false;
}
示例3: execute
void GlobalEvents::execute(GlobalEvent_t type) const
{
for (const auto& it : serverMap) {
GlobalEvent* globalEvent = it.second;
if (globalEvent->getEventType() == type) {
globalEvent->executeEvent();
}
}
}
示例4: execute
void GlobalEvents::execute(GlobalEvent_t type)
{
for (GlobalEventMap::iterator it = serverMap.begin(); it != serverMap.end(); ++it) {
GlobalEvent* globalEvent = it->second;
if (globalEvent->getEventType() == type) {
globalEvent->executeEvent();
}
}
}