예제 #1
0
// DeviceInterface
DeviceInterface::DeviceInterface(const QDBusObjectPath &path, const QVariantMap &properties, QObject *parent)
    : QDBusAbstractAdaptor(parent)
    , m_mediaPlayer(0)
{
    setPath(path);
    setObjectParent(parent);
    setProperties(properties);
    setName(QStringLiteral("org.bluez.Device1"));

    // Alias needs special handling
    setAlias(properties.value(QStringLiteral("Alias")).toString());

    // Create Input1
    if (properties.contains(QStringLiteral("Input"))) {
        const QVariantMap &inputProps = qdbus_cast<QVariantMap>(properties.value(QStringLiteral("Input")));
        InputInterface *input = new InputInterface(path, inputProps, parent);

        ObjectManager *manager = ObjectManager::self();
        manager->addObject(input);

        QVariantMap props = properties;
        props.remove(QStringLiteral("Input"));
        setProperties(props);
    }
}
예제 #2
0
map<uint32_t, pair<string, uint32_t> > Colonize::generateListOptions() {
   map<uint32_t, pair<string,uint32_t> > options;
   Game* game = Game::getGame();
   ObjectManager* om = game->getObjectManager();

   IGObject::Ptr selectedObj = game->getObjectManager()->getObject(
      game->getOrderManager()->getOrderQueue(orderqueueid)->getObjectId());
   Planet* planet = dynamic_cast<Planet*>(selectedObj->getObjectBehaviour());
   assert(planet);
   om->doneWithObject(selectedObj->getID());

   set<uint32_t> allObjs = om->getAllIds();

   uint32_t availibleUnits = planet->getResource("Army").first + planet->getResource("Army").second - 1;

   /* This for loop will iterate over every adjacent planet. 
   This is where the majority of the work occurs, and we populate our list.
   You see here we select an item of the map, in my case (*i)->getID(), and
   for that item we create a pair.
      If its a little hard to read, here is what I am doing:
            options[#] = pair<string,uint32_t>( "title", max# );

   For my pair I set the title as the adjacent planet to move to, and set the
   max to availible units. */
   for(set<uint32_t>::iterator i = allObjs.begin(); i != allObjs.end(); i++) {
      IGObject::Ptr currObj = om->getObject((*i));
      Planet* owned = dynamic_cast<Planet*>(currObj->getObjectBehaviour());
      if ( owned != NULL && owned->getOwner() == 0) {   
         options[owned->getID()] = pair<string,uint32_t>(
            owned->getName(), availibleUnits );
      }
   }   

   return options;
}
예제 #3
0
		bool ObjectManagerLoadObjectTable(ObjectManager& mgr, ROBJECT_TYPE::ENUM type, SlkTable& table)
		{
			try
			{
				ObjTable<Option> objTable;

				if (mgr.load(static_cast<OBJ_TYPE::ENUM>(type), objTable))
				{
					SlkTable baseTable;
					if (!mgr.load_base(type, baseTable))
						return false;

					MetaTable const& metaTable = mgr.load_singleton<META_SLK_TYPE::ENUM, MetaTable>(static_cast<META_SLK_TYPE::ENUM>(type));

					TableAppend(table, baseTable);
					ObjTableToSlkTable(table, objTable, baseTable, metaTable, mgr.get_converter());
				}
				else
				{
					if (!mgr.load_base(type, table))
						return false;
				}
			}
			catch (base::exception const&)
			{
				return false;
			}
			return true;
		}
