本文整理汇总了C++中CreatureObject::setMovementScale方法的典型用法代码示例。如果您正苦于以下问题:C++ CreatureObject::setMovementScale方法的具体用法?C++ CreatureObject::setMovementScale怎么用?C++ CreatureObject::setMovementScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CreatureObject
的用法示例。
在下文中一共展示了CreatureObject::setMovementScale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void MoveSimManager::start (const NetworkId & userId, int numNpcToSpawn, int numPcToSpawn, float radius, float moveSpeed)
{
if (!ConfigServerGame::getMoveSimEnabled ())
return;
const ServerObject * const player = safe_cast<ServerObject *>(NetworkIdManager::getObjectById (userId));
if (!player)
return;
float halfMapWidth = 1000.0f;
TerrainObject * const terrainObject = TerrainObject::getInstance ();
if (terrainObject)
{
//- subtract a 512 meter invalid band around the edge of the map
halfMapWidth = (terrainObject->getMapWidthInMeters () * 0.5f) - 512.0f;
}
const Vector & player_pos_w = player->getPosition_w ();
const int numToSpawn = numPcToSpawn + numNpcToSpawn;
const float randomRadiusArea = std::min (halfMapWidth * 2.0f, radius * 0.7f);
for (int i = 0; i < numToSpawn; ++i)
{
Vector pos = player_pos_w;
pos.x += Random::randomReal (-randomRadiusArea, randomRadiusArea);
pos.z += Random::randomReal (-randomRadiusArea, randomRadiusArea);
pos.x = std::min (halfMapWidth, std::max (-halfMapWidth, pos.x));
pos.z = std::min (halfMapWidth, std::max (-halfMapWidth, pos.z));
float angle = Random::randomReal (0.0f, PI * 2.0f);
Transform tr;
tr.setPosition_p(pos);
tr.yaw_l(angle);
CreatureObject * creature = 0;
if (numPcToSpawn-- > 0)
{
creature = dynamic_cast<CreatureObject *>(ServerWorld::createNewObject(templateName_pc, tr, 0, false));
creature->setPlayerControlled (true);
ServerWorld::createNewObject (ConfigServerGame::getPlayerObjectTemplate (), *creature, false);
}
else
{
creature = dynamic_cast<CreatureObject *>(ServerWorld::createNewObject(templateName_npc, tr, 0, false));
}
if (!creature)
return;
creature->addToWorld ();
const float naturalRunSpeed = safe_cast<const SharedCreatureObjectTemplate *>(creature->getSharedTemplate())->getSpeed(SharedCreatureObjectTemplate::MT_run);
const float moveScale = moveSpeed / naturalRunSpeed;
creature->setMovementScale (moveScale);
MoveSimController * const msc = new MoveSimController (creature, player_pos_w, radius);
creature->setController (msc);
creature->scheduleForAlter ();
setCreatureObjVars (*creature, player_pos_w, radius);
s_moveSimCreatures.push_back (creature->getNetworkId ());
}
}