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


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

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


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

示例2: start


//.........这里部分代码省略.........
	SUBSCRIBE(bt_scientist, TMsgAISetPossessed, onSetPossessed);
	SUBSCRIBE(bt_scientist, TMsgAISetStunned, onSetStunned);
	SUBSCRIBE(player_controller_cientifico, TMsgControllerSetEnable, onSetEnable);
	SUBSCRIBE(player_controller_cientifico, TMsgGetWhoAmI, onGetWhoAmI);
	SUBSCRIBE(player_controller_cientifico, TMsgCanRechargeDrone, onCanRepairDrone);
	//..Mole
	SUBSCRIBE(bt_mole, TMsgAISetPossessed, onSetPossessed);
	SUBSCRIBE(bt_mole, TMsgAISetStunned, onSetStunned);
	SUBSCRIBE(player_controller_mole, TMsgControllerSetEnable, onSetEnable);
	SUBSCRIBE(player_controller_mole, TMsgGetWhoAmI, onGetWhoAmI);

	//..PJ Principal
	SUBSCRIBE(player_controller, TMsgPossessionLeave, onLeaveFromPossession);
	SUBSCRIBE(player_controller, TMsgGetWhoAmI, onGetWhoAmI);

	//Guard
	SUBSCRIBE(bt_guard, TMsgGetWhoAmI, onGetWhoAmI);

	//Dead
	//anything for now
	/*SUBSCRIBE(player_controller, TMsgDie, onDie);
	SUBSCRIBE(player_controller_cientifico, TMsgDie, onDie);
	SUBSCRIBE(player_controller_mole, TMsgDie, onDie);*/

	//Damage
	SUBSCRIBE(TCompLife, TMsgEntityCreated, onCreate);		//init damage scales
	SUBSCRIBE(TCompLife, TMsgDamageSave, onSetSaveDamage);
	SUBSCRIBE(TCompLife, TMsgDamage, onDamage);
	SUBSCRIBE(TCompLife, TMsgSetDamage, onReciveDamage);
	SUBSCRIBE(TCompLife, TMsgStopDamage, onStopDamage);
	SUBSCRIBE(player_controller_cientifico, TMsgUnpossesDamage, onForceUnPosses);
	SUBSCRIBE(player_controller_mole, TMsgUnpossesDamage, onForceUnPosses);
	SUBSCRIBE(bt_scientist, TMsgUnpossesDamage, onForceUnPosses);
	SUBSCRIBE(bt_mole, TMsgUnpossesDamage, onForceUnPosses);

	SUBSCRIBE(TCompCameraMain, TMsgGetCullingViewProj, onGetViewProj);
	SUBSCRIBE(TCompLightDirShadows, TMsgGetCullingViewProj, onGetViewProj);
	SUBSCRIBE(TCompLightDirShadowsDynamic, TMsgGetCullingViewProj, onGetViewProj);
	SUBSCRIBE(TCompCamera, TMsgGetCullingViewProj, onGetViewProj);

	//Control
	SUBSCRIBE(player_controller, TMsgSetControllable, onSetControllable);
	SUBSCRIBE(player_controller_cientifico, TMsgSetControllable, onSetControllable);
	SUBSCRIBE(player_controller_mole, TMsgSetControllable, onSetControllable);
	SUBSCRIBE(TCompController3rdPerson, TMsgSetControllable, onSetControllable);
	SUBSCRIBE(player_controller, TMsgSetOnlySense, onSetOnlySense);
	SUBSCRIBE(player_controller_cientifico, TMsgSetOnlySense, onSetOnlySense);
	SUBSCRIBE(player_controller_mole, TMsgSetOnlySense, onSetOnlySense);

	//Go And Look
	SUBSCRIBE(player_controller, TMsgGoAndLook, onGoAndLook);
	SUBSCRIBE(player_controller_cientifico, TMsgGoAndLook, onGoAndLook);
	SUBSCRIBE(player_controller_mole, TMsgGoAndLook, onGoAndLook);
	//SUBSCRIBE(bt_guard, TMsgGoAndLookAs, onGoAndLook);
	//SUBSCRIBE(bt_mole, TMsgGoAndLookAs, onGoAndLook);

	//Fx
	SUBSCRIBE(TCompFadeScreen, TMsgEntityCreated, onCreate);

	//System
	SUBSCRIBE(bt_guard, TMsgDifficultyChanged, onDifficultyChanged);
	SUBSCRIBE(player_controller, TMsgDifficultyChanged, onDifficultyChanged);

	//Gui
	SUBSCRIBE(TCompGui, TMsgEntityCreated, onCreate); //Este onCreate se encarga de llamar al resto de creates de gui!
	//SUBSCRIBE(TCompGuiSelector, TMsgEntityCreated, onCreate);
	//SUBSCRIBE(TCompLoadingScreen, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompGuiCursor, TMsgOverButton, onButton);
	SUBSCRIBE(TCompGuiCursor, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompGuiButton, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompGuiButton, TMsgClicked, onClick);
	SUBSCRIBE(TCompGuiButton, TMsgGuiSetListener, onSetListener);

	SUBSCRIBE(TCompGuiSelector, TMsgGuiNotify, onGuiNotify);
	//SUBSCRIBE(TCompGuiSelector, TMsgLanguageChanged, onLanguageChanged);

	SUBSCRIBE(TCompGuiDrag, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompText, TMsgLanguageChanged, onLanguageChanged);
	SUBSCRIBE(TCompFadingMessage, TMsgLanguageChanged, onLanguageChanged);
	SUBSCRIBE(TCompText, TMsgControlsChanged, onControlsChanged);
	SUBSCRIBE(TCompFadingMessage, TMsgControlsChanged, onControlsChanged);

	auto hm = CHandleManager::getByName("entity");
	CHandle new_hp = hm->createHandle();
	CEntity* entity = new_hp;

	auto hm1 = CHandleManager::getByName("name");
	CHandle new_hn = hm1->createHandle();
	MKeyValue atts1;
	atts1.put("name", "playerTalk");
	new_hn.load(atts1);
	entity->add(new_hn);

	auto hm3 = CHandleManager::getByName("helper_message");
	CHandle new_hl = hm3->createHandle();
	entity->add(new_hl);
	entity->setPermanent(true);

	return true;
}
开发者ID:DopaminaInTheVein,项目名称:ItLightens,代码行数:101,代码来源:entities.cpp


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