예제 #4
0
void ZonePacketHandler::handleSceneObjectCreateMessage(Message* pack) {
	BaseClient* client = (BaseClient*) pack->getClient();
	uint64 objectID = pack->parseLong();
	pack->shiftOffset(16);

	float x = pack->parseFloat();
	float z = pack->parseFloat();
	float y = pack->parseFloat();

	uint32 crc = pack->parseInt();

	ObjectManager* objectManager = zone->getObjectManager();
	if (objectManager == NULL) {
		error("object manager was NULL");
		return;
	}

	SceneObject* object = objectManager->createObject(crc, objectID);

	if (object == NULL) {
		StringBuffer infoMsg;
		infoMsg << "unknown crc 0x" << hex << crc << " received in SceneObjectCreateMessage";
		client->debug(infoMsg.toString());
		return;
	}

	if (zone->isSelfPlayer(object)) {
		object->setClient(zone->getZoneClient());
	}
}
예제 #5
0
bool UnloadArmament::doOrder(IGObject::Ptr ob){
  Fleet* fleet = dynamic_cast<Fleet*>(ob->getObjectBehaviour());
  ObjectManager* obman = Game::getGame()->getObjectManager();
  ObjectTypeManager* otman = Game::getGame()->getObjectTypeManager();
  ResourceManager::Ptr resman = Game::getGame()->getResourceManager();
  std::set<uint32_t>objs = obman->getObjectsByPos(fleet->getPosition(), 10000);
  IGObject::Ptr planetObj;
  Planet* planet;

  for (std::set<uint32_t>::const_iterator itcurr = objs.begin(); itcurr != objs.end(); ++itcurr) {
    if (obman->getObject(*itcurr)->getType() == otman->getObjectTypeByName("Planet")) {

      planetObj = obman->getObject(*itcurr);
      planet = dynamic_cast<Planet*>(planetObj->getObjectBehaviour());
      Logger::getLogger()->debug("UnloadArmaments::doOrder Found Planet %s for Unload Armaments Order", planetObj->getName().c_str());
      const uint32_t factoryType = resman->getResourceDescription("Factories")->getResourceType();

    IdMap weapontype = weaponlist->getList();
    for(IdMap::iterator weaponit = weapontype.begin(); weaponit != weapontype.end(); ++weaponit) {
      if (planet->removeResource(factoryType, 1)) {
        if (fleet->removeResource(weaponit->first, weaponit->second)) {
          Logger::getLogger()->debug("UnloadArmaments::doOrder success, adding to resource %d: #:%d", weaponit->first, weaponit->second);
          planet->addResource(weaponit->first, weaponit->second);
          planetObj->touchModTime();
          return true;
          }
        } else {
          turns = 1;
          return true;
        }
      }
    }
  }
  return false;
}
예제 #6
0
void HandleKeypress ( unsigned char key, int x, int y )
{
    if ( key == 27 )            //esc
        exit( 0 );
    if ( key == 'a' || key == 'A' )           //left
    {
        player.Move( TURN_LEFT );
    }
    else if ( key == 'd' || key == 'D' )      //right
    {
        player.Move( TURN_RIGHT );
    }
    if ( key == 'w' || key == 'D' )           //up
    {
        player.Move( FORWARD );
    }
    else if ( key == 's' || key == 'S' )      //down
    {
        player.Move( BACKWARD );
    }

    if ( key == 'r' )           //display room (or don't)
    {
        if ( objManager.DisplayRoom() == true )
            objManager.DisplayRoom( false );
        else
            objManager.DisplayRoom( true );
    }
}
예제 #7
0
void ObjectManager::ConCmd_objectInfo(const Console::ArgvType& argv)
{
	if (argv.size() != 2) {
		pout << "usage: objectInfo <objectnum>" << std::endl;
		return;
	}

	ObjectManager* objman = ObjectManager::get_instance();

	ObjId objid = static_cast<ObjId>(strtol(argv[1].c_str(), 0, 0));

	Object* obj = objman->getObject(objid);
	if (obj == 0) {
		bool reserved = false;
		if (objid >= 256) // CONSTANT!
			reserved = objman->objIDs->isIDUsed(objid);
		else
			reserved = objman->actorIDs->isIDUsed(objid);
		if (reserved)
			pout << "Reserved objid: " << objid << std::endl;
		else
			pout << "No such object: " << objid << std::endl;
	} else {
		obj->dumpInfo();
	}
}
예제 #8
0
void Entity::hide(){
    if(objectmanagerId != 0){ 
        ObjectManager *objectManager = Global::getInstance()->objectManager;
        objectManager->removeObject(objectmanagerId);
        objectmanagerId = 0;
    }
}
예제 #9
0
//Sends a fleet back to it's home planet
void TaeTurn::sendHome(uint32_t fleet) {
    Game* game = Game::getGame();
    ObjectManager* obm = game->getObjectManager();
    ObjectTypeManager* obtm = game->getObjectTypeManager();
    PlayerManager::Ptr pm = game->getPlayerManager();

    IGObject::Ptr fleetobj = obm->getObject(fleet);
    //Check to make sure it is really a fleet
    if(fleetobj->getType() != obtm->getObjectTypeByName("Fleet")) {
        return;
    }

    //Get all the required objects
    Fleet* f = (Fleet*) fleetobj->getObjectBehaviour();
    Player::Ptr p = pm->getPlayer(f->getOwner());
    IGObject::Ptr sys = obm->getObject(fleetobj->getParent());
    StarSystem* sysData = (StarSystem*) sys->getObjectBehaviour();

    //Remove fleet from system
    sysData->setRegion(0);
    fleetobj->removeFromParent();

    //Find it's home planet
    std::set<uint32_t> objects = obm->getAllIds();
    std::set<uint32_t>::iterator itcurr;
    for(itcurr = objects.begin(); itcurr != objects.end(); ++itcurr) {
        IGObject::Ptr ob = obm->getObject(*itcurr);
        if(ob->getName().compare(string(p->getName() + "'s Home Planet")) == 0) {
            Planet* p = (Planet*) ob->getObjectBehaviour();
            f->setPosition(p->getPosition());
            fleetobj->addToParent(ob->getID());
        }
    }
}
void SelectionSystem::selectObjects() {
	ObjectManager* mgr = Game::game.getObjMgr();
	
	// Get all selectable objects
	std::list<int> objects = mgr->getObjectsWithComponent("SelectableComponent");
	
	for (int i : objects) {
		
		SelectableComponent* selectComp = mgr->getObjectComponent<SelectableComponent>(i, "SelectableComponent");
		
		// Check if the object has a transform
		TransformComponent* transComp = mgr->getObjectComponent<TransformComponent>(i, "TransformComponent");
		
		if (transComp == nullptr)
			continue;
		
		vector2di screenPos = worldToScreen(transComp->worldPosition);
		
		int topLeftX = (clickPos.X < mousePos.X) ? clickPos.X : mousePos.X;
		int topLeftY = (clickPos.Y < mousePos.Y) ? clickPos.Y : mousePos.Y;
		int bottomRightX = (clickPos.X > mousePos.X) ? clickPos.X : mousePos.X;
		int bottomRightY = (clickPos.Y > mousePos.Y) ? clickPos.Y : mousePos.Y;
		
		if (screenPos.X >= topLeftX && screenPos.X <= bottomRightX &&
			screenPos.Y >= topLeftY && screenPos.Y <= bottomRightY)
			selectComp->selected = true;
		else
			selectComp->selected = false;
	}
}
예제 #11
0
std::map<uint32_t, std::pair<std::string, uint32_t> > LoadArmament::generateListOptions(){
  Logger::getLogger()->debug("Entering LoadArmament::generateListOptions");
  std::map<uint32_t, std::pair<std::string, uint32_t> > options;

  Game* game = Game::getGame();
  IGObject::Ptr selectedObj = game->getObjectManager()->getObject(
            game->getOrderManager()->getOrderQueue(orderqueueid)->getObjectId());

  Fleet* fleet = dynamic_cast<Fleet*>(selectedObj->getObjectBehaviour());

  ObjectManager* obman = Game::getGame()->getObjectManager();
  ObjectTypeManager* otman = Game::getGame()->getObjectTypeManager();
  ResourceManager::Ptr resman = Game::getGame()->getResourceManager();
  std::set<uint32_t>objs = obman->getObjectsByPos(fleet->getPosition(), 10000);

  for (std::set<uint32_t>::iterator itcurr = objs.begin(); itcurr != objs.end(); ++itcurr) {
    if (obman->getObject(*itcurr)->getType() == otman->getObjectTypeByName("Planet")) {
      IGObject::Ptr planetObj = obman->getObject(*itcurr);
      Planet* planet = dynamic_cast<Planet*>(planetObj->getObjectBehaviour());
      Logger::getLogger()->debug("Found Planet %s for Load Armaments Order", planetObj->getName().c_str());
      std::map<uint32_t, std::pair<uint32_t, uint32_t> > reslist = planet->getResources();
      for (std::map<uint32_t, std::pair<uint32_t, uint32_t> >::iterator it = reslist.begin(); it != reslist.end(); ++it) {
        if (resman->getResourceDescription(it->first)->getUnitSingular() == "weapon") {
          options[it->first] = std::pair<std::string, uint32_t>(resman->getResourceDescription(it->first)->getNamePlural(),
            planet->getResourceSurfaceValue(it->first));
        }
      }

    }
  }

  Logger::getLogger()->debug("Exiting LoadArmament::generateListOptions");
  return options;
}
예제 #12
0
void DeviceInterface::disconnectMediaPlayer()
{
    ObjectManager *manager = ObjectManager::self();
    manager->removeObject(m_mediaPlayer);
    m_connectedUuids.removeOne(MediaPlayerUuid);

    m_mediaPlayer = 0;
}
Reference<FactoryCrate*> TangibleObjectImplementation::createFactoryCrate(bool insertSelf) {
	String file;
	uint32 type = getGameObjectType();

	if(type & SceneObjectType::ARMOR)
		file = "object/factory/factory_crate_armor.iff";
	else if(type == SceneObjectType::CHEMICAL || type == SceneObjectType::PHARMACEUTICAL || type == SceneObjectType::PETMEDECINE)
		file = "object/factory/factory_crate_chemicals.iff";
	else if(type & SceneObjectType::CLOTHING)
		file = "object/factory/factory_crate_clothing.iff";
	else if(type == SceneObjectType::ELECTRONICS)
		file = "object/factory/factory_crate_electronics.iff";
	else if(type == SceneObjectType::FOOD || type == SceneObjectType::DRINK)
		file = "object/factory/factory_crate_food.iff";
	else if(type == SceneObjectType::FURNITURE)
		file = "object/factory/factory_crate_furniture.iff";
	else if(type & SceneObjectType::INSTALLATION)
		file = "object/factory/factory_crate_installation.iff";
	else if(type & SceneObjectType::WEAPON)
		file = "object/factory/factory_crate_weapon.iff";
	else
		file = "object/factory/factory_crate_generic_items.iff";

	ObjectManager* objectManager = ObjectManager::instance();

	Reference<FactoryCrate*> crate = (getZoneServer()->createObject(file.hashCode(), 2)).castTo<FactoryCrate*>();

	if (crate == NULL)
		return NULL;

	SharedTangibleObjectTemplate* tanoData = dynamic_cast<SharedTangibleObjectTemplate*>(templateObject.get());

	if (tanoData == NULL)
		return NULL;

	crate->setMaxCapacity(tanoData->getFactoryCrateSize());

	if (insertSelf) {
		crate->transferObject(_this.get(), -1, false);
	} else {

		ManagedReference<TangibleObject*> protoclone = cast<TangibleObject*>( objectManager->cloneObject(_this.get()));

		if (protoclone == NULL)
			return NULL;

		protoclone->setParent(NULL);
		crate->transferObject(protoclone, -1, false);
	}

	crate->setCustomObjectName(getCustomObjectName(), false);

	crate->setUseCount(1);

	return crate;
}
예제 #14
0
void ObjectManager::JSObjectWeakCallbackStatic(const WeakCallbackData<Object, ObjectWeakCallbackState>& data)
{
	ObjectWeakCallbackState *callbackState = data.GetParameter();

	ObjectManager *thisPtr = callbackState->thisPtr;

	auto isolate = data.GetIsolate();

	thisPtr->JSObjectWeakCallback(isolate, callbackState);
}
예제 #15
0
void test(void)
{
    ObjectManager<> m;
    Object<>* obj = Create<Item>();
    m.add(obj->id(), obj);
    printf("%u\n", obj->id());
    obj = Create<Item>();
    m.add(obj->id(), obj);
    printf("%u\n", obj->id());
    obj = Create<Item>();
    m.add(obj->id(), obj);
    printf("%u\n", obj->id());

    obj = Create<Object<> >();
    m.add(obj->id(), obj);
    printf("%u\n", obj->id());
    obj = Create<Object<> >();
    m.add(obj->id(), obj);
    printf("%u\n", obj->id());
    obj = Create<Object<> >();
    m.add(obj->id(), obj);
    printf("%u\n", obj->id());

    m.del(2);


    ItemNT* itemn = CreateNT<ItemNT>("hello");
    printf("%u, %s, %u\n", itemn->id(), itemn->name().c_str(), itemn->tempid());
    while (!m.add(itemn->id(), itemn))
        itemn->id()++;
    printf("%u, %s, %u\n", itemn->id(), itemn->name().c_str(), itemn->tempid());

}
예제 #16
0
set<Planet*> Planet::getAdjacent() {
   set<Planet*> result;
   Risk* risk = dynamic_cast<Risk*>(Game::getGame()->getRuleset());
   ObjectManager* om = Game::getGame()->getObjectManager();
   
   set<uint32_t> adjacent = risk->getGraph()->getAdjacent(this->obj->getID());
   for(set<uint32_t>::iterator i = adjacent.begin(); i != adjacent.end(); ++i) {
      result.insert(dynamic_cast<Planet*>(om->getObject(*i)->getObjectBehaviour()));
   }
   return result;
}
예제 #17
0
jweak ObjectManager::NewWeakGlobalRefCallback(const int& javaObjectID, void *state)
{
	ObjectManager *objManager = reinterpret_cast<ObjectManager*>(state);

	JniLocalRef obj(objManager->GetJavaObjectByIDImpl(javaObjectID));

	JEnv env;
	jweak weakRef = env.NewWeakGlobalRef(obj);

	return weakRef;
}
예제 #18
0
 X_VOID		MainGame::EndBattle(bool win)
 {
	 
	 //------------打开战斗前的界面
	 m_nGameRunState = RUNING_IN_GAME;
	 SceneManger::GetSingleton()->EnterScene(SceneManger::EM_SS_MAIN);

	if(DataPool::GetSingleton()->BattlyType == EM_COPY_SCENE)
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_LEVELLIST_SHOW);
	else if(DataPool::GetSingleton()->BattlyType == EM_SPORT)
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_RANKLIST_SHOW);
	else if(DataPool::GetSingleton()->BattlyType == EM_WOODPVP)
	{
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_BASE_ACTIVITY_SHOW);
	}
	else if(DataPool::GetSingleton()->BattlyType == EM_BATTLETYPE_QUJING)
	{
		vector<string> str;str.clear();
		str.push_back(UtilTools::IntToString(EM_HUSONG_WOOD));//
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_CHEESE_SHOW,str);
		SendLogicPacket::OpenQuJingUi();
		EventSystem::GetSingleton()->PushEvent(GAME_EVNET_LVL_ESCORTWOOD_SHOW);
	}
	else if(DataPool::GetSingleton()->BattlyType == EM_BATTLETYPE_BLOODBATTLE)
	{
		BloodData* pBloodData = DataPool::GetSingleton()->GetBloodData();
		if (win)
		{
				pBloodData->NextStep();
		}else
		{
				pBloodData->EnterBloodUi();
		}
	}
	else 
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_CHEESE_SHOW);


	ObjectManager* pManager = DataPool::GetSingleton()->getObjectManager();
	PlayerData* pData = pManager->getSelf()->playerData();
	if (pData && pData->IsLevelUp())
	{
		pData->resetLevelUp();
		EventSystem::GetSingleton()->PushEvent(GAME_EVNET_LVL_UPGRADE_SHOW);
	}
	

	 BattleData * pBattle = DataPool::GetSingleton()->GetBattleData();
	 pBattle->DestroyBattleData();
	 


 }
