void GsTL_project::clear() { SmartPtr<Named_interface> ni_dir = Root::instance()->interface( gridModels_manager ); Manager* mng = dynamic_cast<Manager*>( ni_dir.raw_ptr() ); appli_assert( mng ); std::vector< std::string > tmp_copy( grid_objects_list_.size() ); std::copy( grid_objects_list_.begin(), grid_objects_list_.end(), tmp_copy.begin() ); for( std::vector< std::string >::iterator it = tmp_copy.begin(); it != tmp_copy.end(); ++it ) { mng->delete_interface( "/" + (*it) ); this->deleted_object( *it ); } project_modified_ = true; project_name_ = ""; }
void rotsprite_image(Image* bmp, Image* spr, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { static ImageBufferPtr buf1, buf2, buf3; // TODO non-thread safe if (!buf1) buf1.reset(new ImageBuffer(1)); if (!buf2) buf2.reset(new ImageBuffer(1)); if (!buf3) buf3.reset(new ImageBuffer(1)); int scale = 8; base::UniquePtr<Image> bmp_copy(Image::create(bmp->pixelFormat(), bmp->width()*scale, bmp->height()*scale, buf1)); base::UniquePtr<Image> tmp_copy(Image::create(spr->pixelFormat(), spr->width()*scale, spr->height()*scale, buf2)); base::UniquePtr<Image> spr_copy(Image::create(spr->pixelFormat(), spr->width()*scale, spr->height()*scale, buf3)); color_t maskColor = spr->maskColor(); bmp_copy->setMaskColor(maskColor); tmp_copy->setMaskColor(maskColor); spr_copy->setMaskColor(maskColor); bmp_copy->clear(bmp->maskColor()); spr_copy->clear(maskColor); spr_copy->copy(spr, gfx::Clip(spr->bounds())); for (int i=0; i<3; ++i) { tmp_copy->clear(maskColor); image_scale2x(tmp_copy, spr_copy, spr->width()*(1<<i), spr->height()*(1<<i)); spr_copy->copy(tmp_copy, gfx::Clip(tmp_copy->bounds())); } doc::algorithm::parallelogram(bmp_copy, spr_copy, x1*scale, y1*scale, x2*scale, y2*scale, x3*scale, y3*scale, x4*scale, y4*scale); doc::algorithm::scale_image(bmp, bmp_copy, 0, 0, bmp->width(), bmp->height()); }
void monster::die() { if (!dead) dead = true; if (!no_extra_death_drops) { drop_items_on_death(); } // If we're a queen, make nearby groups of our type start to die out if (has_flag(MF_QUEEN)) { // Do it for overmap above/below too for(int z = 0; z >= -1; --z) { for (int x = -MAPSIZE/2; x <= MAPSIZE/2; x++) { for (int y = -MAPSIZE/2; y <= MAPSIZE/2; y++) { std::vector<mongroup*> groups = g->cur_om->monsters_at(g->levx+x, g->levy+y, z); for (int i = 0; i < groups.size(); i++) { if (MonsterGroupManager::IsMonsterInGroup (groups[i]->type, (type->id))) groups[i]->dying = true; } } } } } // If we're a mission monster, update the mission if (mission_id != -1) { mission_type *misstype = g->find_mission_type(mission_id); if (misstype->goal == MGOAL_FIND_MONSTER) g->fail_mission(mission_id); if (misstype->goal == MGOAL_KILL_MONSTER) g->mission_step_complete(mission_id, 1); } // temporary copy as the death function might invalidate this when monster tmp_copy(*this); // Also, perform our death function mdeath md; if(is_hallucination()) { //Hallucinations always just disappear md.disappear(this); return; } else { (md.*type->dies)(this); } // If our species fears seeing one of our own die, process that int anger_adjust = 0, morale_adjust = 0; if (tmp_copy.type->has_anger_trigger(MTRIG_FRIEND_DIED)){ anger_adjust += 15; } if (tmp_copy.type->has_fear_trigger(MTRIG_FRIEND_DIED)){ morale_adjust -= 15; } if (tmp_copy.type->has_placate_trigger(MTRIG_FRIEND_DIED)){ anger_adjust -= 15; } if (anger_adjust != 0 && morale_adjust != 0) { int light = g->light_level(); for (int i = 0; i < g->num_zombies(); i++) { int t = 0; if (g->m.sees(g->zombie(i).posx(), g->zombie(i).posy(), tmp_copy._posx, tmp_copy._posy, light, t)) { g->zombie(i).morale += morale_adjust; g->zombie(i).anger += anger_adjust; } } } }