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


C++ PlayerObject::checkIfMountCalled方法代码示例

本文整理汇总了C++中PlayerObject::checkIfMountCalled方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::checkIfMountCalled方法的具体用法?C++ PlayerObject::checkIfMountCalled怎么用?C++ PlayerObject::checkIfMountCalled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerObject的用法示例。


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

示例1: Store

//===============================================================================================
//stores the physical body
void VehicleController::Store()
{
    if(!body_)    {
        DLOG(info) << "Vehicle::store() Error: Store was called for a nonexistant body object!";
        return;
    }

	PlayerObject* owner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(owner_));

    if(!owner_ || owner->GetCreature()->isDead() || owner->GetCreature()->isIncapacitated())    {
        DLOG(info) << "Vehicle::store() couldnt find owner";
        return;
    }

    // todo auto dismount
    if(owner->checkIfMounted())
    {
		DLOG(info) << "Vehicle::store() dismounted";
        DismountPlayer();
    }

    if(!owner->checkIfMountCalled())
    {
        DLOG(info) << "Vehicle::store() Mount wasnt called !!!";
        return;
    }

	//the body is a creature_object!!!
	gSpatialIndexManager->RemoveObjectFromWorld(body_);

    owner->setMount(NULL);

    owner->setMounted(false);
    owner->setMountCalled(false);

    // finally unload & destroy the vehicle creature
    gWorldManager->destroyObject(body_);

    // null the reference
    body_ = NULL;

}
开发者ID:ELMERzark,项目名称:mmoserver,代码行数:44,代码来源:VehicleController.cpp

示例2: Call

void VehicleController::Call() {
    if(body_)	{
        assert(false && "void Vehicle::call() body already exists");
        return;
    }

	PlayerObject* owner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(owner_));
	
    if(owner->checkIfMountCalled()) {
		LOG(info) << "VehicleController::Call : body already in world " << this->getId();
        return;
    }

    if(!owner->isConnected() || owner->GetCreature()->isDead() || owner->GetCreature()->isIncapacitated()) {
		LOG(info) << "VehicleController::Call : owner statecheck fail for " << this->getId();
        return;
    }

    body_ = new MountObject();

    BString cust;
    cust.initRawBSTR((int8*)Swoop_Customization, BSTRType_ANSI);
    body_->setCustomizationStr("");//cust.getAnsi());
    body_->setCreoGroup(CreoGroup_Vehicle);
    body_->setTypeOptions(0x1080);
    body_->setMoodId(0);
    body_->setCL(0);

    body_->setId(mId + 1);	// Vehicles are created by the VehicleControllerFactory with +2 step for IDs

    body_->set_controller(this->getId());

    body_->set_owner(owner->getId());
    body_->setParentId(0);
    body_->SetTemplate(mPhysicalModel);
    body_->setSpeciesGroup(mNameFile.getAnsi());
    body_->setSpeciesString(mName.getAnsi());
    body_->SetPosture(0);
    body_->setScale(1.0f);

	std::string con = this->getAttribute<std::string>("condition");
	uint32 health_current = atoi(con.substr(0,con.find_first_of("/")).c_str());
	uint32 health_max = atoi(con.substr(con.find_first_of("/")+1,con.find_first_of("/")).c_str());

	for(int8 i = 0; i<9;i++)	{
		body_->InitStatBase(0);
		body_->InitStatCurrent(0);
		body_->InitStatMax(0);
		body_->InitStatWound(0);
	}

	body_->InitStatCurrent(HamBar_Health, health_current);
	body_->InitStatMax(HamBar_Health, health_max);
	
    owner->setMount(body_);
    owner->setMounted(false);
    owner->setMountCalled(false);

    // Set default direction and position for the body.
	body_->mDirection = owner->GetCreature()->mDirection;
    body_->mPosition  = owner->GetCreature()->mPosition;

    // Move it forward 2 meters
    body_->moveForward(2);
	
	auto terrain = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::terrain::TerrainService>("TerrainService");

	gObjectManager->LoadSlotsForObject(body_);
	
	body_->mPosition.y =	terrain->GetHeight(gWorldManager->getZoneId(), body_->mPosition.x,body_->mPosition.z) + 0.3;

    // Finally rotate it perpendicular to the player.
    body_->rotateRight(90.0f);

    // add to world
    if(!gWorldManager->addObject(body_)) {
		DLOG(info) << "void Vehicle::call() creating vehicle with id "<<body_->getId()<<" failed : couldnt add to world";
        SAFE_DELETE(body_);
        return;
    }

	auto permissions_objects_ = gObjectManager->GetPermissionsMap();
	body_->SetPermissions(permissions_objects_.find(swganh::object::RIDEABLE_PERMISSION)->second.get());//CREATURE_PERMISSION

	//currently done by gWorldManager->addObject(body_)
	//gSpatialIndexManager->createInWorld(body_);

    gMessageLib->sendUpdateTransformMessage(body_);

    owner->setMountCalled(true);

    return;
}
开发者ID:ELMERzark,项目名称:mmoserver,代码行数:93,代码来源:VehicleController.cpp

示例3: _updateInRangeObjectsOutside

bool ObjectController::_updateInRangeObjectsOutside()
{
	PlayerObject*	player = dynamic_cast<PlayerObject*>(mObject);

	// We may wan't to limit the amount of messages sent in one session.
	uint32 updatedObjects = 0;
	const uint32 objectSendLimit = 50;

	while ((mObjectSetIt != mInRangeObjects.end()) && (updatedObjects < objectSendLimit))
	{
		//BEWARE Object is at this time possibly not valid anymore!
		//this actually causes a lot of crashes!!!!

		Object* object = dynamic_cast<Object*>(*mObjectSetIt);
		// Just simplified the code a little. Good find Schmunzel.

		// only add it if its also outside
		// see if its already observed, if yes, just send a position update out, if its a player
		if ((object) && (!player->checkKnownObjects(object)))
		{
			// send the according create for the type of object
#if defined(_MSC_VER)
			if (object->getId() > 0x0000000100000000)
#else
			if (object->getId() > 0x0000000100000000LLU)
#endif
			{
				if (object->getPrivateOwner())
				{
					if (object->isOwnedBy(player))
					{
						gMessageLib->sendCreateObject(object,player);
						player->addKnownObjectSafe(object);
						object->addKnownObjectSafe(player);

						//If player has a mount make sure add to its known objects
						//but is the mount even near us ???
						// does this even matter ?

						if(player->checkIfMountCalled() && player->getMount())
						{
							if(player->getMount()->getId() != object->getId())
							{
								player->getMount()->addKnownObjectSafe(object);
								object->addKnownObjectSafe(player->getMount());
							}
						}
						updatedObjects++;
					}
				}
				else
				{
					//if(!player->checkKnownObjects(object))
					//{
						gMessageLib->sendCreateObject(object,player);
						player->addKnownObjectSafe(object);
						object->addKnownObjectSafe(player);

						//If player has a mount make sure add to its known objects
						if(player->checkIfMountCalled() && player->getMount())
						{
							if(player->getMount()->getId() != object->getId())
							{
								player->getMount()->addKnownObjectSafe(object);
								object->addKnownObjectSafe(player->getMount());
							}
						}
					//}
					updatedObjects++;
				}
			}
		}
		++mObjectSetIt;
	}
	return (mObjectSetIt == mInRangeObjects.end());
}
开发者ID:Arnold47525,项目名称:mmoserver,代码行数:76,代码来源:OCDataTransformhandlers.cpp


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