void dot_t::schedule_tick() { if ( sim.debug ) sim.out_debug.printf( "%s schedules tick for %s on %s", source -> name(), name(), target -> name() ); if ( current_tick == 0 ) { if ( current_action -> tick_zero ) { time_to_tick = timespan_t::zero(); current_action -> tick( this ); if ( current_tick == num_ticks ) { last_tick(); return; } } } time_to_tick = current_action -> tick_time( state -> haste ); tick_event = new ( sim ) dot_tick_event_t( this, time_to_tick ); ticking = true; if ( current_action -> channeled ) { // FIXME: Find some way to make this more realistic - the actor shouldn't have to recast quite this early // Response: "Have to"? It might be good to recast early - since the GCD will end sooner. Depends on the situation. -ersimont expr_t* expr = current_action -> early_chain_if_expr; if ( ( ( current_action -> chain && current_tick + 1 == num_ticks ) || ( current_tick > 0 && expr && expr -> success() && current_action -> player -> gcd_ready <= sim.current_time ) ) && current_action -> ready() && !is_higher_priority_action_available() ) { // FIXME: We can probably use "source" instead of "action->player" current_action -> player -> channeling = 0; current_action -> player -> gcd_ready = sim.current_time + current_action -> gcd(); current_action -> execute(); if ( current_action -> result_is_hit( current_action -> execute_state -> result ) ) { current_action -> player -> channeling = current_action; } else { cancel(); current_action -> player -> schedule_ready(); } } else { current_action -> player -> channeling = current_action; } } }
void dot_t::cancel() { if ( ! ticking ) return; last_tick(); reset(); }
void VideoFrameDispatchQueue::run() { osg::Timer t; static unsigned int frame_delay = 1000 * 1000 / 120; _block.reset(); _block.block(); while(!_finished) { unsigned int num_items(0); { osg::Timer_t last_tick(t.tick()); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); for(Queue::iterator i = _queue.begin(); i != _queue.end(); ) { osg::observer_ptr<VideoImageStream> stream(*i); if (stream.valid() && stream->needsDispatching()) { if (stream.valid()) stream->decodeFrame(); ++num_items; ++i; } else { if (stream.valid()) stream->setDispatchQueue(NULL); _queue.erase(i++); } } _numItems = num_items; if (_numItems > 0) { unsigned int dt = t.delta_u(last_tick, t.tick()); if (dt < frame_delay) { OpenThreads::Thread::microSleep(frame_delay - dt); } } } if (_numItems == 0) { // std::cout << this << " blocking" << std::endl; _block.reset(); _block.block(); } } }
void draw(SDL_Renderer *renderer) { if (last_tick(ti) >= SCREEN_TICKS_PER_FRAME) { //printf("ltick %d, %d\n", last_tick(ti), SCREEN_TICKS_PER_FRAME); SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); SDL_RenderClear(renderer); for (int i = 0; i < BOX_COUNT; i++) box[i].draw(renderer); SDL_RenderPresent(renderer); update_tick(ti); } else { SDL_Delay(1); } }
void action_t::cancel() { if ( ticking ) last_tick(); if ( player -> executing == this ) player -> executing = 0; if ( player -> channeling == this ) player -> channeling = 0; event_t::cancel( execute_event ); event_t::cancel( tick_event ); ticking = 0; current_tick = 0; added_ticks = 0; cooldown -> reset(); dot -> reset(); execute_event = 0; tick_event = 0; snapshot_haste = -1.0; if ( observer ) *observer = 0; }
void dot_t::check_tick_zero() { // If we're precasting a helpful dot and we're not in combat, fake precasting by using a first tick. // We also reduce the duration by one tick interval in action_t::trigger_dot(). bool fake_first_tick = ! current_action -> harmful && ! current_action -> player -> in_combat; if ( current_action -> tick_zero || fake_first_tick ) { timespan_t previous_ttt = time_to_tick; time_to_tick = timespan_t::zero(); // Recalculate num_ticks: timespan_t tick_time = current_action->tick_time(state->haste); assert( tick_time > timespan_t::zero() && "A Dot needs a positive tick time!" ); num_ticks = current_tick + as<int>(std::ceil(remains() / tick_time ) ); tick_zero(); if ( remains() <= timespan_t::zero() ) { last_tick(); return; } time_to_tick = previous_ttt; } }