当前位置: 首页>>代码示例>>C++>>正文


C++ GlobalEvent::getEventType方法代码示例

本文整理汇总了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;
}
开发者ID:Caduceus,项目名称:DecapitatedSoul,代码行数:29,代码来源:globalevent.cpp

示例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;
}
开发者ID:godely,项目名称:forgottenserver,代码行数:33,代码来源:globalevent.cpp

示例3: execute

void GlobalEvents::execute(GlobalEvent_t type) const
{
	for (const auto& it : serverMap) {
		GlobalEvent* globalEvent = it.second;
		if (globalEvent->getEventType() == type) {
			globalEvent->executeEvent();
		}
	}
}
开发者ID:kinglekke,项目名称:forgottenserver,代码行数:9,代码来源:globalevent.cpp

示例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();
		}
	}
}
开发者ID:afsdadsfdsa,项目名称:forgottenserver,代码行数:9,代码来源:globalevent.cpp


注:本文中的GlobalEvent::getEventType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。