当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectID类代码示例

本文整理汇总了C++中ObjectID的典型用法代码示例。如果您正苦于以下问题:C++ ObjectID类的具体用法?C++ ObjectID怎么用?C++ ObjectID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: use

void CmpProjectileWeaponUsable::use()
{
	if(m_timeTillCanFire == 0)
	{
		// Determine the character which is firing the projectile (the owner of the weapon).
		ICmpOwnable_CPtr cmpOwnable = m_objectManager->get_component(m_objectID, cmpOwnable);
		ObjectID firer = cmpOwnable->owner();
		if(!firer.valid()) throw Exception("Can't use a projectile weapon when it's not owned");

		// Check that there's enough ammo.
		ICmpInventory_Ptr cmpFirerInventory = m_objectManager->get_component(firer, cmpFirerInventory);
		if(!cmpFirerInventory) throw Exception("The firer must have an inventory component");
		if(cmpFirerInventory->consumables_count(m_ammoType) > 0)
		{
			// Fire a bullet from each hotspot of the weapon (note that this in principle makes it easy to implement things like double-barrelled shotguns).
			const std::vector<std::string>& spots = hotspots();
			for(size_t i=0, size=spots.size(); i<size; ++i)
			{
				boost::optional<Vector3d> pos = hotspot_position(spots[i]);
				boost::optional<Vector3d> ori = hotspot_orientation(spots[i]);
				if(pos && ori)
				{
					ObjectSpecification specification = m_objectManager->get_archetype(m_ammoType);
					specification.set_component_property("Projectile", "Firer", firer);
					specification.set_component_property("Simulation", "Position", *pos);
					specification.set_component_property("Simulation", "Velocity", m_muzzleSpeed * *ori);
					m_objectManager->queue_for_construction(specification);
				}
			}

			cmpFirerInventory->destroy_consumables(m_ammoType, 1);
			m_timeTillCanFire = m_firingInterval;
		}
	}
}
开发者ID:galek,项目名称:hesperus,代码行数:35,代码来源:CmpProjectileWeaponUsable.cpp

示例2: if

//#################### PUBLIC METHODS ####################
void CmdUseActiveItem::execute(const ObjectManager_Ptr& objectManager, const std::vector<CollisionPolygon_Ptr>& polygons, const OnionTree_CPtr& tree,
							   const NavManager_CPtr& navManager, int milliseconds)
{
	ICmpInventory_Ptr cmpInventory = objectManager->get_component(m_objectID, cmpInventory);	if(!cmpInventory) return;
	ObjectID activeItem = cmpInventory->active_item();											if(!activeItem.valid()) return;
	ICmpUsable_Ptr cmpItemUsable = objectManager->get_component(activeItem, cmpItemUsable);		if(!cmpItemUsable) return;
	cmpItemUsable->use();
}
开发者ID:galek,项目名称:hesperus,代码行数:9,代码来源:CmdUseActiveItem.cpp

示例3: remove

int Database::remove(const DatabaseKey &key)
{
    ObjectID oid = mainIndex->get(key);
    if (! oid.isNull()) {
        mainIndex->deleteKey(key);
        slabs->removeData(oid);
    }
    return 0;
}
开发者ID:vrok,项目名称:gucdb,代码行数:9,代码来源:Database.cpp

示例4: New

Handle<Value>
ObjectID::ToString(const Arguments &args) {
    ObjectID *o = ObjectWrap::Unwrap<ObjectID>(args.This());

    HandleScope scope;
    char hex[25];
    o->str(hex);
    return String::New(hex);
}
开发者ID:w1nk,项目名称:node-mongodb,代码行数:9,代码来源:bson.cpp

示例5: read

Value Database::read(const DatabaseKey &key)
{
    ObjectID oid = mainIndex->get(key);

    if (oid.isNull())
        return nullValue;

    char *result = NULL;
    size_t resultSize = slabs->readData(result, oid);

    return Value(result, resultSize);
}
开发者ID:vrok,项目名称:gucdb,代码行数:12,代码来源:Database.cpp

示例6: assert

