예제 #1
0
  void CWiFiSensor::SetEntity(CEntity& c_entity) {
    /* Treat the entity as composable */
    CComposableEntity* pcComposableEntity = dynamic_cast<CComposableEntity*>(&c_entity);
    if(pcComposableEntity != NULL) {
      /* The entity is composable, does it have the required component? */
      if(pcComposableEntity->HasComponent("wifi_equipped_entity")) {
	/* Yes, it does */
	m_pcWiFiEquippedEntity = &(pcComposableEntity->GetComponent<CWiFiEquippedEntity>("wifi_equipped_entity"));
	m_pcEntity = &c_entity;
      }
      else {
	/* No, error */
	THROW_ARGOSEXCEPTION("Cannot associate a wifi sensor to an entity of type \"" << c_entity.GetTypeDescription() << "\"");
      }
    }
  }
예제 #2
0
 void CEPuckRangeAndBearingSensor::SetEntity(CEntity& c_entity) {
    /* Treat the entity as composable */
    CComposableEntity* pcComposableEntity = dynamic_cast<CComposableEntity*>(&c_entity);
    if(pcComposableEntity != NULL) {
       /* The entity is composable, does it have the required components? */
       if(pcComposableEntity->HasComponent("rab_equipped_entity<2>") &&
          pcComposableEntity->HasComponent("embodied_entity") &&
          pcComposableEntity->HasComponent("controllable_entity")) {
          /* Yes, it does */
          m_pcRABEquippedEntity = &(pcComposableEntity->GetComponent< CRABEquippedEntity<2> >("rab_equipped_entity<2>"));
          m_pcEmbodiedEntity = &(pcComposableEntity->GetComponent<CEmbodiedEntity>("embodied_entity"));
          m_pcControllableEntity = &(pcComposableEntity->GetComponent<CControllableEntity>("controllable_entity"));
          m_pcEntity = &c_entity;
       }
       else {
          /* No, error */
          THROW_ARGOSEXCEPTION("Cannot associate a range and bearing sensor to an entity of type \"" << c_entity.GetTypeDescription() << "\"");
       }
    }
 }