本文整理汇总了C++中world类的典型用法代码示例。如果您正苦于以下问题:C++ world类的具体用法?C++ world怎么用?C++ world使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了world类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* Called by the world that's holding the entity every tick (50ms).
* A return value of true will cause the world to destroy the entity.
*/
bool
e_pickup::tick (world &w)
{
if (!valid)
return false;
if (entity::tick (w))
return true;
if (!pickable ())
return false;
// fetch closest player
std::pair<player *, double> closest;
int i = 0;
e_pickup *me = this;
w.get_players ().all (
[&i, me, &closest] (player *pl)
{
if (pl->is_dead ())
return;
double dist = calc_distance_squared (me->pos, pl->pos);
if (i == 0)
closest = {pl, dist};
else
{
if (dist < closest.second)
closest = {pl, dist};
}
++ i;
});
if ((i == 0) || (closest.second > 2.25))
return false;
player *pl = closest.first;
if (!pl) return false;
int r = pl->inv.add (this->data);
if (r == 0)
{
w.get_players ().send_to_all_visible (
packets::play::make_collect_item (this->eid, pl->get_eid ()),
this);
}
this->data.set_amount (r);
pl->send (packets::play::make_sound_effect ("random.pop",
this->pos.x, this->pos.y, this->pos.z, 0.2f, 98));
if (this->data.empty ())
{
this->valid = false;
w.despawn_entity (this);
return true;
}
return false;
}
示例2: _try_door_nolock
static bool
_try_door_nolock (world &w, int x, int y, int z, block_data bd)
{
if (bd.ex != BE_DOOR) return false;
w.queue_update_nolock (x, y, z, BT_AIR);
w.queue_physics (x, y, z, bd.id | (bd.meta << 12), nullptr, DOOR_TICK_RATE, nullptr, _door_tick);
return true;
}
示例3: _try_block
static int
_try_block (world &w, int x, int y, int z)
{
int prev_id = w.get_final_block (x, y, z).id;
if (!w.in_bounds (x, y, z) || !_is_water (prev_id))
return -1;
w.queue_update (x, y, z, BT_SHARK);
return prev_id;
}
示例4: _sur_water
static int
_sur_water (world &w, int x, int y, int z)
{
int id;
if (_is_water (id = w.get_final_block (x - 1, y, z).id)) return id;
if (_is_water (id = w.get_final_block (x + 1, y, z).id)) return id;
if (_is_water (id = w.get_final_block (x, y, z - 1).id)) return id;
if (_is_water (id = w.get_final_block (x, y, z + 1).id)) return id;
return 0;
}
示例5: countWorldParts
/**
* @brief countWorldParts: This function count how many parts are in the World
* @param w: The World
* @param blockedWorms: The Worms, that block fields
* @return The Count of seperated Parts in the Map
*/
uint Tools::countWorldParts(const world& w, const WormContainer& blockedWorms){
visitedMap map;
uint result(0);
createVisitedMap(w, map, blockedWorms);
for(uint x=0; x< w.getSizeX(); ++x){
for(uint y=0; y < w.getSizeY(); ++y){
if(map[x][y] == false){
result++;
getWorldPartSize(w,map, WormPart(x,y));
}
}
}
return result;
}
示例6: getinitargs
static
boost::python::tuple
getinitargs(const world& w)
{
using namespace boost::python;
return boost::python::make_tuple(w.get_country());
}
示例7: getWorldPartSize
uint Tools::getWorldPartSize(const world &w, const uint &worms, const WormPart& p){
visitedMap map;
WormContainer wCon;
wCon.push_back(w.getWorm(worms));
createVisitedMap(w, map, wCon);
return getWorldPartSize(w, map, p);
}
示例8: take_damage
void unit::take_damage(int damage, world &w, bool net_src)
{
object::take_damage(damage, w, net_src);
if (hp <= 0 && m_render.is_valid() && m_render->visible)
{
w.spawn_explosion(get_pos(), 30.0f);
m_render->visible = false;
}
}
示例9:
insula::physics::scoped_body::scoped_body(
world &w,
btRigidBody &b)
:
w(w),
b(b)
{
w.add(
b);
}
示例10: runtime_error
soil_generator::soil_generator(world& w, const ptree& conf)
: terrain_generator_i(w, conf)
, surfacemap_(w.find_area_generator("surface"))
, grass_(find_material("grass"))
, dirt_(find_material("dirt"))
, rock_(find_material("cobblestone"))
, sand_(find_material("sand"))
{
if (surfacemap_ < 0)
throw std::runtime_error("soil_generator requires a surface map");
}
示例11:
void
world::write(const world& w, std::ostream& o)
{
for(size_t col = 0; col < w.cols_; ++col)
{
for(size_t row = 0; row < w.rows_; ++row)
{
o << (w.has_cell(row, col) ? 'o' : ' ');
}
o << std::endl;
}
}
示例12: dis
void
snow::tick (world &w, int x, int y, int z, int extra, void *ptr,
std::minstd_rand& rnd)
{
if (y <= 0)
{ w.queue_update (x, y, z, BT_AIR); return; }
if (w.get_final_block (x, y, z).id != BT_SNOW_BLOCK)
return;
int below = w.get_final_block (x, y - 1, z).id;
if (w.get_final_block (x, y - 1, z).id != BT_AIR)
{
if (below == BT_SNOW_BLOCK || below == BT_SNOW_COVER)
w.queue_update (x, y, z, BT_AIR);
else
w.queue_update (x, y, z, BT_SNOW_COVER);
}
else
{
w.queue_update (x, y, z, BT_AIR);
int nx = x, nz = z;
std::uniform_int_distribution<> dis (1, 4);
int d = dis (rnd);
switch (d)
{
case 1: ++ nx; break;
case 2: -- nx; break;
case 3: ++ nz; break;
case 4: -- nz; break;
}
if (w.get_final_block (nx, y - 1, nz) == BT_AIR)
w.queue_update (nx, y - 1, nz, BT_SNOW_BLOCK);
else
w.queue_update (x, y - 1, z, BT_SNOW_BLOCK);
}
}
示例13: w_next
world
world::evolve(const world& w)
{
world w_next(w);
// TODO could this be a bit more object oriented, please?
for(size_t col = 0; col < w.cols_; ++col)
{
for(size_t row = 0; row < w.rows_; ++row)
{
size_t n = w.neighbours(row, col);
if(w.has_cell(row, col))
{
if(n < 2)
{
w_next.put_cell(row, col, false);
}
else if(n == 2 || n == 3)
{
w_next.put_cell(row, col, true);
}
else
{
w_next.put_cell(row, col, false);
}
}
else
{
if(n == 3)
{
w_next.put_cell(row, col, true);
}
}
}
}
return w_next;
}
示例14: createVisitedMap
/**
* @brief createVisitedMap
* @param w: The Current World: needed for size and blocked fields
* @param map: The Result Map
* @param worms: Worms that block fields
*/
void createVisitedMap(const world& w, visitedMap& map, const WormContainer& worms){
map.clear();
for(uint x=0; x<w.getSizeX(); ++x){
visitedMapInnerContainer innerContainer;
for(uint y=0; y<w.getSizeY(); ++y){
if(w.getWormMap().getTheHomeFor(x,y) == 1){
innerContainer.push_back(true);
} else{
bool found(false);
for(const Worm& wurm: worms){
if(wurm.contains(WormPart(x,y))) {
innerContainer.push_back(true);
found = true;
break;
}
}
if(!found)
innerContainer.push_back(false);
}
}
map.push_back(innerContainer);
}
}
示例15: draw
void panel::draw(const aircraft& a, const world& w)
{
sdl_helper::normal_line_color(0.0, 0.3, 0.4, 0.2, sdl_helper::WHITE);
sdl_helper::normal_line_color(0.4, 0.2, 0.8, 0.2, sdl_helper::WHITE);
sdl_helper::normal_line_color(0.8, 0.2, 1.2, 0.3, sdl_helper::WHITE);
std::map<int, panel_element*>::iterator iter;
for (iter = elements.begin(); iter != elements.end(); iter++)
{
iter->second->draw(a, w);
}
w.draw_moving_map(0.75, 0.75, 0.23, 0.23, a);
}