void CmpCharacterModelRender::render_first_person() const
{
	ICmpInventory_Ptr cmpInventory = m_objectManager->get_component(m_objectID, cmpInventory);
	assert(cmpInventory);

	ObjectID activeItem = cmpInventory->active_item();
	if(!activeItem.valid()) return;

	ICmpBasicModelRender_Ptr cmpItemRender = m_objectManager->get_component(activeItem, cmpItemRender);
	if(!cmpItemRender) return;

	cmpItemRender->render_first_person();
	render_crosshair();
}
开发者ID:longde123,项目名称:hesperus2,代码行数:14,代码来源:CmpCharacterModelRender.cpp

示例7: saveState

void CostAdaptiveStateManager::saveState(const VTime& currentTime, SimulationObject *object) {
   ObjectID *currentObjectID = object->getObjectID();
   unsigned int simObjectID = currentObjectID->getSimulationObjectID(); 

   // The period is only recalculated after the specified number of events.
   if (forwardExecutionLength[simObjectID] < eventsBetweenRecalculation[simObjectID]) {
      forwardExecutionLength[simObjectID]++;
   }
   else{
      calculatePeriod( object );
   }

   AdaptiveStateManagerBase::saveState(currentTime, object);
}
开发者ID:CindyYang85,项目名称:pdes,代码行数:14,代码来源:CostAdaptiveStateManager.cpp

示例8: encodeObjectID

void
encodeObjectID(bson_buffer *bb, const char *name, const Local<Value> element) {
    // get at the delicious wrapped object centre
    Local<Object> obj = element->ToObject();
    assert(!obj.IsEmpty());
    assert(obj->InternalFieldCount() > 0);
    ObjectID *o = static_cast<ObjectID*>(Handle<External>::Cast(
                obj->GetInternalField(0))->Value());
    bson_oid_t oid;
    char oid_hex[25];
    o->str(oid_hex);
    bson_oid_from_string(&oid, oid_hex);
    bson_append_oid(bb, name, &oid);
}
开发者ID:w1nk,项目名称:node-mongodb,代码行数:14,代码来源:bson.cpp

示例9: onRestoreMessage

