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);
		}
	}
}
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);
	}
}
Пример #3
0
bool CEntitiesModule::start() {
	SBB::init();
	Damage::init();
	IdEntities::init();

	getHandleManager<CEntity>()->init(MAX_ENTITIES);

	getHandleManager<TVictoryPoint>()->init(20);
	getHandleManager<TTriggerLua>()->init(100);
	getHandleManager<TCompHierarchy>()->init(16);
	getHandleManager<TCompAbsAABB>()->init(MAX_ENTITIES);
	getHandleManager<TCompLocalAABB>()->init(MAX_ENTITIES);
	getHandleManager<TCompCulling>()->init(40);
	getHandleManager<TCompLightDir>()->init(8);
	getHandleManager<TCompLightDirShadows>()->init(MAX_ENTITIES);
	getHandleManager<TCompLightDirShadowsDynamic>()->init(20);
	getHandleManager<player_controller>()->init(8);
	getHandleManager<player_controller_mole>()->init(16);
	getHandleManager<player_controller_cientifico>()->init(8);
	getHandleManager<TCompRenderStaticMesh>()->init(MAX_ENTITIES);
	getHandleManager<TCompSkeleton>()->init(MAX_ENTITIES);
	getHandleManager<TCompSkeletonIK>()->init(MAX_ENTITIES);
	getHandleManager<TCompSkeletonLookAt>()->init(MAX_ENTITIES);
	getHandleManager<SkelControllerPlayer>()->init(MAX_ENTITIES);
	getHandleManager<SkelControllerGuard>()->init(MAX_ENTITIES);
	getHandleManager<SkelControllerScientist>()->init(MAX_ENTITIES);
	getHandleManager<SkelControllerMole>()->init(MAX_ENTITIES);
	getHandleManager<TCompName>()->init(MAX_ENTITIES);
	getHandleManager<TCompRoom>()->init(MAX_ENTITIES);
	getHandleManager<TCompRoomSwitch>()->init(4);
	getHandleManager<TCompRoomLimit>()->init(4);
	getHandleManager<TCompTransform>()->init(MAX_ENTITIES);
	getHandleManager<TCompTransformAnimator>()->init(MAX_ENTITIES);
	getHandleManager<TCompSnoozer>()->init(MAX_ENTITIES);
	getHandleManager<TCompRenderStaticMesh>()->init(MAX_ENTITIES);
	getHandleManager<TCompCamera>()->init(32);
	getHandleManager<TCompCameraMain>()->init(4);
	getHandleManager<TCompController3rdPerson>()->init(4);
	getHandleManager<TCompLife>()->init(MAX_ENTITIES);
	getHandleManager<TCompWire>()->init(10);
	getHandleManager<TCompGenerator>()->init(10);
	getHandleManager<TCompPolarized>()->init(MAX_ENTITIES);
	getHandleManager<TCompBoneTracker>()->init(MAX_ENTITIES);
	getHandleManager<TCompTags>()->init(MAX_ENTITIES);
	getHandleManager<TCompBox>()->init(MAX_ENTITIES);
	getHandleManager<TCompPila>()->init(MAX_ENTITIES);
	getHandleManager<TCompPilaContainer>()->init(MAX_ENTITIES);
	getHandleManager<TCompWorkstation>()->init(MAX_ENTITIES);
	getHandleManager<TCompGuidedCamera>()->init(16);
	//helpers
	getHandleManager<TCompFadingMessage>()->init(32);
	getHandleManager<TCompText>()->init(32);
	getHandleManager<TCompFadingGlobe>()->init(32);
	getHandleManager<TCompLoadingScreen>()->init(32);
	getHandleManager<LogicHelperArrow>()->init(4);
	getHandleManager<Tasklist>()->init(4);
	getHandleManager<TasklistSwitch>()->init(32);
	getHandleManager<TCompLookTarget>()->init(8);
	//lights
	getHandleManager<TCompLightDir>()->init(MAX_ENTITIES);
	getHandleManager<TCompLightFadable>()->init(4);
	getHandleManager<TCompLightPoint>()->init(MAX_ENTITIES);

	getHandleManager<bt_guard>()->init(MAX_ENTITIES);
	getHandleManager<bt_mole>()->init(MAX_ENTITIES);
	getHandleManager<bt_scientist>()->init(MAX_ENTITIES);
	getHandleManager<ai_cam>()->init(MAX_ENTITIES);
	getHandleManager<workbench_controller>()->init(MAX_ENTITIES);
	getHandleManager<workbench>()->init(MAX_ENTITIES);
	getHandleManager<magnet_door>()->init(MAX_ENTITIES);
	getHandleManager<elevator>()->init(4);
	getHandleManager<TCompRenderGlow>()->init(4);
	getHandleManager<TCompSenseVision>()->init(4);

	getHandleManager<TCompPlatform>()->init(MAX_ENTITIES);
	getHandleManager<TCompDrone>()->init(MAX_ENTITIES);

	getHandleManager<CStaticBomb>()->init(MAX_ENTITIES);
	getHandleManager<CMagneticBomb>()->init(MAX_ENTITIES);
	getHandleManager<CThrowBomb>()->init(MAX_ENTITIES);

	getHandleManager<TCompBoxSpawner>()->init(MAX_ENTITIES);
	getHandleManager<TCompBoxDestructor>()->init(MAX_ENTITIES);
	getHandleManager<TCompBoxPlacer>()->init(MAX_ENTITIES);

	//getHandleManager<TCompTriggerStandar>()->init(MAX_ENTITIES);

	//colliders
	getHandleManager<TCompPhysics>()->init(MAX_ENTITIES);
	getHandleManager<TCompCharacterController>()->init(MAX_ENTITIES);

	//Trackers
	getHandleManager<TCompTracker>()->init(100);

	//particles
	getHandleManager<CParticleSystem>()->init(MAX_ENTITIES);

	//video
	getHandleManager<TCompVideo>()->init(4);

	//sound
	getHandleManager<TCompSound>()->init(MAX_ENTITIES);

	//fx
	getHandleManager<TCompFadeScreen>()->init(4);

	//Gui
	getHandleManager<TCompGui>()->init(MAX_ENTITIES);
	getHandleManager<TCompGuiCursor>()->init(64);
	getHandleManager<TCompGuiButton>()->init(64);
	getHandleManager<TCompGuiSelector>()->init(64);
	getHandleManager<TCompGuiDrag>()->init(64);

	//SUBSCRIBE(TCompLife, TMsgDamage, onDamage);
	SUBSCRIBE(TCompSnoozer, TMsgPreload, onPreload);
	SUBSCRIBE(TCompSnoozer, TMsgAwake, onAwake);
	SUBSCRIBE(TCompTransform, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompPhysics, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompPlatform, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompDrone, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompDrone, TMsgActivate, onRecharge);
	SUBSCRIBE(TCompPila, TMsgIsCharged, isCharged);
	SUBSCRIBE(TCompPila, TMsgActivate, onRecharge);
	SUBSCRIBE(TCompPilaContainer, TMsgSetCharged, onRecharge);
	SUBSCRIBE(TCompDrone, TMsgRepair, onRepair);
	SUBSCRIBE(TCompTags, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompPila, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompPilaContainer, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompCharacterController, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompController3rdPerson, TMsgSetTarget, onSetTarget);
	SUBSCRIBE(TCompController3rdPerson, TMsgEntityCreated, onCreate);
	SUBSCRIBE(player_controller, TMsgSetCamera, onSetCamera);
	SUBSCRIBE(player_controller, TMsgDamageSpecific, onSetDamage);
	SUBSCRIBE(player_controller_mole, TMsgSetCamera, onSetCamera);
	SUBSCRIBE(bt_scientist, TMsgWBEmpty, onEmptyWB);						//Workbench empty
	SUBSCRIBE(TCompRenderStaticMesh, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompRenderStaticMesh, TMsgGetLocalAABB, onGetLocalAABB);
	SUBSCRIBE(TCompCharacterController, TMsgGetLocalAABB, onGetLocalAABB);
	SUBSCRIBE(TCompHierarchy, TMsgHierarchySolver, onGetParentById);
	SUBSCRIBE(TCompHierarchy, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompBoneTracker, TMsgEntityGroupCreated, onGroupCreated);
	SUBSCRIBE(TCompAbsAABB, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompLocalAABB, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompTags, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompTags, TMsgSetTag, onSetTag);

	//Trackers
	SUBSCRIBE(TCompTracker, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompTracker, TMsgFollow, setFollower);
	SUBSCRIBE(TCompCameraMain, TMsgGuidedCamera, onGuidedCamera);
	SUBSCRIBE(TCompGuidedCamera, TMsgGuidedCamera, onGuidedCamera);
	SUBSCRIBE(TCompBoneTracker, TMsgAttach, onAttach);

	//For camera unique
	SUBSCRIBE(TCompCameraMain, TMsgEntityCreated, onCreate);

	//Skeleton Controllers
	SUBSCRIBE(SkelControllerPlayer, TMsgEntityCreated, onCreate);
	SUBSCRIBE(SkelControllerGuard, TMsgEntityCreated, onCreate);
	SUBSCRIBE(SkelControllerMole, TMsgEntityCreated, onCreate);
	SUBSCRIBE(SkelControllerScientist, TMsgEntityCreated, onCreate);

	//Skeleton IK
	SUBSCRIBE(TCompSkeletonIK, TMsgSetIKSolver, onSetIKSolver);
	SUBSCRIBE(TCompSkeletonLookAt, TMsgEntityCreated, onCreate);

	//Grab Objects Hit
	SUBSCRIBE(player_controller_mole, TMsgGrabHit, onGrabHit);

	//On contact
	SUBSCRIBE(TCompPila, TMsgContact, onContact);

	SUBSCRIBE(bt_scientist, TMsgWBTakenByPlayer, onTakenWB);
	SUBSCRIBE(magnet_door, TMsgSetLocked, onSetLocked);
	SUBSCRIBE(magnet_door, TMsgSetPolarity, onSetPolarity);
	SUBSCRIBE(magnet_door, TMsgEntityCreated, onCreate);
	SUBSCRIBE(elevator, TMsgActivate, onElevatorAction);
	SUBSCRIBE(elevator, TMsgEntityCreated, onCreate);
	SUBSCRIBE(workbench, TMsgEntityCreated, onCreate);

	//box
	SUBSCRIBE(TCompBox, TMsgLeaveBox, onUnLeaveBox);
	//SUBSCRIBE(TCompBoxPlacer, TMsgEntityCreated, onCreate);

	//bombs
	SUBSCRIBE(CThrowBomb, TMsgActivate, onNextState);
	SUBSCRIBE(CThrowBomb, TMsgThrow, onThrow);
	SUBSCRIBE(CThrowBomb, TMsgEntityCreated, onCreate);
	SUBSCRIBE(bt_scientist, TMsgStaticBomb, onStaticBomb);
	SUBSCRIBE(bt_guard, TMsgStaticBomb, onStaticBomb);
	SUBSCRIBE(bt_mole, TMsgStaticBomb, onStaticBomb);
	SUBSCRIBE(bt_guard, TMsgNoise, noise);
	SUBSCRIBE(bt_guard, TMsgOverCharge, onOverCharged);
	SUBSCRIBE(bt_guard, TMsgBoxHit, onBoxHit);

	//WIRES
	SUBSCRIBE(TCompWire, TMsgEntityCreated, onCreate);
	SUBSCRIBE(player_controller, TMsgWirePass, onWirePass);

	// RECHARGING DRONES
	SUBSCRIBE(player_controller, TMsgCanRechargeDrone, onCanRechargeDrone);
	SUBSCRIBE(player_controller, TMsgCanNotRechargeDrone, onCanNotRechargeDrone);
	SUBSCRIBE(TCompGenerator, TMsgTriggerIn, onTriggerEnterCall);
	SUBSCRIBE(TCompGenerator, TMsgTriggerOut, onTriggerExitCall);

	//generator
	SUBSCRIBE(TCompGenerator, TMsgEntityCreated, onCreate);
	SUBSCRIBE(player_controller, TMsgCanRec, onCanRec);
	SUBSCRIBE(TCompGenerator, TMsgTriggerIn, onTriggerEnterCall);
	SUBSCRIBE(TCompGenerator, TMsgTriggerOut, onTriggerExitCall);
	SUBSCRIBE(TCompGenerator, TMsgTriggerUnpossess, onTriggerUnposses);

	// task switcher
	SUBSCRIBE(TasklistSwitch, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TasklistSwitch, TMsgTriggerIn, onTriggerEnterCall);
	SUBSCRIBE(TasklistSwitch, TMsgTriggerOut, onTriggerExitCall);
	SUBSCRIBE(TasklistSwitch, TMsgTriggerUnpossess, onTriggerUnposses);
	// room switcher
	SUBSCRIBE(TCompRoomSwitch, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompRoomSwitch, TMsgTriggerIn, onTriggerEnterCall);
	SUBSCRIBE(TCompRoomSwitch, TMsgTriggerOut, onTriggerExitCall);
	SUBSCRIBE(TCompRoomSwitch, TMsgTriggerUnpossess, onTriggerUnposses);
	// room limiter
	SUBSCRIBE(TCompRoomLimit, TMsgEntityCreated, onCreate);
	SUBSCRIBE(TCompRoomLimit, TMsgTriggerIn, onTriggerEnterCall);
	SUBSCRIBE(TCompRoomLimit, TMsgTriggerOut, onTriggerExitCall);
	SUBSCRIBE(TCompRoomLimit, TMsgTriggerUnpossess, onTriggerUnposses);

	SUBSCRIBE(TCompBoxDestructor, TMsgTriggerIn, onTriggerEnterCall);

	//triggers
	//SUBSCRIBE(TCompTriggerStandar, TMsgTriggerIn, onTriggerEnterCall);
	//SUBSCRIBE(TCompTriggerStandar, TMsgTriggerOut, onTriggerExitCall);

	//victory point
	SUBSCRIBE(TVictoryPoint, TMsgTriggerIn, onTriggerEnterCall);

	//trigger_lua
	SUBSCRIBE(TTriggerLua, TMsgTriggerIn, onTriggerEnterCall);
	SUBSCRIBE(TTriggerLua, TMsgTriggerOut, onTriggerExitCall);
	SUBSCRIBE(TTriggerLua, TMsgTriggerUnpossess, onTriggerUnposses);
	SUBSCRIBE(TTriggerLua, TMsgSetActivable, onSetActionable);
	SUBSCRIBE(TCompPila, TMsgSetActivable, onSetActionable);

	//Animations
	SUBSCRIBE(TCompSkeleton, TMsgSetAnim, onSetAnim);

	//polarized
	SUBSCRIBE(TCompPolarized, TMsgEntityCreated, onCreate);
	SUBSCRIBE(player_controller, TMsgPolarize, onPolarize);
	SUBSCRIBE(player_controller, TMsgGetPolarity, onGetPolarity);
	SUBSCRIBE(TCompPolarized, TMsgPlayerPolarize, onPolarize);

	//Posesiones Mensajes
	//..Cientifico
	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;
}