EngineerPost::EngineerPost() : ServiceBuilding( Service::engineer, constants::building::engineerPost, Size(1) ) { setPicture( ResourceGroup::buildingEngineer, 56 ); _animationRef().load( ResourceGroup::buildingEngineer, 57, 10 ); _animationRef().setDelay( 4 ); _animationRef().setOffset( Point( 10, 42 ) ); _fgPicturesRef().resize(1); }
void Granary::timeStep(const unsigned long time) { WorkingBuilding::timeStep( time ); if( getWorkersCount() > 0 ) { _animationRef().update( time ); _fgPicturesRef().at(5) = _animationRef().getFrame(); if( time % 22 == 1 && _d->goodStore.isDevastation() && (_d->goodStore.getCurrentQty() > 0) && getWalkers().empty() ) { _tryDevastateGranary(); } } }
Granary::Granary() : WorkingBuilding( constants::building::granary, Size(3) ), _d( new Impl ) { _d->goodStore.granary = this; setPicture( ResourceGroup::commerce, 140 ); _fgPicturesRef().resize(6); // 1 upper level + 4 windows + animation _animationRef().load(ResourceGroup::commerce, 146, 7, Animation::straight); // do the animation in reverse _animationRef().load(ResourceGroup::commerce, 151, 6, Animation::reverse); _animationRef().setDelay( 4 ); _fgPicturesRef().at(0) = Picture::load( ResourceGroup::commerce, 141); _fgPicturesRef().at(5) = _animationRef().getFrame(); computePictures(); _d->devastateThis = false; }
void EntertainmentBuilding::deliverService() { // we need all trainees types for the show if( !mayWork() ) { _animationRef().stop(); return; } bool isWalkerReady = _isWalkerReady(); int decreaseLevel = idleDecreaseLevel; // all trainees are there for the show! if( isWalkerReady ) { if( _specificWorkers().empty() ) { ServiceBuilding::deliverService(); if( !_specificWorkers().empty() ) { _d->showCounter++; _animationRef().start(); decreaseLevel = workDecreaseLevel; } } } if( _specificWorkers().empty() ) { _animationRef().stop(); //have no actors for the show } for( auto& item : _d->necWalkers ) { int level = traineeValue( item ); setTraineeValue( item, math::clamp( level - decreaseLevel, 0, 100) ); } }
void EngineerPost::timeStep(const unsigned long time) { bool mayAnimate = getWorkersCount() > 0; if( mayAnimate ) { if( _animationRef().isStopped() ) { _animationRef().setIndex( 0 ); _animationRef().start(); } } else if( _animationRef().isRunning() ) { _animationRef().stop(); _animationRef().setIndex( -1 ); _fgPicturesRef().back() = Picture::getInvalid(); } ServiceBuilding::timeStep( time ); }