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


C++ map::has_flag方法代码示例

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


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

示例1: can_move_to

bool monster::can_move_to(map &m, int x, int y)
{
 if (m.move_cost(x, y) == 0 &&
     (!has_flag(MF_DESTROYS) || !m.is_destructable(x, y)) &&
     ((!has_flag(MF_AQUATIC) && !has_flag(MF_SWIMS)) ||
      !m.has_flag(swimmable, x, y)))
  return false;
 if (has_flag(MF_DIGS) && !m.has_flag(diggable, x, y))
  return false;
 if (has_flag(MF_AQUATIC) && !m.has_flag(swimmable, x, y))
  return false;
 return true;
}
开发者ID:AkrionXxarr,项目名称:Cataclysm-DDA,代码行数:13,代码来源:monmove.cpp

示例2: vertical_move_destination

tripoint vertical_move_destination( const map &m, const tripoint &t )
{
    if( !m.has_zlevels() ) {
        return tripoint_min;
    }

    constexpr int omtileszx = SEEX * 2;
    constexpr int omtileszy = SEEY * 2;
    real_coords rc( m.getabs( t.x, t.y ) );
    point omtile_align_start(
        m.getlocal( rc.begin_om_pos() )
    );

    const auto &pf_cache = m.get_pathfinding_cache_ref( t.z );
    for( int x = omtile_align_start.x; x < omtile_align_start.x + omtileszx; x++ ) {
        for( int y = omtile_align_start.y; y < omtile_align_start.y + omtileszy; y++ ) {
            if( pf_cache.special[x][y] & PF_UPDOWN ) {
                const tripoint p( x, y, t.z );
                if( m.has_flag( flag, p ) ) {
                    return p;
                }
            }
        }
    }

    return tripoint_min;
}
开发者ID:RyanMcManaman,项目名称:Cataclysm-DDA,代码行数:27,代码来源:pathfinding.cpp

示例3: vertical_move_destination

tripoint vertical_move_destination( const map &m, const tripoint &t )
{
    if( !m.has_zlevels() ) {
        return tripoint_min;
    }

    constexpr int omtileszx = SEEX * 2;
    constexpr int omtileszy = SEEY * 2;
    real_coords rc( m.getabs( t.x, t.y ) );
    point omtile_align_start(
        m.getlocal( rc.begin_om_pos() )
    );

    tripoint from( omtile_align_start.x, omtile_align_start.y, t.z );
    tripoint to( omtile_align_start.x + omtileszx, omtile_align_start.y + omtileszy, t.z );

    // TODO: Avoid up to 576 bounds checks by using methods that don't check bounds
    for( const tripoint &p : m.points_in_rectangle( from, to ) ) {
        if( m.has_flag( flag, p ) ) {
            return p;
        }
    }

    return tripoint_min;
}
开发者ID:Mattychan,项目名称:Cataclysm-DDA,代码行数:25,代码来源:pathfinding.cpp

示例4: rate_location

/** Helper for place_player
 * Flood-fills the area from a given point, then returns the area it found.
 * Considers unpassable tiles passable if they can be bashed down or opened.
 * Will return INT_MAX if it reaches upstairs or map edge.
 * We can't really use map::route here, because it expects a destination
 * Maybe TODO: Allow "picking up" items or parts of bashable furniture
 *             and using them to help with bash attempts.
 */
int rate_location( map &m, const tripoint &p, const bool must_be_inside,
                   const int bash_str, const int attempt,
                   int ( &checked )[MAPSIZE * SEEX][MAPSIZE * SEEY] )
{
    if( ( must_be_inside && m.is_outside( p ) ) ||
        m.impassable( p ) ||
        checked[p.x][p.y] > 0 ) {
        return 0;
    }

    // Vector that will be used as a stack
    std::vector<tripoint> st;
    st.reserve( MAPSIZE * SEEX * MAPSIZE * SEEY );
    st.push_back( p );

    // If not checked yet and either can be moved into, can be bashed down or opened,
    // add it on the top of the stack.
    const auto maybe_add = [&]( const int x, const int y, const tripoint & from ) {
        if( checked[x][y] >= attempt ) {
            return;
        }

        const tripoint pt( x, y, p.z );
        if( m.passable( pt ) ||
            m.bash_resistance( pt ) <= bash_str ||
            m.open_door( pt, !m.is_outside( from ), true ) ) {
            st.push_back( pt );
        }
    };

    int area = 0;
    while( !st.empty() ) {
        area++;
        const tripoint cur = st.back();
        st.pop_back();

        checked[cur.x][cur.y] = attempt;
        if( cur.x == 0 || cur.x == SEEX * MAPSIZE - 1 ||
            cur.y == 0 || cur.y == SEEY * MAPSIZE - 1 ||
            m.has_flag( "GOES_UP", cur ) ) {
            return INT_MAX;
        }

        maybe_add( cur.x - 1, cur.y, cur );
        maybe_add( cur.x, cur.y - 1, cur );
        maybe_add( cur.x + 1, cur.y, cur );
        maybe_add( cur.x, cur.y + 1, cur );
        maybe_add( cur.x - 1, cur.y - 1, cur );
        maybe_add( cur.x + 1, cur.y - 1, cur );
        maybe_add( cur.x - 1, cur.y + 1, cur );
        maybe_add( cur.x + 1, cur.y + 1, cur );
    }

    return area;
}
开发者ID:nonymous,项目名称:Cataclysm-DDA,代码行数:63,代码来源:start_location.cpp


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