本文整理汇总了C++中environment::distance方法的典型用法代码示例。如果您正苦于以下问题:C++ environment::distance方法的具体用法?C++ environment::distance怎么用?C++ environment::distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类environment
的用法示例。
在下文中一共展示了environment::distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: action_unit
void npc::action_unit(environment ¤t)
{
person::action_unit(current);
point dest = current.player()->position();
if (m_ai_state == ai_state::idle)
{
if (current.distance(dest, position()) <= alert_distance || !health().full())
{
m_ai_state = ai_state::alert;
current.broadcast({ "!", 0xff0000, position(), 1.0 });
}
}
else if (m_ai_state == ai_state::alert)
{
auto scene = current.scene();
auto path = path::find(position(), dest, 50, [&](const point &p) { return scene->traversable(p); });
if (path)
{
auto step = path->begin();
if (step != path->end())
{
auto blocking = scene->blocking(*step);
if (blocking && !blocking->invincible())
{
for (auto &skill : m_skills)
{
if (skill.targeted() && skill.useable(this, blocking))
{
skill.use(this, blocking);
break;
}
else if (skill.useable(this, dest))
{
skill.use(this, dest);
break;
}
}
}
else
{
scene->move(*this, *step);
}
}
}
}
}