當前位置: 首頁>>代碼示例>>C++>>正文


C++ ObjectManager類代碼示例

本文整理匯總了C++中ObjectManager的典型用法代碼示例。如果您正苦於以下問題:C++ ObjectManager類的具體用法?C++ ObjectManager怎麽用?C++ ObjectManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ObjectManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: QDBusAbstractAdaptor

// 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);
    }
}
開發者ID:KDE,項目名稱:bluez-qt,代碼行數:26,代碼來源:deviceinterface.cpp

示例2: assert

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;
}
開發者ID:epyon,項目名稱:tpserver-cpp,代碼行數:35,代碼來源:colonize.cpp

示例3: ObjectManagerLoadObjectTable

		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;
		}
開發者ID:BattleNWar,項目名稱:YDWE,代碼行數:29,代碼來源:ObjectManager.cpp

示例4: handleSceneObjectCreateMessage

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());
	}
}
開發者ID:ModTheGalaxy,項目名稱:mtgserver,代碼行數:30,代碼來源:ZonePacketHandler.cpp

示例5: doOrder

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;
}
開發者ID:epyon,項目名稱:tpserver-cpp,代碼行數:35,代碼來源:unloadarm.cpp

示例6: ConCmd_objectInfo

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();
	}
}
開發者ID:amichaelt,項目名稱:pentagram,代碼行數:26,代碼來源:ObjectManager.cpp

示例7: hide

void Entity::hide(){
    if(objectmanagerId != 0){ 
        ObjectManager *objectManager = Global::getInstance()->objectManager;
        objectManager->removeObject(objectmanagerId);
        objectmanagerId = 0;
    }
}
開發者ID:hflw,項目名稱:Blackpyre-Engine,代碼行數:7,代碼來源:Entity.cpp

示例8: sendHome

//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());
        }
    }
}
開發者ID:epyon,項目名稱:tpserver-cpp,代碼行數:35,代碼來源:taeturn.cpp

示例9: selectObjects

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;
	}
}
開發者ID:RHUL-CS-Projects,項目名稱:towersAndMuskets,代碼行數:30,代碼來源:SelectionSystem.cpp

示例10:

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;
}
開發者ID:epyon,項目名稱:tpserver-cpp,代碼行數:34,代碼來源:loadarm.cpp

示例11: disconnectMediaPlayer

void DeviceInterface::disconnectMediaPlayer()
{
    ObjectManager *manager = ObjectManager::self();
    manager->removeObject(m_mediaPlayer);
    m_connectedUuids.removeOne(MediaPlayerUuid);

    m_mediaPlayer = 0;
}
開發者ID:KDE,項目名稱:bluez-qt,代碼行數:8,代碼來源:deviceinterface.cpp

示例12: getGameObjectType

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;
}
開發者ID:SWGChoice,項目名稱:Core3,代碼行數:56,代碼來源:TangibleObjectImplementation.cpp

示例13: JSObjectWeakCallbackStatic

void ObjectManager::JSObjectWeakCallbackStatic(const WeakCallbackData<Object, ObjectWeakCallbackState>& data)
{
	ObjectWeakCallbackState *callbackState = data.GetParameter();

	ObjectManager *thisPtr = callbackState->thisPtr;

	auto isolate = data.GetIsolate();

	thisPtr->JSObjectWeakCallback(isolate, callbackState);
}
開發者ID:atifzaidi,項目名稱:android-runtime,代碼行數:10,代碼來源:ObjectManager.cpp

示例14: test

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());

}
開發者ID:jianglutian,項目名稱:GameServer,代碼行數:33,代碼來源:object.cpp

示例15:

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;
}
開發者ID:AfrazHussain,項目名稱:tpserver-cpp,代碼行數:11,代碼來源:planet.cpp


注:本文中的ObjectManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。