bool ConditionDamage::init() { if(periodDamage) return true; if(!damageList.empty()) return true; setTicks(0); int32_t amount = random_range(minDamage, maxDamage); if(!amount) return false; if(startDamage > maxDamage) startDamage = maxDamage; else if(!startDamage) startDamage = std::max((int32_t)1, (int32_t)std::ceil(((float)amount / 20.0))); std::list<int32_t> list; ConditionDamage::generateDamageList(amount, startDamage, list); for(std::list<int32_t>::iterator it = list.begin(); it != list.end(); ++it) addDamage(1, tickInterval, -(*it)); return !damageList.empty(); }
bool ConditionDamage::init() { if(periodDamage != 0){ return true; } if(damageList.empty()){ setTicks(0); int32_t amount = random_range(minDamage, maxDamage); if(amount != 0){ if(startDamage > maxDamage){ startDamage = maxDamage; } else if(startDamage == 0){ startDamage = std::max((int32_t)1, (int32_t)std::ceil(((float)amount / 20.0))); } std::list<int32_t> list; ConditionDamage::generateDamageList(amount, startDamage, list); for(std::list<int32_t>::iterator it = list.begin(); it != list.end(); ++it){ addDamage(1, tickInterval, -*it); } } } return (!damageList.empty()); }
void Workspace::damageNotifyEvent( const XDamageNotifyEvent *event ) { Client *client = find( event->drawable ); // ### should never happen if ( !client ) return; XserverRegion parts; if ( !client->isPainted() ) { // If the window has been painted for the first time, mark the whole // window as damaged. parts = client->createRegion( WindowAndBorder ); XDamageSubtract( dpy, client->damageHandle(), None, None ); client->setPainted( true ); } else { // Create a new empty region parts = XFixesCreateRegion( dpy, 0, 0 ); // Copy the damage region to parts, subtracting it from the widgets damage XDamageSubtract( dpy, client->damageHandle(), None, parts ); // Offset parts with the widgets position XFixesTranslateRegion( dpy, parts, client->x(), client->y() ); } // Add the damaged region to the total damage for the workspace // (destroys parts) addDamage( parts ); }
bool ConditionDamage::init() { if (periodDamage != 0) { return true; } if (damageList.empty()) { setTicks(0); int32_t amount = uniform_random(minDamage, maxDamage); if (amount != 0) { if (startDamage > maxDamage) { startDamage = maxDamage; } else if (startDamage == 0) { startDamage = std::max<int32_t>(1, std::ceil(amount / 20.0)); } std::list<int32_t> list; ConditionDamage::generateDamageList(amount, startDamage, list); for (int32_t value : list) { addDamage(1, tickInterval, -value); } } } return !damageList.empty(); }
void CompositeWindow::updateSaturation () { unsigned short saturation; saturation = screen->getWindowProp32 (priv->window->id (), Atoms::winSaturation, COLOR); if (saturation != priv->saturation) { priv->saturation = saturation; addDamage (); } }
void CompositeWindow::updateBrightness () { unsigned short brightness; brightness = screen->getWindowProp32 (priv->window->id (), Atoms::winBrightness, BRIGHT); if (brightness != priv->brightness) { priv->brightness = brightness; addDamage (); } }
void CompositeWindow::updateOpacity () { if (priv->window->type () & CompWindowTypeDesktopMask) return; unsigned short opacity = screen->getWindowProp32 (priv->window->id (), Atoms::winOpacity, OPAQUE); if (opacity != priv->opacity) { priv->opacity = opacity; addDamage (); } }
void Workspace::propertyNotifyEvent( const XPropertyEvent *event ) { //char *name = XGetAtomName( dpy, event->atom ); //std::cout << "property \"" << name << "\" changed.\n"; //XFree( name ); // Handle property events for the root window if ( event->window == rootId() ) { // Major optimization when switching desktops; we'll block updates and just // let damage accumulate until all newly mapped windows have been painted. if ( event->atom == ATOM(_NET_CURRENT_DESKTOP) ) { mWaitForClients = true; XSync( dpy, false ); // Helps to accumulate more events } // If the root window pixmap was changed else if ( event->atom == ATOM(_XROOTPMAP_ID) || event->atom == ATOM(_XSETROOT_ID) || event->atom == ATOM(ESETROOT_PMAP_ID) ) { // Compress these events XEvent dummy; while ( XCheckIfEvent( dpy, &dummy, rootPixmapPredicate, XPointer( rootId() ) ) ); // Destroy the root tile picture releasePicture( mRootTile ); // Damage the whole display XserverRegion r = createRegionFromQRect( QRect( 0, 0, width(), height() ) ); addDamage( r ); } } // Handle notifications of changes to window opacity hints else if ( event->atom == ATOM(_NET_WM_WINDOW_OPACITY)) { // Compress opacity change events for the window XEvent dummy; while ( XCheckIfEvent( dpy, &dummy, windowOpacityPredicate, XPointer(event->window) ) ); Client *client = find( event->window ); if ( client ) client->opacityChanged(); } }
// Handles expose events for the root window void Workspace::exposeEvent( const XExposeEvent *event ) { if ( event->window != rootId() ) return; int more = event->count + 1; if ( mExposeRects.count() + more > mExposeRects.capacity() ) mExposeRects.reserve( mExposeRects.count() + more ); XRectangle r = { event->x, event->y, event->width, event->height }; mExposeRects.append( r ); if ( event->count == 0 ) { XserverRegion damage = XFixesCreateRegion( dpy, &mExposeRects.first(), mExposeRects.count() ); addDamage( damage ); mExposeRects.clear(); } }
CompositeWindow::~CompositeWindow () { if (priv->damage) XDamageDestroy (screen->dpy (), priv->damage); if (!priv->redirected) { priv->cScreen->overlayWindowCount ()--; if (priv->cScreen->overlayWindowCount () < 1) priv->cScreen->showOutputWindow (); } release (); addDamage (); if (lastDamagedWindow == priv->window) lastDamagedWindow = NULL; delete priv; }
void ThreatMapEntry::addDamage(WeaponObject* weapon, uint32 damage) { addDamage(weapon->getXpType(), damage); }
void Enemy::checkDamage() { int ch; // Chech shots. for (int i = 0; i < shots->actor.size(); ++i) { if (!shots->actor[i]->isExist) continue; Vector sp = tr1::dynamic_pointer_cast<Shot>(shots->actor[i])->pos; ch = checkHit(sp, 0.7, 0); if (ch >= HIT) { manager->addParticle(sp, rand.nextSignedFloat(0.3), 0, Shot::SPEED / 4); manager->addParticle(sp, rand.nextSignedFloat(0.3), 0, Shot::SPEED / 4); manager->addParticle(sp, M_PI + rand.nextSignedFloat(0.3), 0, Shot::SPEED / 7); shots->actor[i]->isExist = false; if (ch == HIT) addDamage(SHOT_DAMAGE); else addDamageBattery(ch, SHOT_DAMAGE); } } if (manager->mode == P47GameManager::ROLL) { // Chech rolls. for (int i = 0; i < rolls->actor.size(); ++i) { if (!rolls->actor[i]->isExist) continue; tr1::shared_ptr<Roll> rl = tr1::dynamic_pointer_cast<Roll>(rolls->actor[i]); ch = checkHit(rl->pos[0], 1.0, 1.0); if (ch >= HIT) { for (int i = 0; i < 4; ++i) manager->addParticle(rl->pos[0], rand.nextFloat(M_PI * 2), 0, Shot::SPEED / 10); float rd = ROLL_DAMAGE; if (rl->released) { rd += rd; } else { if (rl->cnt < Roll::NO_COLLISION_CNT) continue; } if (ch == HIT) addDamage(static_cast<int>(rd)); else addDamageBattery(ch, static_cast<int>(rd)); } } } else if (type->type != EnemyType::SMALL) { // Chech locks. for (int i = 0; i < locks->actor.size(); ++i) { if (!locks->actor[i]->isExist) continue; tr1::shared_ptr<Lock> lk = tr1::dynamic_pointer_cast<Lock>(locks->actor[i]); if (lk->state == Lock::SEARCH || lk->state == Lock::SEARCHED) { ch = checkLocked(lk->pos[0], 2.5, lk); if (ch >= HIT) { lk->state = Lock::SEARCHED; // lk->lockedEnemy = this; lk->lockedEnemy = returnSharedThis(); lk->lockedPart = ch; } return; // } else if (lk->state == Lock::FIRED && lk->lockedEnemy == this) { } else if (lk->state == Lock::FIRED && lk->lockedEnemy == returnSharedThis()) { ch = checkHit(lk->pos[0], 1.5, 1.5); if (ch >= HIT && ch == lk->lockedPart) { for (int i = 0; i < 4; ++i) manager->addParticle(lk->pos[0], rand.nextFloat(M_PI * 2), 0, Shot::SPEED / 10); if (ch == HIT) addDamage(LOCK_DAMAGE); else addDamageBattery(ch, LOCK_DAMAGE); lk->hit(); } } } } }