예제 #19
0
Entity::Entity(float x, float y, float sx, float sy, float a, std::string sp)
    : GameObject(x,y,sx,sy,a){
    objectmanagerId = 0;
    texture = 0;
    sprite = sp;
    //ResourceManager *resourceManager = Global::getInstance()->resourceManager;
    //texture = resourceManager->loadTexture(sprite.c_str());
    //Now we need to add ourselves to the object manager

    ObjectManager *objectManager = Global::getInstance()->objectManager;
    objectmanagerId = objectManager->addObject(this);
}
예제 #20
0
//System cannot be destroyed, occupied, or colonized in order to be able to be colonized.
//It also must be inhabitable for the colony type.
bool StarSystem::canBeColonized(bool mining) {
    ObjectManager* obm = Game::getGame()->getObjectManager();
    ObjectTypeManager* obtm = Game::getGame()->getObjectTypeManager();

    if(isDestroyed()) {
        Logger::getLogger()->debug("StarSystem->canBeColonized: System is destroyed");
        return false;
    }

    //Grab the children and see if the system is occupied
    set<uint32_t> children = obj->getContainedObjects();
    uint32_t pid;
    bool isOccupied = false;
    for(set<uint32_t>::iterator i = children.begin(); i != children.end(); i++) {
        if(obm->getObject(*i)->getType() == obtm->getObjectTypeByName("Planet")) {
            pid = *i;
        } else if (obm->getObject(*i)->getType() == obtm->getObjectTypeByName("Fleet")) {
            isOccupied = true;
        }
    }
    if(isOccupied) {
        Logger::getLogger()->debug("StarSystem->canBeColonized: System is occupied");
        return false;
    }

    //Check to see if the system has already been colonized
    Planet* planet = (Planet*)(obm->getObject(pid)->getObjectBehaviour());
    if(planet->getResource(4) > 0) {
        Logger::getLogger()->debug("StarSystem->canBeColonized: System has been colonized by merchants.");
        return false;
    } else if(planet->getResource(5) > 0) {
        Logger::getLogger()->debug("StarSystem->canBeColonized: System has been colonized by scientists.");
        return false;
    } else if(planet->getResource(6) > 0) {
        Logger::getLogger()->debug("StarSystem->canBeColonized: System has been colonized by settlers.");
        return false;
    } else if(planet->getResource(7) > 0) {
        Logger::getLogger()->debug("StarSystem->canBeColonized: System has been colonized by mining robots.");
        return false;
    }

    //Check to make sure the system is inhabitable by the fleet
    if(mining && planet->getResource(1) < 1) {
        Logger::getLogger()->debug("StarSystem->canBeColonized: System is inhabitable and cannot be colonized by mining robots");
        return false;
    } else if(!mining && planet->getResource(1) > 0) {
        Logger::getLogger()->debug("StarSystem->canBeColonized: System is Uninhabitable and can ONLY be colonized by mining robots");
        return false;
    }

    return true;
}
예제 #21
0
bool Bombard::doOrder(IGObject *fleet) {

   Game *game = Game::getGame();
   ObjectManager *om = game->getObjectManager();
   ObjectTypeManager *odm = game->getObjectTypeManager();
   Random *rand = game->getRandom();

   IGObject *planetObj = om->getObject(planet->getObjectId());

   if(planetObj->getType() != odm->getObjectTypeByName("Planet"))
   {
      Logger::getLogger()->debug("Player tried to bombard something illogical");
      return true;
   }

   Fleet *fleetData = dynamic_cast<Fleet*>(fleet->getObjectBehaviour());
   Planet *planetData = dynamic_cast<Planet*>(planetObj->getObjectBehaviour());
   char planetShipTech = PlayerInfo::getPlayerInfo(planetData->getOwner()).getShipTechLevel();
   double attack = fleetData->getAttack();
   
   planetData->removeResource("Industry", 
                  static_cast<uint32_t>(attack * INDUSTRY_DMG * (1+rand->getInRange(-2,2)/100.) ));

   planetData->removeResource("Social Environment", 
                  static_cast<uint32_t>(attack * SOCIAL_DMG * (1+rand->getInRange(-2,2)/100.) ));

   planetData->removeResource("Planetary Environment", 
                  static_cast<uint32_t>(attack * PLANETARY_DMG * (1+rand->getInRange(-2,2)/100.) ));

   planetData->removeResource(string("PDB") + planetShipTech,
                  static_cast<uint32_t>(attack * PDB_DMG / 10. * (1+rand->getInRange(-2,2)/100.) ));

   PlayerInfo::getPlayerInfo(fleetData->getOwner()).addVictoryPoints(VICTORY_POINTS);


   // PDBs counter-attack at: PDB level * 6 * numPDBs
   fleetData->takeDamage( (planetShipTech - '0') *
                         6 * planetData->getResource(string("PDB") + planetShipTech).first);

   Message *msg = new Message();
   msg->setSubject("Bombard complete");
   string body = "Fleet \"" + fleet->getName() + "\" bombarded " + planetObj->getName();
   msg->setBody(PlayerInfo::appAllVictoryPoints(body));
   msg->addReference(rst_Action_Order, rsorav_Completion);
   msg->addReference(rst_Object, fleet->getID());
   msg->addReference(rst_Object, planetObj->getID());

   game->getPlayerManager()->getPlayer(fleetData->getOwner())->postToBoard(msg);
   game->getPlayerManager()->getPlayer(planetData->getOwner())->postToBoard(msg);

   return true;
}
예제 #22
0
void Update(float elapsedTime)
{
	objectManager.update(elapsedTime);

	if(clearScene)
	{
		clearScene = false;
		objectManager.clearListOfObject();
		ground = new Generic_Object();
		generateGround();
		nbObjects = 0;
	}
	//printf("%.0f fps - %i objects in the scene\n", 1/elapsedTime, nbObjects);
}
예제 #23
0
void setVisibleObjects(Player::Ptr player) {
   ObjectManager *om = Game::getGame()->getObjectManager();
   
   IGObject::Ptr universe = om->getObject(0);
   PlayerView::Ptr pv = player->getPlayerView();
   set<uint32_t> ownedObjects = pv->getOwnedObjects();

   // add universe and star systems
   ObjectView::Ptr obv = pv->getObjectView(universe->getID());
   if(!obv){
      pv->addVisibleObject( universe->getID(), true );
   }
   
   uint32_t fleettype = Game::getGame()->getObjectTypeManager()->getObjectTypeByName("Fleet");
   set<uint32_t> containedObjects = universe->getContainedObjects();
   for(set<uint32_t>::const_iterator i = containedObjects.begin(); i != containedObjects.end(); ++i){
     IGObject::Ptr object = om->getObject(*i);
     obv = pv->getObjectView(*i);
     if(object->getType() != fleettype){
      if(!obv){
          pv->addVisibleObject(*i, true );
      }
     }else{
       if(obv && !obv->isGone()){
         obv->setGone(true);
         pv->updateObjectView(*i);
       }
     }
     om->doneWithObject(*i);
   }

   for(set<uint32_t>::const_iterator i = ownedObjects.begin(); i != ownedObjects.end(); ++i)
   {
      IGObject::Ptr obj = om->getObject(*i);
      if(obj->getType() != fleettype || obj->getParent() != 0){
        exploreStarSys(obj);
      }
      om->doneWithObject(*i);
   }
   
   set<uint32_t> visobjects = pv->getVisibleObjects();
   for(set<uint32_t>::const_iterator i = visobjects.begin(); i != visobjects.end(); ++i)
   {
      IGObject::Ptr obj = om->getObject(*i);
      obv = pv->getObjectView(*i);
      if(!obj){
        if(!obv->isGone()){
          obv->setGone(true);
          pv->updateObjectView(*i);
        }
      }else if((!obv->isGone()) && obv->isCompletelyVisible() && obj->getModTime() > obv->getModTime()){
        obv->setModTime(obj->getModTime());
        pv->updateObjectView(*i);
      }
      if(obj != NULL){
        om->doneWithObject(*i);
      }
   }
   
}
예제 #24
0
void taeRuleset::createGame() {
    Game* game = Game::getGame();
    ObjectManager* obm = game->getObjectManager();
    ObjectTypeManager* obtm = game->getObjectTypeManager();

    //Create ship design category
    Category* cat = new Category();
    cat->setName("Ships");
    cat->setDescription("Ship components");
    game->getDesignStore()->addCategory(cat);
    
    //Create properties
    createProperties();

    //Create components
    createComponents();

    //Create resources
    setupResources();

    uint32_t obT_Universe = obtm->getObjectTypeByName("Universe");
    uint32_t obT_Galaxy = obtm->getObjectTypeByName("Galaxy");

    //Create the universe
    IGObject* universe = obm->createNewObject();
    obtm->setupObject(universe, obT_Universe);
    Universe* theUniverse = (Universe*)(universe->getObjectBehaviour());
    theUniverse->setSize(1000000000000ll);
    universe->setName("The Universe");
    theUniverse->setPosition(Vector3d(0ll,0ll,0ll));
    obm->addObject(universe);

    //Create the galaxy
    IGObject* gal = obm->createNewObject();
    obtm->setupObject(gal, obT_Galaxy);
    EmptyObject* galob = (EmptyObject*)(gal->getObjectBehaviour());
    galob->setSize(100000000000ll);
    gal->setName("The Fertile Galaxy");
    galob->setPosition(Vector3d(0ll, -6000ll, 0ll));
    gal->addToParent(universe->getID());
    obm->addObject(gal);

    string path = string(Settings::getSettings()->get("board_path"));
    Logger::getLogger()->debug(path.c_str());
    
    createBoard(path, gal->getID());
    
    Logger::getLogger()->info("TaE created");
}
예제 #25
0
void Colonize::inputFrame(InputFrame::Ptr f, uint32_t playerid) {
    FleetOrder::inputFrame(f, playerid);

    Game *game = Game::getGame();
    ObjectManager *obm = game->getObjectManager();
    ObjectTypeManager *obtm = game->getObjectTypeManager();

    IGObject::Ptr starSysObj = obm->getObject(starSys->getObjectId());
    StarSystem* starSysData = (StarSystem*) starSysObj->getObjectBehaviour();

    // Check to see if it is a legal system to colonize
    if(starSysObj->getType() == obtm->getObjectTypeByName("Star System") && !starSysData->canBeColonized(isMining)) {
        starSys->setObjectId(0);
        Logger::getLogger()->debug("Player tried to colonize a system which cannot be colonized.");
    }        
}
예제 #26
0
Result Bombard::inputFrame(Frame * f, unsigned int playerid) {
   Result r = Order::inputFrame(f, playerid);
   if(!r) return r;

   ObjectManager *om = Game::getGame()->getObjectManager();

   IGObject *planetObj = om->getObject(planet->getObjectId());
   Planet *planetData = dynamic_cast<Planet*>(planetObj->getObjectBehaviour());

   if(!planetData)
      planet->setObjectId(0);
   else if(planetData->getOwner() == playerid)
      planet->setObjectId(0);

   return Success();
}
예제 #27
0
void DeviceInterface::connectMediaPlayer()
{
    const QVariantMap &properties = qdbus_cast<QVariantMap>(Object::property(QStringLiteral("MediaPlayer")));
    const QDBusObjectPath &path = properties.value(QStringLiteral("Path")).value<QDBusObjectPath>();
    QVariantMap props = properties;
    props.remove(QStringLiteral("Path"));

    MediaPlayerObject *mediaPlayerObj = new MediaPlayerObject(path);
    m_mediaPlayer = new MediaPlayerInterface(path, props, mediaPlayerObj);

    ObjectManager *manager = ObjectManager::self();
    manager->addObject(m_mediaPlayer);
    manager->addAutoDeleteObject(mediaPlayerObj);

    m_connectedUuids.append(MediaPlayerUuid);
}
예제 #28
0
BOOL StaticObject::RecycleContents()
{
    World* world = World::GetPtr();
    ObjectManager* omanager = world->GetObjectManager();
    std::vector<Entity*>::iterator it, itEnd;

    if (descendants.size())
        {
            itEnd = descendants.end();
            for (it = descendants.begin(); it != itEnd; ++it)
                {
                    omanager->RecycleObject((*it));
                }
        }

    return true;
}
예제 #29
0
void exploreStarSys(IGObject* obj) {
   // set the planets in this star sys to visible for my owner
   OwnedObject *objData = dynamic_cast<OwnedObject*>(obj->getObjectBehaviour());

   Game *game = Game::getGame();
   ObjectManager *om = game->getObjectManager();

   IGObject *starSys = om->getObject(obj->getParent());
   PlayerView *pview = game->getPlayerManager()->getPlayer(objData->getOwner())->getPlayerView();

   ObjectView* obv = pview->getObjectView(obj->getID());
   if(obv != NULL){
      if(!obv->isCompletelyVisible()){
        obv->setCompletelyVisible(true);
        pview->updateObjectView(obj->getID());
      }
      if(obv->isGone()){
        obv->setGone(false);
        pview->updateObjectView(obj->getID());
      }
   }else{
      obv = new ObjectView();
      obv->setObjectId(obj->getID());
      obv->setCompletelyVisible(true);
      pview->addVisibleObject(obv);
   }

   if(starSys->getID() == 0) return; // don't explore the universe

   set<uint32_t> planets = starSys->getContainedObjects();
   for(set<uint32_t>::const_iterator i = planets.begin(); i != planets.end(); ++i){
      obv = pview->getObjectView(*i);
      if(obv != NULL){
          if(!obv->isCompletelyVisible()){
            obv->setCompletelyVisible(true);
            pview->updateObjectView(*i);
          }
      }else{
          obv = new ObjectView();
          obv->setObjectId(*i);
          obv->setCompletelyVisible(true);
          pview->addVisibleObject(obv);
      }
   }
}
예제 #30
0
void GlUtil::drawScene(){
	_angle += 0.05f;
	if(_angle > 360.0f)
		_angle -= 360.0f;

	//Clear information from last draw
	glClearColor(.3, .3, .3, 0);
	glClear(GL_COLOR_BUFFER_BIT);
	
	glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
	glLoadIdentity(); //Reset the drawing perspective
	
	
    //glTranslatef(0.375, 0.375, 0);
    ObjectManager *objMan = ObjectManager::getInstance();

    objMan->renderObjects();
}