コード例 #1
0
void CPlayerBase::energyDecreasal(float howmuch) {
	PROFILE_FUNCTION("player base: energy dec function");
	CEntity * raijin = tags_manager.getFirstHavingTag(getID("raijin"));

	TMsgSetDamage msg;
	msg.dmg = howmuch;
	raijin->sendMsg(msg);
}
コード例 #2
0
//animaciones parciales
void TCompSkelController::setAnim(std::vector<std::string> anim, bool loop, std::vector<std::string> nextLoop)
{
	if (!owner.isValid()) return;
	CEntity* eOwner = owner;
	TMsgSetAnim msgAnim;
	msgAnim.name = anim;
	msgAnim.loop = loop;
	msgAnim.nextLoop = nextLoop;
	eOwner->sendMsg(msgAnim);
}
コード例 #3
0
CHandle spawnPrefab(const std::string& prefab) {
	CHandle h = createPrefab(prefab);

	//Le avisamos que se ha creado
	CEntity* e = h;
	TMsgEntityCreated msg;
	e->sendMsg(msg);

	//Devolvemos handle de la entidad creada
	return h;
}
コード例 #4
0
void CEntityParser::onEndElement(const std::string &elem) {
	//if (loading_control) GameController->AddLoadingState(0.f); // for update
	if (!hasToParse(elem)) return;

	if (curr_prefab_compiler) {
		CPrefabCompiler::TCall c;
		c.is_start = false;
		c.elem = elem;
		curr_prefab_compiler->calls.push_back(c);
	}
	if (MUST_COMPILE_SNOOZER) {
		CPrefabCompiler::TCall c;
		c.is_start = false;
		c.elem = elem;
		curr_slept_compiler->calls.push_back(c);
	}

	//dbg("Bye from %s\n", elem.c_str());
	if (elem == "entity") {
		if (!curr_entity.isValid()) return;
		handles.push_back(curr_entity);

		if (curr_slept_compiler) {
			auto hmSnoozer = CHandleManager::getByName("snoozer");
			CHandle snoozer = hmSnoozer->createHandle();
			CEntity * e = curr_entity;
			e->add(snoozer);
			TMsgPreload msgPreload;
			msgPreload.comps = curr_slept_compiler;
			e->sendMsg(msgPreload);
		}
		// Keep track of the first entity found in the file
		if (!root_entity.isValid())
			root_entity = curr_entity;
		curr_entity = CHandle();
		curr_slept_compiler = nullptr;

		if (loading_control)
			GameController->AddLoadingState(entity_load_value);
		//GameController->AddLoadingState(entity_load_value - entity_load_accum);
	}
	//else {
	//	float to_add = 0.1 * entity_load_value;
	//	if (to_add + entity_load_accum > entity_load_value)
	//		to_add = entity_load_value - entity_load_accum;
	//	entity_load_accum += to_add;
	//	GameController->AddLoadingState(to_add);
	//}

	if (elem == "entities" || elem == "prefab") {
		for (auto h : handles) {
			CEntity*e = h;
			dbg("Entity created!! [%s]\n", e->getName());
			e->sendMsg(TMsgEntityCreated());
		}

		// Send the group has been created msg
		TMsgEntityGroupCreated msg = { &handles };

		for (auto h : handles)
			((CEntity*)h)->sendMsg(msg);
	}
}