void IdeMailBox::onRestoreMessage(IEvent *e)
{
	HtmlEvent *htmlEvent = dynamic_cast<HtmlEvent *>(e);
	if(htmlEvent == nullptr)
		return;

	ObjectID id = htmlEvent->get(0).to_ascii();
	if(id.empty() == false)
	{
		// Elimina il messaggio
		getPortal()->getMessenger()->moveMessageToInbox(getPage()->getDatabase(), getSessionAccount(), id);
		// Mostra la posta in arrivo
		_renderFolder(messageFolderInbox);
	}
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例10: onDeleteMessage

void IdeMailBox::onDeleteMessage(IEvent *e)
{
	HtmlEvent *htmlEvent = dynamic_cast<HtmlEvent *>(e);
	if(htmlEvent == nullptr)
		return;

	ObjectID id = htmlEvent->get(0).to_ascii();
	if(id.empty() == false)
	{
		// Elimina il messaggio
		getPortal()->getMessenger()->moveMessageToTrash(getPage()->getDatabase(), getSessionAccount(), id);
		// Mostra la directory di riferimento
		_renderFolder(m_folder);
	}
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例11: deregisterContainer

 void ComponentManager::deregisterContainer(const ObjectID& oid) {
     unsigned int index = oid.getIndex();
     m_activeContainers.erase(index);
     m_containers[index] = 0;
     std::memset(&m_componentIDs[index * MAX_INTERFACES], 0, sizeof (ComponentID) * MAX_INTERFACES);
     m_containerIndices.free(index);
     //std::cout << "Object " << oid.getIndex() << " deregistered." << std::endl;
 }
开发者ID:chrisschuette,项目名称:HephaestusLibrary,代码行数:8,代码来源:ComponentManager.cpp

示例12: ThrowException

Handle<Value> ObjectID::New(const Arguments &args) {
    HandleScope scope;

    if (args.Length() < 1
           || !args[0]->IsString()
           || (args[0]->IsString()
                && args[0]->ToString()->Length() != 24)) {
        return ThrowException(Exception::Error(
                String::New("Argument must be 24 character hex string")));
    }

    String::Utf8Value hex(args[0]->ToString());

    // XXX where should this be deleted?
    ObjectID *o = new ObjectID((const char *) *hex);
    o->Wrap(args.This());
    return args.This();
}
开发者ID:w1nk,项目名称:node-mongodb,代码行数:18,代码来源:bson.cpp

示例13: construct_model_matrix

void CmpCharacterModelRender::render() const
{
	ICmpOrientation_CPtr cmpOrientation = m_objectManager->get_component(m_objectID, cmpOrientation);
	ICmpPosition_CPtr cmpPosition = m_objectManager->get_component(m_objectID, cmpPosition);

	const Vector3d& p = cmpPosition->position();
	const Vector3d& n = cmpOrientation->nuv_axes()->n();
	const Vector3d& u = cmpOrientation->nuv_axes()->u();
	const Vector3d& v = cmpOrientation->nuv_axes()->v();

	if(m_modelPose != NULL)
	{
		RBTMatrix_CPtr mat = construct_model_matrix(p, n, u, v);
		glPushMatrix();
			glMultMatrixd(&mat->rep()[0]);

			// Render the model.
			model()->render(m_modelPose);

			// Render the active item (if any).
			ICmpInventory_Ptr cmpInventory = m_objectManager->get_component(m_objectID, cmpInventory);	assert(cmpInventory);
			ObjectID activeItem = cmpInventory->active_item();
			if(activeItem.valid())
			{
				ICmpBasicModelRender_Ptr cmpItemRender = m_objectManager->get_component(activeItem, cmpItemRender);
				if(cmpItemRender)
				{
					cmpItemRender->render_child();
				}
			}
		glPopMatrix();
	}

	if(m_highlights)
	{
		// If the object should be highlighted, render the object's bounds.
		render_bounds(p);
	}

	// Render the object's NUV axes.
	render_nuv_axes(p, n, u, v);
}
开发者ID:longde123,项目名称:hesperus2,代码行数:42,代码来源:CmpCharacterModelRender.cpp

示例14: post_message

void ObjectManager::post_message(const ObjectID& target, const Message_CPtr& msg)
{
	std::map<ObjectID,Object>::iterator it = m_objects.find(target);
	if(it == m_objects.end()) throw Exception("Invalid object ID: " + target.to_string());

	Object& obj = it->second;
	for(Object::iterator jt=obj.begin(), jend=obj.end(); jt!=jend; ++jt)
	{
		msg->dispatch(jt->second.get());
	}
}
开发者ID:galek,项目名称:hesperus,代码行数:11,代码来源:ObjectManager.cpp

示例15: calculatePeriod

void ThreadedCostAdaptiveStateManager::saveState(const VTime& currentTime,
		SimulationObject *object, int threadID) {
	ObjectID *currentObjectID = object->getObjectID();
	unsigned int simObjectID = currentObjectID->getSimulationObjectID();

	// The period is only recalculated after the specified number of events.
	if (forwardExecutionLength[simObjectID]
			< eventsBetweenRecalculation[simObjectID]) {
		forwardExecutionLength[simObjectID]++;
	} else {
		calculatePeriod(object);
	}
	if (periodCounter[simObjectID] <= 1) {
		// we need to first allocate a state. Copy the current state into
		// this newly created state. Then allocate a state object and
		// fill in the current time and a pointer to the newly copied
		// current state.
		startStateTiming(simObjectID);

		State *newState = object->allocateState();
		newState->copyState(object->getState());
		SetObject<State> stateObject(currentTime, newState);

		// look up the state queue of the simulation object and insert the
		// newly allocated state object
		ThreadedStateManagerImplementationBase::getStateQueueLock(threadID,
				simObjectID);
		myStateQueue[simObjectID].insert(stateObject);
		/*cout << "Saving at the Time Stamp :::::"
		 << currentTime.getApproximateIntTime() << endl;*/
		ThreadedStateManagerImplementationBase::releaseStateQueueLock(threadID,
				simObjectID);

		// reset period counter to state period
		periodCounter[simObjectID] = objectStatePeriod[simObjectID];
		stopStateTiming(simObjectID);
	} else {
		// decrement period counter
		periodCounter[simObjectID] = periodCounter[simObjectID] - 1;
	}
}
开发者ID:CindyYang85,项目名称:pdes,代码行数:41,代码来源:ThreadedCostAdaptiveStateManager.cpp


注:本文中的ObjectID类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。