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


C++ monster::pos3方法代码示例

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


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

示例1: despawn_monster

void overmapbuffer::despawn_monster(const monster &critter)
{
    // Get absolute coordinates of the monster in map squares, translate to submap position
    tripoint sm = ms_to_sm_copy( g->m.getabs( critter.pos3() ) );
    // Get the overmap coordinates and get the overmap, sm is now local to that overmap
    const point omp = sm_to_om_remain( sm.x, sm.y );
    overmap &om = get( omp.x, omp.y );
    // Store the monster using coordinates local to the overmap.
    om.monster_map.insert( std::make_pair( sm, critter ) );
}
开发者ID:golgepapaz,项目名称:Cataclysm-DDA,代码行数:10,代码来源:overmapbuffer.cpp

示例2: add

bool Creature_tracker::add( monster &critter )
{
    if( critter.type->id == "mon_null" ) { // Don't wanna spawn null monsters o.O
        return false;
    }

    if( -1 != mon_at( critter.pos3() ) ) {
        debugmsg( "add_zombie: there's already a monster at %d,%d,%d", 
                  critter.posx(), critter.posy(), critter.posz() );
        return false;
    }

    if( monster_is_blacklisted(critter.type) ) {
        return false;
    }

    monsters_by_location[critter.pos3()] = monsters_list.size();
    monsters_list.push_back(new monster(critter));
    return true;
}
开发者ID:Camkitsune,项目名称:Cataclysm-DDA,代码行数:20,代码来源:creature_tracker.cpp

示例3: remove_from_location_map

void Creature_tracker::remove_from_location_map( const monster &critter )
{
    const tripoint &loc = critter.pos3();
    const auto pos_iter = monsters_by_location.find( loc );
    if( pos_iter != monsters_by_location.end() ) {
        const auto &other = find( pos_iter->second );
        if( &other == &critter ) {
            monsters_by_location.erase( pos_iter );
        }
    }
}
开发者ID:Camkitsune,项目名称:Cataclysm-DDA,代码行数:11,代码来源:creature_tracker.cpp

示例4: update_pos

bool Creature_tracker::update_pos(const monster &critter, const tripoint &new_pos)
{
    const auto old_pos = critter.pos3();
    if( critter.is_dead() ) {
        // mon_at ignores dead critters anyway, changing their position in the
        // monsters_by_location map is useless.
        remove_from_location_map( critter );
        return true;
    }

    bool success = false;
    const int critter_id = mon_at( old_pos );
    const int new_critter_id = mon_at( new_pos );
    if( new_critter_id >= 0 ) {
        debugmsg("update_zombie_pos: new location %d,%d,%d already has zombie %d",
                 new_pos.x, new_pos.y, new_pos.z, new_critter_id);
    } else if( critter_id >= 0 ) {
        if( &critter == monsters_list[critter_id] ) {
            monsters_by_location.erase( old_pos );
            monsters_by_location[new_pos] = critter_id;
            success = true;
        } else {
            debugmsg("update_zombie_pos: old location %d,%d had zombie %d instead",
                     old_pos.x, old_pos.y, critter_id);
        }
    } else {
        // We're changing the x/y/z coordinates of a zombie that hasn't been added
        // to the game yet. add_zombie() will update monsters_by_location for us.
        debugmsg("update_zombie_pos: no such zombie at %d,%d,%d (moving to %d,%d,%d)",
                 old_pos.x, old_pos.y, old_pos.z, new_pos.x, new_pos.y, new_pos.z );
        // Rebuild cache in case the monster actually IS in the game, just bugged
        rebuild_cache();
    }

    return success;
}
开发者ID:Camkitsune,项目名称:Cataclysm-DDA,代码行数:36,代码来源:creature_tracker.cpp


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