本文整理汇总了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 ) );
}
示例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;
}
示例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 );
}
}
}
示例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;
}