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


C++ CEntity::setReload方法代码示例

本文整理汇总了C++中CEntity::setReload方法的典型用法代码示例。如果您正苦于以下问题:C++ CEntity::setReload方法的具体用法?C++ CEntity::setReload怎么用?C++ CEntity::setReload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CEntity的用法示例。


在下文中一共展示了CEntity::setReload方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onStartElement

void CEntityParser::onStartElement(const std::string &elem, MKeyValue &atts) {
	if (!hasToParse(elem)) return;
	if (curr_prefab_compiler) {
		CPrefabCompiler::TCall c;
		c.is_start = true;
		c.elem = elem;
		c.atts = atts;
		curr_prefab_compiler->calls.push_back(c);
	}
	else if (curr_slept_compiler && elem != "tags") {
		CPrefabCompiler::TCall c;
		c.is_start = true;
		c.elem = elem;
		c.atts = atts;
		curr_slept_compiler->calls.push_back(c);
	}

	if (elem == "entities") {
		return;
	}

	CHandle new_h;
	bool    reusing_component = false;

	// Check if we find a new entity with the prefab attr
	if (elem == "entity") {
		curr_entity_permanent = atts.getBool("permanent", false);
		curr_entity_reload = atts.getBool("reload", false);
		curr_entity_temp = atts.getBool("temp", false);
		curr_entity_keyboard = atts.getBool("only_keyboard", false);
		curr_entity_pad = atts.getBool("only_pad", false);
		//entity_load_accum = 0.f;
		if (!hasToCreate()) {
			curr_entity = CHandle();
			return;
		}
		else {
			curr_entity_id = atts.getInt("id", -1);
			curr_entity_slept = atts.getBool("slept", false);
			if (curr_entity_slept) curr_slept_compiler = new CPrefabCompiler;
			auto prefab = atts["prefab"];
			if (!prefab.empty()) new_h = createPrefab(prefab);
		}
	}
	if (!hasToCreate()) return;

	// Inside an entity...?
	if (curr_entity.isValid()) {
		auto hm = CHandleManager::getByName(elem.c_str());
		// Check if the current entity already has this type
		// of component...
		CEntity* e = curr_entity;
		IdEntities::saveIdEntity(CHandle(e), curr_entity_id);
		e->setPermanent(curr_entity_permanent);
		e->setReload(curr_entity_reload);
		e->setTemp(curr_entity_temp);
		new_h = e->getByCompIndex(hm->getType());
		reusing_component = new_h.isValid();
	}

	// If not prefab has been generated... create one of the
	// type of the tag
	if (!new_h.isValid()) {
		if (MUST_ADD_COMPONENT) {
			auto hm = CHandleManager::getByName(elem.c_str());
			new_h = hm->createHandle();
		}
	}

	if (elem == "entity") {
		curr_entity = new_h;
	}
	// Estoy parseando un component
	else {
		assert(curr_entity.isValid());
		CEntity* e = curr_entity;
		new_h.load(atts);

		if (!curr_slept_compiler && elem == "rigidbody" && atts["type_collision"] == "static") {
			collisionables.push_back(curr_entity);
		}
		if (!reusing_component && MUST_ADD_COMPONENT) {
			e->add(new_h);
		}
	}
}
开发者ID:DopaminaInTheVein,项目名称:ItLightens,代码行数:86,代码来源:entity_parser.cpp


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