当前位置: 首页>>代码示例>>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;未经允许,请勿转载。